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

Fix a bug in the fractional indexing implementation when a column type is specified #330

Closed tantaman closed 10 months ago

tantaman commented 10 months ago

crsql_as_ordered would fail if the table schema specified a type for the column used to order by.

E.g.,

CREATE TABLE test (id, spot TEXT, list TEXT);

Assigning TEXT to spot would cause inserts to spot to be treated as text. This meant out -1 and 1 shorthand for pre-pend and append would fail to compare and write an invalid fractional index. Fix that by casting the ordering column before using it.