Skip to content
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

fix!: EXPOSED-536 Short column allows out-of-range values #2231

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

joc-a
Copy link
Collaborator

@joc-a joc-a commented Sep 9, 2024

Description

  • What:
    fix: EXPOSED-536 Short column allows out-of-range values
  • Why:
    For SQLite and Oracle, inserting an out-of-range value using raw SQL with exec would work even though it shouldn't.
  • How:
    Short stores values between -32768 and 32767. For Oracle and H2 Oracle, Short data type was changed from SMALLINT to NUMBER(5) because SMALLINT is stored as NUMBER(38) in the database and takes up unnecessary storage. Another reason for this change is that this is a precursor to the column type change detection feature for migration, where it will be useful to have the column type be more specific than NUMBER(38).
    A check constraint was added (that applies only to SQLite, Oracle and H2_Oracle) to ensure that no out-of-range values are stored.

Type of Change

Please mark the relevant options with an "X":

  • Bug fix
  • New feature
  • Documentation update

Updates/remove existing public API methods:

  • Is breaking change

Affected databases:

  • MariaDB
  • Mysql5
  • Mysql8
  • Oracle
  • Postgres
  • SqlServer
  • H2
  • SQLite

Checklist

  • Unit tests are in place
  • The build is green (including the Detekt check)
  • All public methods affected by my PR has up to date API docs
  • Documentation for my change is up to date

Related Issues

@joc-a joc-a marked this pull request as ready for review September 9, 2024 17:22
@joc-a joc-a requested a review from bog-walk September 9, 2024 17:22
Copy link
Member

@bog-walk bog-walk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments. Please consider adding breaking changes (re the new type and new constraint) for dialect users that may be expecting the old DDL and/or may be using plain SQL without restriction.

For Oracle, Short data type was changed from SMALLINT to NUMBER(5) because SMALLINT is stored as NUMBER(38) in the database and takes up unnecessary storage. Another reason is that this is a precursor to the column type change detection feature for migration, where it will be useful to have the column type be more specific than NUMBER(38).

A check constraint was added to ensure that no out-of-range values are stored.
@joc-a joc-a changed the title fix: EXPOSED-536 Short column allows out-of-range values fix!: EXPOSED-536 Short column allows out-of-range values Sep 10, 2024
@joc-a joc-a merged commit cf8c71a into main Sep 10, 2024
5 checks passed
@joc-a joc-a deleted the joc/exposed-536 branch September 10, 2024 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants