Repository navigation
[SourceDbToSpanner] Use prepared statements for Spanner to MySQL - #4644
Conversation
Summary of ChangesHello, 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 refactors the Spanner-to-MySQL migration logic to utilize JDBC prepared statements instead of manual string concatenation for DML generation. This change mitigates SQL injection risks by separating SQL structure from record data. The update includes new model classes to manage typed parameters and updates to the DML generation utilities to ensure all column values, including custom transformations and timezone offsets, are correctly bound as parameters. Highlights
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 the 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 counterproductive. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the MySQL DML generation logic to use parameterized queries via PreparedStatement instead of string interpolation, significantly improving security against SQL injection. It introduces PreparedStatementValue and ColumnBinding models to manage typed parameters and updates JdbcDao and DMLGeneratorUtils to support parameter binding. The review feedback highlights two potential issues in MySQLDMLGenerator: a possible NumberFormatException when parsing special float values like NaN or Infinity as BigDecimal, and a potential StringIndexOutOfBoundsException or truncation issue when unconditionally trimming the trailing 'Z' from timestamp strings.
19c9715 to
f6603f8
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4644 +/- ##
============================================
+ Coverage 60.13% 66.55% +6.41%
+ Complexity 8845 4253 -4592
============================================
Files 1123 572 -551
Lines 72848 35075 -37773
Branches 8855 4037 -4818
============================================
- Hits 43808 23343 -20465
+ Misses 26105 10568 -15537
+ Partials 2935 1164 -1771
🚀 New features to boost your workflow:
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request transitions the MySQL DML generation from inline SQL literals to parameterized prepared statements, introducing PreparedStatementValue and ColumnBinding to safely bind column values and custom transformation results. The review feedback highlights critical safety improvements: handling potential NullPointerExceptions in DMLGeneratorUtils when custom transformations return null values, and safely checking for a trailing 'Z' before trimming timestamps in MySQLDMLGenerator to prevent StringIndexOutOfBoundsException or data corruption.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the MySQL DML generation process to use parameterized queries instead of SQL literals, enhancing security against SQL injection. It introduces a new ColumnBinding and PreparedStatementValue structure to handle typed parameters, updates MySQLDMLGenerator to build parameterized SQL, and adds a MySQLJdbcDao to manage the binding of these parameters. Additionally, it includes comprehensive updates to existing tests to reflect the new parameterized approach and adds new unit tests for the binding logic.
bharadwaj-aditya
left a comment
There was a problem hiding this comment.
Most comments are about standardizing across jdbc flows
582a1d1 to
e2ee676
Compare
No description provided.