Repository navigation
fix: close correctness gaps in Rules, SQL scanners and sqb query - #848
Merged
Merged
Conversation
SQBRSQL023 only recognised aliases introduced by AS, so an unused implicit alias such as `FROM orders o` went unreported. Implicit aliases after relation names, subqueries and table functions now follow the same unused-alias contract. Refs CHI-376
SQBRDECLARATION102 only inspected binary comparison operators, so literal BETWEEN bounds and numeric IN/NOT IN members bypassed the rule. Range and value-list predicates are now evaluated like the equivalent comparisons, and value lists point to a list or set constant used through IN @const(...). Refs CHI-397
The compiler's reference, macro, declaration, interpolation and resolution scanners only recognised quote characters, so an apostrophe inside a $$...$$ literal opened a phantom quote and compilation failed with an unclosed quoted string, while reference-shaped text inside dollar quotes could be extracted as a dependency. The Python scanners and the native compiler scan policy now skip $$ and $tag$ literals like single-quoted strings. Refs CHI-375
A warehouse error from sqb query escaped the CLI error projection and printed a Python traceback. Query execution failures now raise a coded CLI error, error[C108], carrying the warehouse message on stderr with exit code 2 and no stdout output. Refs CHI-343
SQBRCONTRACT105 needs inferred type proofs, which only exist when SQL analysis runs, so compile --no-sql-analysis (or sql_analysis = false) reported it for essentially every typed contract column. Type-proof rules are now not evaluated when the run or project disables SQL analysis, and compile prints one note naming the skipped rules on stderr before the final summary. With analysis enabled, behaviour is unchanged. Refs CHI-353
… findings SQBRSQL023 treated an unaliased relation's join or relation modifier, such as POSITIONAL in `FROM orders POSITIONAL JOIN customers`, as an implicit alias and offered to delete it. It also counted an alias as used only when followed by a dot, so whole-row uses such as `to_json(o)`, `SELECT o` or `WHERE o IS NOT NULL` were reported and their deletion broke binding. Modifier and clause keywords are no longer implicit-alias candidates, and any bare identifier reference to the alias counts as a use for both implicit and AS aliases. Refs CHI-376
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Five small correctness gaps found while using SQLBuild on larger projects: two Rules missed common SQL forms, the compiler failed on valid dollar-quoted literals,
sqb queryprinted Python tracebacks, and--no-sql-analysisburied real diagnostics under thousands of type-proof findings.Changes
AS. Join modifiers (POSITIONAL,ASOF, ...), clause keywords and whole-row alias uses (row_to_json(o),SELECT o) are never treated as unused, so the fix cannot break a query.[NOT] BETWEENbounds and[NOT] INlists, suggesting a list or set constant for value lists.$$...$$and$tag$...$tag$as opaque literals, so apostrophes,--and__ref(text inside them no longer break compilation or create dependencies.sqb queryreports warehouse errors aserror[C108]with exit code 2 and no partial stdout.Verification
make check-ciandmake test(7,820 passed) locally.