cloudspannerecosystem/liquibase-spanner

loadData not escaping single quotes correctly

evtilley opened this issue · 0 comments

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