fix: translate named parameters for PostgreSQL#749
Conversation
Summary of ChangesHello @olavloite, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the handling of SQL query parameters, particularly for PostgreSQL-dialect databases. It introduces the capability to correctly translate named parameters into the PostgreSQL-specific indexed format, which was previously a blocker for using named parameters with this dialect. Furthermore, it improves parameter validation by explicitly erroring on missing named parameter values instead of silently substituting nulls, and relaxes the ordering requirement for PostgreSQL-style parameters. The changes also enforce a single parameter style per statement to maintain clarity and prevent unexpected behavior. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a fix for translating named parameters for PostgreSQL-dialect databases. The changes correctly handle the translation of @name style parameters to PostgreSQL's $n style, fix an issue with out-of-order parameter usage, and ensure that an error is thrown for missing named parameters instead of silently sending a null value. The implementation involves significant updates to the SQL statement parser, including a new parameter translation mechanism and more robust validation of parameter styles. The accompanying tests are comprehensive and cover a wide range of scenarios for both GoogleSQL and PostgreSQL dialects, providing strong confidence in the correctness of the solution. The changes are well-structured and I have no further suggestions for improvement.
1e3f2de to
66420be
Compare
Named parameters in the SQL string were not translated to PostgreSQL-style query parameters before sending these to Spanner. This made it impossible to use named query parameters with PostgreSQL-dialect databases. This change also fixes an issue that PostgreSQL-style query parameters had to be used in order, and an issue that using a wrong value for a named parameter would not cause an error, and instead just silently send a null value for the parameter to Spanner. Fixes #738 Fixes #601 Fixes #730
66420be to
291a415
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a significant and well-implemented fix for handling named parameters in PostgreSQL-dialect databases. The changes correctly translate named parameters to PostgreSQL-style parameters, address issues with parameter ordering, and improve error handling for missing parameters. The logic is complex but appears correct, and it is backed by a comprehensive set of new tests that cover various scenarios and edge cases. The code is clean and the changes are consistent across the affected files. Overall, this is a high-quality contribution that improves the usability and correctness of the Spanner driver for PostgreSQL users.
Named parameters in the SQL string were not translated to PostgreSQL-style query parameters before sending these to Spanner. This made it impossible to use named query parameters with PostgreSQL-dialect databases.
This change also fixes an issue that PostgreSQL-style query parameters had to be used in order, and an issue that using a wrong value for a named parameter would not cause an error, and instead just silently send a null value for the parameter to Spanner.
Fixes #738
Fixes #601
Fixes #730