amazon-dynamodbpartiql

How to escape a single quote in a PartiQL insert statement


Using DynamoDB, I want to insert a record that contains a string with a single quote ('). Not sure how to escape this so it passes validation.

INSERT INTO "MyTable" VALUE {
  'MyAttr': 'some message containing a \' quote'
}

NOTE: escaping as I have above with a \ does not work.


Solution

  • You do so using an additional single quote:

    INSERT INTO "MyTable" VALUE {
      'MyAttr': 'some message containing a '' quote' 
    }