-
Notifications
You must be signed in to change notification settings - Fork 21
fix: enhance data type handling in MongoConnector and add support for… #438
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
Conversation
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.
Pull request overview
This PR enhances data type handling in the MongoConnector by adding support for BSON Double type for floating-point numbers and improving type conversion logic. The changes ensure proper storage and retrieval of numeric values in MongoDB.
Key Changes
- Added BSON Double type import and usage for FLOAT type fields
- Enhanced setFieldValue method with better validation and type handling for INTEGER, FLOAT, DATE, DATETIME, BOOLEAN, and DECIMAL types
- Updated type detection priority to handle DECIMAL before other numeric types
- Fixed getMinMaxValues to correctly access column.name property
- Improved createRecordOriginalValues and updateRecordOriginalValues to properly apply type conversions using setFieldValue
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
adminforth/dataConnectors/mongo.ts
Outdated
|
|
||
| if (field.type === AdminForthDataTypes.INTEGER) { | ||
| if (value === "" || value === null) return null; | ||
| const n = typeof value === "number" ? value : Number(String(value).replace(",", ".")); |
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.
@NoOne7135 lets remove replace
adminforth/dataConnectors/mongo.ts
Outdated
|
|
||
| if (field.type === AdminForthDataTypes.FLOAT) { | ||
| if (value === "" || value === null) return null; | ||
| const n = typeof value === "number" ? value : Number(String(value).replace(",", ".")); |
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.
@NoOne7135 lets throw new error with clear message, even if typeof is not number at all '1.0' -> or '1' -> ok, 'afsa' -> throw
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.
and do it on top level in common databaseConnector
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.
adminforth/dataConnectors/mongo.ts
Outdated
| newRecord[colName] = record[colName]; | ||
| for (const [key, raw] of Object.entries(record)) { | ||
| const col = colsByName.get(key); | ||
| newRecord[key] = col ? this.setFieldValue(col, raw) : raw; |
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.
…dation in AdminForthBaseConnector and update MongoConnector to utilize it
…y column type check in MongoConnector
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.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…es across data connectors and components
… normalizeMongoValue methods


… Double type