-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat(orm): Support unsigned integer types in MySQL ORM #2429
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
Fix uint32_t values > INT32_MAX being converted to negative numbers. - Add MySqlUTiny/UShort/ULong/ULongLong enum types - Replace getMysqlTypeBySize() with getMysqlType<T>() template - Update MysqlConnection to handle unsigned type casting - Maintain backward compatibility
Fix compilation error where getMysqlType<bool> was not handled, causing static_assert failures when Json::Value::asBool() is used.
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 adds support for unsigned integer types in the MySQL ORM to fix an issue where uint32_t values greater than INT32_MAX were being incorrectly converted to negative numbers. The implementation introduces new enum types for unsigned integers and replaces the size-based type detection with a more precise template-based approach.
Key Changes:
- Added four new MySQL field type enums (MySqlUTiny, MySqlUShort, MySqlULong, MySqlULongLong) for unsigned integers
- Replaced
getMysqlTypeBySize()with template functiongetMysqlType<T>()that uses type traits to distinguish between signed and unsigned types - Updated MysqlConnection to handle the new unsigned type cases with appropriate casting
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| orm_lib/inc/drogon/orm/DbTypes.h | Adds four new enum values for unsigned integer types (UTiny, UShort, ULong, ULongLong) |
| orm_lib/inc/drogon/orm/SqlBinder.h | Introduces template function getMysqlType<T>() using type traits to precisely determine MySQL types, including unsigned variants |
| orm_lib/src/mysql_impl/MysqlConnection.cc | Adds case handlers for unsigned integer types with proper casting to uint8_t, uint16_t, uint32_t, and uint64_t |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| MySqlUTiny, | ||
| MySqlUShort, | ||
| MySqlULong, | ||
| MySqlULongLong, |
Copilot
AI
Dec 25, 2025
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.
The unsigned integer enum values are added at the end of the enum, after MySqlString and DrogonDefaultValue. While this maintains backward compatibility with existing enum values, it creates a disorganized structure where related types (signed/unsigned pairs) are separated.
Consider whether the enum ordering could cause confusion or maintenance issues. If the enum values are persisted or used in serialization, the current approach is correct. Otherwise, consider documenting why unsigned types are placed at the end rather than grouped with their signed counterparts.
Co-authored-by: Copilot <[email protected]>
Fix uint32_t values > INT32_MAX being converted to negative numbers.