fix(import): TAMOC-400: Use model field metadata for numeric change detection in importer#9264
fix(import): TAMOC-400: Use model field metadata for numeric change detection in importer#9264dannash100 wants to merge 3 commits intomainfrom
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 resolves an issue in the import functionality where decimal column values were not being compared correctly, leading to potential inaccuracies when updating existing records. The changes introduce specific handling for decimal types to ensure that numeric comparisons are performed accurately, preventing unintended skips or updates. New tests have been added to validate this corrected behavior. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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 aims to fix an issue with comparing decimal values during data import. It introduces a specific check for when a database value (as a string) is compared against an imported numeric value. The PR also adds tests to verify that updates and skips on re-import work as expected for decimal values.
My review found a critical issue in the implementation of the comparison logic that could lead to missed updates in certain scenarios. I've provided a detailed comment with a suggested fix. The new tests are good but do not cover the edge case where the bug occurs.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
|
🦸 Review Hero Summary |
|
Android builds 📱
|
🍹
|
chris-bes
left a comment
There was a problem hiding this comment.
LGTM! Sorry about 1 tiny suggestion, but I think it's going to make it a lot more robust
| SurveyScreenComponent: ['componentIndex'], | ||
| }; | ||
|
|
||
| const NUMERIC_FIELD_TYPES = new Set(['INTEGER', 'BIGINT', 'FLOAT', 'REAL', 'DOUBLE', 'DECIMAL']); |
There was a problem hiding this comment.
Hmm I believe this is not a full list, we do have more such as 'TINYINT', 'SMALLINT', 'MEDIUMINT'
I think instead of hardcoding the numeric field types like this, there is a more robust way to check if it's a number by checking if it is an instance of DataTypes.NUMBER, as all the numeric types inherit from the top parent class NUMBER
import { DataTypes } from 'sequelize';
// Check if a model attribute's type is numeric
return attrType instanceof DataTypes.NUMBER;
There was a problem hiding this comment.
Oh thats a very good call 🙏
Use instanceof DataTypes.NUMBER instead of typeof to identify numeric fields, so DECIMAL values (returned as strings by Sequelize) are correctly compared during import change detection. Made-with: Cursor
179277a to
287a895
Compare
Changes
FSM go live finding, I will hotfix to 2.49+
DECIMAL columns (like coverageValue and price) are returned as strings by PostgreSQL/Sequelize, causing checkForChanges to miss updates when comparing against number values from the import. Refactored to use rawAttributes field type metadata instead of runtime typeof checks, so all numeric column types (INTEGER, BIGINT, FLOAT, REAL, DOUBLE, DECIMAL) are consistently compared as numbers regardless of their JavaScript representation.
Deploys
Tests
Review Hero
Remember to...