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.
There used to be only one column type:
Column
.Column
had an undocumented (little) privilege: it could enhance observation of fetch requests that target specific row ids, such asPlayer.filter(Column("id") == 1)
.Observation tools like RxGRDB notify of changes in the results of such request if and only if the player with id 1 is modified or deleted.
Conversely, raw sql requests like
SELECT * FROM players WHERE id = 1
, or requests built from custom column types, likePlayer.filter(CustomColumn("id") == 1)
(ping @freak4pc) would not profit for this precise observation: any change in any row would trigger a change notification.This PR does not bring precise observation to raw SQL requests. But it does for custom column types (if they adopt the new
ColumnExpression
protocol).The recommended way to declare columns attached to a record type was a namespace enum and static declarations:
This works, but it is not very sexy.
The new
ColumnExpression
protocol fixes both problems:Customized column types now just have to adopt
ColumnExpression
in order to trigger precise request observation.And it is easier to define record columns:
Codable records can also turn their coding keys into columns, if they want: