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-467 Decimal type precision and scale not checked by SchemaUtils #2192

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

bog-walk
Copy link
Member

@bog-walk bog-walk commented Aug 7, 2024

Description

Summary of the change:
Defining the same column of type decimal(), binary(), varchar(), or char() but with a different size (precision) or scale (for decimal only) now correctly triggers an ALTER statement when SchemaUtils.createMissingTablesAndColumns is used.

Detailed description:

  • Why:
    Currently, if the existing database table has a column of type DECIMAL(?,?), VARCHAR(?), VARBINARY(?), or CHAR(?) and the Exposed table object defines the same column type but with a different size, the SchemaUtils functions will not generate any ALTER statements to fix the inconsistency.

  • What:
    SchemaUtils.createMissingTablesAndColumns now compares existing- and defined- column size (and scale, if applicable to type) when inspecting the ColumnDiff.

  • How:

    • Extracted column metadata now includes DECIMAL_DIGITS label for scale (only non-null for decimal types).
    • Extracted column metadata COLUMN_SIZE is now used as part of the ColumnDiff comparison

Type of Change

Please mark the relevant options with an "X":

  • Bug fix

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

Related Issues

EXPOSED-467

@bog-walk bog-walk requested review from e5l and joc-a August 7, 2024 00:06
Copy link
Member

@e5l e5l left a comment

Choose a reason for hiding this comment

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

lgtm

…maUtils

Any difference column type that includes a user-defined column size (precision)
or scale in the SQL type is not detected as a ColumnDiff when SchemaUtils functions
are used.

Column metadata for the fractional digits (scale) is now also read and use with
the existing column size to determine if an alter statement should be generated.
@bog-walk bog-walk force-pushed the bog-walk/fix-schema-utils-column-type branch from 75ac5c6 to 37f2cca Compare August 7, 2024 18:44
@bog-walk bog-walk merged commit c75f24b into main Aug 7, 2024
5 checks passed
@bog-walk bog-walk deleted the bog-walk/fix-schema-utils-column-type branch August 7, 2024 20:33
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