Skip to content

loadData not escaping single quotes correctly #94

@evtilley

Description

@evtilley

When using loadData to import a CSV, the changeset fails if there is a string in the CSV that contains a single quote. This is happening because Liquibase attempts to escape the single quote as '' rather than as \'. For example,

IntVal,StrVal
1,"This won't work"
Unexpected error running Liquibase: Migration failed for change set changelog.yaml::load-data-Test::evtilley:
     Reason: liquibase.exception.DatabaseException: INVALID_ARGUMENT: com.google.api.gax.rpc.InvalidArgumentException: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Syntax error: Expected ")" or "," but got string literal 't work' [at 1:56]
INSERT INTO Test (IntVal, StrVal) VALUES (1, 'This won''t work')
                                                       ^ [Failed SQL: (3) INSERT INTO Test (IntVal, StrVal) VALUES (1, 'This won''t work')]

I've attached a full reproduction below.

liquibase-spanner-escaping-issue.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions