Skip to content

Generated SQL from createCustomSqlitePersister nulls out other columns #187

@LucDeCaf

Description

@LucDeCaf

Describe the bug

When using store.setCell() on an existing cell, the expected behaviour is that the cell will have its value changed and the rest of the row remains unchanged. However, when using a custom SQLite persister with orReplace=1 set, the generated SQL will look as such:

INSERT OR REPLACE "table_name" ("_id","col_to_change") VALUES (?,?);

The issue with this SQL is that every other column in the updated row will be set to NULL, which is probably not expected or desired behaviour.

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

  1. Create a tabular store with some data
  2. Create a SQLite persister that uses orReplace=1 (I used PowerSync)
  3. Use setCell to update a single cell in the store
  4. Generated SQL will null out all fields except replaced field and PK

Expected behavior

The expected behaviour is that the cell that is changed will be updated and the remaining cells will not be set to null. The generated SQL could look something like this:

INSERT OR REPLACE "table_name" ("_id","col_to_change","other_col_1","other_col_2","...") VALUES (?,?,?,?,...);

Screenshots or Videos

No response

Platform

  • OS: macOS 14.5
  • Browser: Chrome
  • Version: Tinybase v5.3.1

Additional context

No response

Metadata

Metadata

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