For simplicity, we recommend using only lower case identifiers for all table and column names used in PowerSync. If you need to use a different case, continue reading.
Like Postgres, PowerSync converts all table and column names to lower-case by default in sync rule queries. To preserve the case, surround the name with double quotes, for example:
SELECT "ID" as id, "Description", "ListID" FROM "TODOs" WHERE "TODOs"."ListID" = bucket.list_id
SELECT *, the original case is preserved for the returned columns.
On the client side, the case of table and column names in the schema must match the case produced by sync rules exactly. For the above example, use the following in Dart:
SQLite itself is case-insensitive. When querying and modifying the data on the client, any case may be used. For example, the above table may be queried using
SELECT description FROM todos WHERE listid = ?.
Operations (PUT/PATCH/DELETE) are stored in the upload queue using the case as defined in the schema above for table and column names, not the case used in queries.
As another example, in this sync rule query:
SELECT ID, todo_description as Description FROM todo_items as TODOs
Each identifier in the example is unquoted and converted to lower case. That means the client-side schema would be: