Use rowid instead id, allowing custom primary keys #117
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.