Repository navigation
fix(v18): throw SqlError from fingerprint, normalize, and scan #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 SQL error offsets drift after emoji
When an SQL error follows an emoji,
callDetailedreports an offset too early for the JavaScript query string. PostgreSQL counts the emoji once, but formatSqlError uses the position as a JavaScript string index.Devin left this for you to triage: The new methods intentionally match parseSync’s PostgreSQL character offset: for SELECT '😀', 'abc all four report 12, while JavaScript substring indexing locates the quote at 13. Fix the existing formatSqlError indexing separately so this PR preserves the parse contract and stays limited to typed errors.
(Refers to this code)
Learn more
PostgreSQL reports the cursor as a one-based count of Unicode characters. JavaScript indexes strings by UTF-16 code units, so a supplementary character such as an emoji occupies two index positions instead of one. The new structured-error path only changes the base from one to zero. The built-in formatSqlError then uses that offset to position the caret and to truncate the query.
Example: In
SELECT '😀', 'abc, PostgreSQL reports position 13 for the unclosed quote. Subtracting one yields 12, which indexes the preceding space in JavaScript; the quote is at index 13.Recommended fix: In the full template, convert positive PostgreSQL cursor positions to UTF-16 offsets by advancing through the original query by Unicode code point and accumulating each point’s code-unit width. Regenerate the v18 source and add a supplementary-character regression case for the three operations and their sync variants.
Was this helpful? React with 👍 or 👎 to provide feedback.