fix: pick a quote the query does not contain - #263
Conversation
Three consecutive double quotes in a query - from a string literal, or a quoted identifier ending in a quote - closed the constant early and left the rest of the module as stray syntax. The file did not parse. The constant and the docstring now choose their delimiter from the text: """ unless the query holds it, ''' otherwise. A query holding both has no block spelling left, so the constant falls back to an escaped one-liner, which carries the SQL exactly and only stops looking like it. The docstring cannot follow: escaping a docstring trips ruff D301 whatever the backslash spells, so it leaves the SQL out and the constant keeps it. Closes #261
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@coderabbitai full-review |
|
✅ Action performedFull review finished. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (10)
📒 Files selected for processing (19)
Included review availability: 4 reviews are currently available. Based on recent review activity, included reviews refill at 5 per hour. 📝 WalkthroughWalkthroughThe change adds delimiter-aware Python literal selection for SQL containing triple quotes or backslashes. Generated query constants select a safe delimiter or use an escaped fallback. Query docstrings select matching delimiters or omit unsupported SQL. Rendering, writer, and SQLite regression tests cover these cases. SQLC configurations update the Python plugin checksums. Merge Risk: ⚪ Minimal · up to The change makes generated SQL constants and docstrings safe for queries containing triple quotes, with fixture and runtime coverage; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment |
Fixes #261.
Three consecutive double quotes in a query - from a string literal, or a quoted identifier ending in a quote - closed the constant early and left the rest of the module as stray syntax. The file did not parse at all.
The constant and the docstring now pick their delimiter from the text:
"""unless the query holds it,'''otherwise. A query holding both has no block spelling left, so the constant falls back to an escaped one-liner - it still carries the SQL exactly, it just stops looking like it. The docstring cannot follow, since escaping one trips ruff D301 whatever the backslash spells, so it leaves the SQL out and the constant keeps it.Fixture in driver_sqlite3 covering both shapes, with runtime assertions on the values that come back. Existing fixtures are untouched: a query without a quote run still gets the plain
""".