-
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-82 Inaccurate UShort column type mapping
Currently, when attempting to insert a UShort value outside of the range [0, 32767], Exposed truncates the value by calling value.toShort() 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 2-byte `SMALLINT`, which accepts the range [-32768, 32767]. Change the default mapping to the next higher-up integer data type INT (technically a 4-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. Oracle INT is an alias for NUMBER(38), so this has been overriden to a reduced type NUMBER(6).
- Loading branch information
Showing
5 changed files
with
89 additions
and
31 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