feat: add ability to see raw SQL results on test page
This commit is contained in:
@@ -68,10 +68,18 @@
|
|||||||
placeholder="Enter your SQL query here..."
|
placeholder="Enter your SQL query here..."
|
||||||
></textarea>
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-4">
|
<div class="mt-4 flex items-center gap-4">
|
||||||
<button :class="primaryButtonClasses" @click="executeSql">
|
<button :class="primaryButtonClasses" @click="executeSql">
|
||||||
Execute
|
Execute
|
||||||
</button>
|
</button>
|
||||||
|
<label class="flex items-center gap-2">
|
||||||
|
<input
|
||||||
|
v-model="returnRawResults"
|
||||||
|
type="checkbox"
|
||||||
|
class="rounded border-gray-300"
|
||||||
|
/>
|
||||||
|
<span class="text-sm">Return Raw Results</span>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="sqlResult" class="mt-4">
|
<div v-if="sqlResult" class="mt-4">
|
||||||
<h3 class="text-lg font-semibold mb-2">Result:</h3>
|
<h3 class="text-lg font-semibold mb-2">Result:</h3>
|
||||||
@@ -401,6 +409,7 @@ export default class Help extends Vue {
|
|||||||
// for SQL operations
|
// for SQL operations
|
||||||
sqlQuery = "";
|
sqlQuery = "";
|
||||||
sqlResult: unknown = null;
|
sqlResult: unknown = null;
|
||||||
|
returnRawResults = false;
|
||||||
|
|
||||||
cryptoLib = cryptoLib;
|
cryptoLib = cryptoLib;
|
||||||
|
|
||||||
@@ -961,15 +970,28 @@ export default class Help extends Vue {
|
|||||||
* Supports both SELECT queries (dbQuery) and other SQL commands (dbExec)
|
* Supports both SELECT queries (dbQuery) and other SQL commands (dbExec)
|
||||||
* Provides interface for testing raw SQL operations
|
* Provides interface for testing raw SQL operations
|
||||||
* Uses PlatformServiceMixin for database access and notification helpers for errors
|
* Uses PlatformServiceMixin for database access and notification helpers for errors
|
||||||
|
* When returnRawResults is true, uses direct platform service methods for unparsed results
|
||||||
*/
|
*/
|
||||||
async executeSql() {
|
async executeSql() {
|
||||||
try {
|
try {
|
||||||
const isSelect = this.sqlQuery.trim().toLowerCase().startsWith("select");
|
const isSelect = this.sqlQuery.trim().toLowerCase().startsWith("select");
|
||||||
|
|
||||||
|
if (this.returnRawResults) {
|
||||||
|
// Use direct platform service methods for raw, unparsed results
|
||||||
|
if (isSelect) {
|
||||||
|
this.sqlResult = await this.$dbQuery(this.sqlQuery);
|
||||||
|
} else {
|
||||||
|
this.sqlResult = await this.$dbExec(this.sqlQuery);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Use methods that normalize the result objects
|
||||||
if (isSelect) {
|
if (isSelect) {
|
||||||
this.sqlResult = await this.$query(this.sqlQuery);
|
this.sqlResult = await this.$query(this.sqlQuery);
|
||||||
} else {
|
} else {
|
||||||
this.sqlResult = await this.$exec(this.sqlQuery);
|
this.sqlResult = await this.$exec(this.sqlQuery);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logger.log("Test SQL Result:", this.sqlResult);
|
logger.log("Test SQL Result:", this.sqlResult);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error("Test SQL Error:", error);
|
logger.error("Test SQL Error:", error);
|
||||||
|
|||||||
Reference in New Issue
Block a user