Skip to content

fix(engine): ignore FROM in SQL string literals and comments (#77) - #79

Merged
aoto-tech merged 2 commits into
aoto-tech:mainfrom
Cid-oe:fix/issue-77-sql-string-comment-literals
Sep 9, 2026
Merged

fix(engine): ignore FROM in SQL string literals and comments (#77)#79
aoto-tech merged 2 commits into
aoto-tech:mainfrom
Cid-oe:fix/issue-77-sql-string-comment-literals

Conversation

@Cid-oe

@Cid-oe Cid-oe commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Resolves #77.

Prevents sqlTableAccesses from treating FROM, JOIN, or other SQL table query verbs found inside single-quoted SQL string literals or SQL comments (/* ... */ and -- ...) as real table references.

Changes

  • Added stripSqlCommentsAndLiterals in packages/engine/src/resource-access.ts to sanitize block comments, line comments, and single-quoted string literals while keeping double-quoted identifiers intact.
  • Sanitized SQL text in sqlTableAccesses before applying the SQL clause regex.
  • Added regression tests in tests/resource-access-coverage.test.mjs verifying that SQL string literals (SELECT 'FROM ghost_table' AS label), block comments (SELECT 1 /* FROM ghost_table */), and line comments (SELECT 1 -- FROM ghost_table) do not generate false table references, while real table references continue to match accurately.

Validation

  • npm run build
  • node --test tests/resource-access-coverage.test.mjs (42/42 tests pass)

@aoto-tech
aoto-tech merged commit e220a4c into aoto-tech:main Sep 9, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: [P2] FROM in SQL string literals and comments is mistaken for a real table reference

2 participants