Replies: 1 comment 2 replies
-
|
hello @mbrandonw, Yes, updates to column "a" do not trigger observations of column "b". In the case of generated columns, I agree that this is not what the library user is expecting. The reason why is that GRDB performs string comparisons:
We can ask SQLite if a column is generated indeed, thanks to
Let's consider a downside of this technique, though. If the generated column So it is worth looking for another technique. We could keep on expanding struct MySchemaDataSource: DatabaseSchemaSource {
func columnsAffectingGeneratedColumn(_ column: String, inTable table: DatabaseObjectID) -> Set<String>? {
if table.name == "t", column == "b" {
// t.b is generated from a
return ["a"]
} else {
return nil
}
}
}Maybe a mix of both techniques would be the sweetest spot. When observing a generated column
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Right now value observation does not play nicely with generated columns in SQLite. Consider a schema like this:
Then a query like this:
…will not observe changes to the column
asince it is not mentioned in the query directly.This can be verified with the following test (add to
ValueObservationTests):Is it worth updating the behavior of value observation so that whenever a generated column is selected it forces observation of all columns?
Beta Was this translation helpful? Give feedback.
All reactions