-
Notifications
You must be signed in to change notification settings - Fork 695
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: EXPOSED-107 Incorrect mapping for UByte data type
Currently, when attempting to insert a UByte value outside of the range [0, 127], Exposed truncates the value by calling value.toByte() before sending it to the DB, causing overflow. The value is stored successfully as a negative number because all databases (except MySQL and MariaDB) don't support unsigned types natively, which means Exposed is actually mapping to 1-byte TINYINT, which accepts the range [-128, 127]. Note: SQL Server is an exception as that DB represents TINYINT as holding the unsigned range [0, 255]; so SQL Server requires no changes. Change the default mapping to the next higher-up integer data type SMALLINT (technically a 2-byte storage type) and remove the truncation conversions so that an accurate value is sent/received to/from the database. To ensure that the intended behavior cannot be overriden using exec() directly, a check constraint is auto-applied to the column when registered if the database is not MySQL/MariaDB/SQL Server. Oracle TINYINT is an alias for NUMBER(38), so this has been overriden to a reduced type NUMBER(4).
- Loading branch information
Showing
7 changed files
with
108 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters