mightyguava/dynamosql

Support INSERT

mightyguava opened this issue · 0 comments

Syntax:

/*
   When inserting documents, the column definition is omitted. The user can provide JSON literals as documents.
 */
INSERT INTO movies
VALUES ('{"title":"hello","year":2938}'),
       ('{"title":"foo","year":2938}');

/*
   When using placeholders, (?) automatically means list of documents. The user may provide a single item or a slice
   of items.
 */
INSERT INTO movies
VALUES (?);

-- NOT SUPPORTED
INSERT INTO movies (title, year)
VALUES ('hello', '2007'),
       ('foo', '2938');

-- NOT SUPPORTED
INSERT INTO movies (title, year)
VALUES (?, ?);

To respect SQL behavior, INSERT will fail if an item already exists. When more than 1 item is inserted, TransactWriteItem will be used to transactionally write the entire list of items. BatchWriteItem will never be used because it can insert only some of the items.