mirror of
https://github.com/h-sphere/sql-seal.git
synced 2026-07-22 10:10:28 +00:00
Merge pull request #23 from h-sphere/fix/cte-names-registering-signals
fix: fixing issue with CTE names registering signals
This commit is contained in:
commit
6b14843516
6 changed files with 23 additions and 6 deletions
|
|
@ -1,3 +1,6 @@
|
|||
# 0.12.2
|
||||
fix: Fixed issue with CTE table names being incorrectly processed causing error
|
||||
|
||||
# 0.12.1
|
||||
fix: Fixed issue with the library on mobile - now it should load properly.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "sqlseal",
|
||||
"name": "SQLSeal",
|
||||
"version": "0.12.1",
|
||||
"version": "0.12.2",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Use SQL in your notes to query your vault files and CSV content.",
|
||||
"author": "hypersphere",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "sqlseal",
|
||||
"version": "0.12.1",
|
||||
"version": "0.12.2",
|
||||
"description": "A plugin for Obsidian that allows you to run SQL queries on your notes.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { App, MarkdownPostProcessorContext } from "obsidian"
|
|||
import { displayError, displayNotice } from "./ui"
|
||||
import { resolveFrontmatter } from "./frontmatter"
|
||||
import { hashString } from "./hash"
|
||||
import { prefixedIfNotGlobal, updateTables } from "./sqlReparseTables"
|
||||
import { extractCtes, prefixedIfNotGlobal, updateTables } from "./sqlReparseTables"
|
||||
import { SqlSealDatabase } from "./database"
|
||||
import { Logger } from "./logger"
|
||||
import { TablesManager } from "./dataLoader/collections/tablesManager"
|
||||
|
|
@ -12,7 +12,7 @@ import { RendererRegistry, RenderReturn } from "./rendererRegistry"
|
|||
|
||||
export class SqlSealCodeblockHandler {
|
||||
get globalTables() {
|
||||
return ['files', 'tags', 'tasks'] // Make this come from SealFileSync and plugins.
|
||||
return ['files', 'tags', 'tasks', 'xyz'] // Make this come from SealFileSync and plugins.
|
||||
}
|
||||
constructor(
|
||||
private readonly app: App,
|
||||
|
|
@ -88,7 +88,9 @@ export class SqlSealCodeblockHandler {
|
|||
try {
|
||||
if (results.queryPart) {
|
||||
const { statement, tables } = updateTables(results.queryPart!, [...this.globalTables], prefix)
|
||||
this.setupQuerySignals({ statement, tables }, renderer!, ctx, el)
|
||||
const ctes = extractCtes(results.queryPart)
|
||||
const tablesWithoutCtes = tables.filter(t => !ctes.includes(t))
|
||||
this.setupQuerySignals({ statement, tables: tablesWithoutCtes }, renderer!, ctx, el)
|
||||
}
|
||||
} catch (e) {
|
||||
renderer!.error(e.toString())
|
||||
|
|
|
|||
|
|
@ -77,4 +77,15 @@ export const updateTables = (selectStatement: string, globalTables: string[], pr
|
|||
} else {
|
||||
throw new Error('Invalid Statement. Only single SELECTs are accepted at the moment.')
|
||||
}
|
||||
}
|
||||
|
||||
export const extractCtes = (selectStatement: string) => {
|
||||
const parser = new Parser()
|
||||
const { ast } = parser.parse(selectStatement)
|
||||
if (!Array.isArray(ast) && ast.type === 'select') {
|
||||
if (ast.with) {
|
||||
return ast.with.map(w => w.name.value)
|
||||
}
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
|
@ -15,5 +15,6 @@
|
|||
"0.10.1": "0.15.0",
|
||||
"0.11.0": "0.15.0",
|
||||
"0.12.0": "0.15.0",
|
||||
"0.12.1": "0.15.0"
|
||||
"0.12.1": "0.15.0",
|
||||
"0.12.2": "0.15.0"
|
||||
}
|
||||
Loading…
Reference in a new issue