Closed gabriel-curtino closed 2 months ago
I have looked into rowid stability as per my comment in #112 and it seems rowids are still not guaranteed to remain stable after a vacuum. see the quirks section of the rowid docs. Relying on rowid would mean users need to rebuild the index after any vacuum operation or they might get the wrong results.
I still think it is the right thing to do though, this will expand the support to any rowid table, and we could highlight the potential need to rebuild the index after the vacuum in the documentation
This PR intent is improve
liteseach
making it rely in therowid
instead theid
as it does actually. This will allow to work with custom TEXT primary keys and maybe clear the way for composite keys.I've found that
Knowing this, if we use the
rowid
instead theid
column, it doens't matter what kind of primary key we use.It also adds the possibility of set a custom primary key name, then this kind of setup will work:
Notes:
similar
to work with therowid
, it does an extra query to read therowid
of the object. There is the alternative to "expose" therowid
attribute adding a default scope in the models when includinglitesearch
, but I think too many things can go wrong doing it and one extra query just for runningsimilar
doesn't looks too bad.