vlcn-io / cr-sqlite

Convergent, Replicated SQLite. Multi-writer and CRDT support for SQLite
https://vlcn.io
MIT License
2.61k stars 69 forks source link

Missing `seq` of `0` in some cases (maybe just `INSERT OR REPLACE INTO`) #431

Open jeromegn opened 1 month ago

jeromegn commented 1 month ago

Reproduction:

sqlite> create table foo (id int not null primary key, text text, text2 text, num int, num2 int);
sqlite> select crsql_as_crr('foo');
OK
sqlite> insert into foo values (1, 'foo', 'bar', 2, 3);
sqlite> .mode col
sqlite> select * from foo__crsql_clock;
key  col_name  col_version  db_version  site_id  seq
---  --------  -----------  ----------  -------  ---
1    num       1            1           0        2
1    num2      1            1           0        3
1    text      1            1           0        0
1    text2     1            1           0        1
sqlite> insert or replace into foo values (1, 'foo2', 'bar2', 4, 5);
sqlite> select * from foo__crsql_clock;
key  col_name  col_version  db_version  site_id  seq
---  --------  -----------  ----------  -------  ---
1    num       2            2           0        3
1    num2      2            2           0        4
1    text      2            2           0        1
1    text2     2            2           0        2

db_version 2 does not have a seq with a value of 0.