Repository navigation
fix: handle sql.Null* types correctly in database wrapper generator - #744
Conversation
Summary of ChangesHello @kalbasit, 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 rectifies a critical type casting error within the 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
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Code Review
This pull request correctly fixes a bug in the database wrapper generator that caused it to produce syntactically incorrect code for sql.Null* types. By introducing an isStructType helper and adjusting the code generation logic to perform direct assignment for these struct types, the fix prevents invalid casting syntax and correctly relies on the Go compiler to handle type checking. The changes are well-targeted and effective. I have one suggestion to slightly refactor the conditional logic for improved conciseness.
fa9de50 to
efed176
Compare
The gen-db-wrappers tool was attempting to cast sql.NullInt64 and other sql.Null* types using invalid function call syntax like sql.NullInt64(value). This doesn't work because these are struct types, not types that can be cast with simple function syntax. Added an isStructType() helper function to detect sql.Null* types and modified the type conversion logic in joinParamsCall() to avoid attempting function call syntax casting for struct types. When both source and target types are struct types, the value is now passed directly without casting. This fixes the TotalChunks field generation issue where it was being incorrectly cast in CreateNarFile and UpdateNarFileTotalChunks functions across all database backends (SQLite, PostgreSQL, MySQL).
efed176 to
56ab810
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #744 +/- ##
=======================================
Coverage 85.41% 85.41%
=======================================
Files 2 2
Lines 480 480
=======================================
Hits 410 410
Misses 65 65
Partials 5 5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|

The gen-db-wrappers tool was attempting to cast sql.NullInt64 and other
sql.Null* types using invalid function call syntax like sql.NullInt64(value).
This doesn't work because these are struct types, not types that can be cast
with simple function syntax.
Added an isStructType() helper function to detect sql.Null* types and modified
the type conversion logic in joinParamsCall() to avoid attempting function call
syntax casting for struct types. When both source and target types are struct
types, the value is now passed directly without casting.
This fixes the TotalChunks field generation issue where it was being incorrectly
cast in CreateNarFile and UpdateNarFileTotalChunks functions across all database
backends (SQLite, PostgreSQL, MySQL).