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-83 createMissingTablesAndColumns not detecting missing PK #1797

Merged
merged 4 commits into from
Jul 26, 2023

Commits on Jul 26, 2023

  1. fix: EXPOSED-83 createMissingTablesAndColumns not detecting missing PK

    createMissingTablesAndColumns does not create a new primary key (PK) if the latter
    is defined by columns that already exist in the table.
    
    A new function, existingPrimaryKeys(), has been added to retrieve relevant metadata,
    which is used as a reference in addMissingColumnsStatements() to determine if the
    current table's PK should be added to an existing column(s).
    
    While this fixes the original issue of the PK not being appropriately detected,
    it raises further issues:
    - Attempting to modify an existing PK raises an error about multiple PKs because
    the function is currently not configured to drop PKs. This logic has been included
    in the fix.
    - The function is currently not set up to drop any columns or indices in the event
    of an existing conflict. Drop functionality is actually contradicted by some existing
    tests, which show the expected behavior of only performing changes that add to
    an existing table.
    - The user test assumes that the PK name will never change because that would be
    the outcome using the default naming system in PostgreSQL if CREATE TABLE was called
    for each new table, and because a custom name is not provided to any test table.
    However, if a PK is correctly dropped because a composite PK is detected, e.g.,
    that uses a new non-id column, this triggers an ALTER TABLE ddl that will be
    configured to use the format ADD CONSTRAINT pk_tester (with the default Exposed
    name). While the fix for this is small (in Table.primaryKeyConstraint()), it breaks
    multiple existing tests and needs to be properly assessed.
    - Multiple vendor-specific syntax errors appear in Column.createStatement() (used
    in ALTER TABLE column definition). e.g. SQL Server cannot have 2 'ADD' and Oracle
    requires constraint to be split across 2 ALTER statements. These databases have
    been excluded until the syntax is fixed.
    bog-walk committed Jul 26, 2023
    Configuration menu
    Copy the full SHA
    39cc56d View commit details
    Browse the repository at this point in the history
  2. fix: EXPOSED-83 createMissingTablesAndColumns not detecting missing PK

    Add PrimaryKeyMetadata data class as a cleaner return value from
    existingPrimaryKeys().
    
    Refactor unit tests to remove drop functionality expectation.
    
    Rebase from main.
    bog-walk committed Jul 26, 2023
    Configuration menu
    Copy the full SHA
    19c367d View commit details
    Browse the repository at this point in the history
  3. fix: EXPOSED-83 createMissingTablesAndColumns not detecting missing PK

    Fix detekt issues to pass GH action.
    bog-walk committed Jul 26, 2023
    Configuration menu
    Copy the full SHA
    2609e92 View commit details
    Browse the repository at this point in the history
  4. fix: EXPOSED-83 createMissingTablesAndColumns not detecting missing PK

    Update KDocs to match new function parameters.
    bog-walk committed Jul 26, 2023
    Configuration menu
    Copy the full SHA
    d7426da View commit details
    Browse the repository at this point in the history