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-116 UUID conversion error with upsert in H2 #1823

Merged
merged 1 commit into from
Aug 4, 2023

Commits on Aug 3, 2023

  1. fix: EXPOSED-116 UUID conversion error with upsert in H2

    Using a UUID column as a key constraint in H2's MERGE INTO -- USING statement
    was failing with: org.h2.jdbc.JdbcSQLDataException: Data conversion error converting
    "U&'\\fffdK\\fffdS\\001bJr\\fffdG%\\fffdE\\00100\\fffd' (TESTER: ""ID"" UUID NOT NULL)";
    
    This error occurs because the statement uses a derived column list to merge ON
    (T.ID=S.ID), so the UUID as a ByteArray in T.ID needs to be converted internally
    to compare with the String in S.ID. This error goes away if a regular integer
    id column is used or if the key constraint is swapped with another.
    
    The error also goes away if the identical MERGE statement is placed in an exec()
    directly, indicating that the issue lies with how Exposed sends UUID values to
    the H2 database.
    
    Switching the sent value from a ByteArray to a String allows comparison without
    conversion. A String is still one of 3 acceptable ways to store a UUID in H2 and
    sending a String still results in a UUID being retrieved back from the database.
    bog-walk committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    865d9b8 View commit details
    Browse the repository at this point in the history