You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote this as a comment to #1032 and immediately realized it should be its own issue.
I'd like to add to this proposal. As far as I currently understand, the plan is to:
start indexing null values
ignore rows that return an "undefined" type using r.absent() or the existing r.literal()
I'd like to also reconsider the behavior of an r.error() (or an implicit error, like operating on the wrong type or not specifying a default) when returned by an index function. I'd propose that a write operation fail if any index returns an error. Likewise, I would propose that creating an index should fail if any documents return such an error.
This would ensure our indices are expecting the correct document structures, and aren't silently missing documents that we would expect to have indexed. This would also have the effect of validating every document in the table.
To ensure backwards-compatibility and ease the process of schema migrations, indexCreate could receive a boolean option of strict to enable this behavior.
Piggy-backing on the same logic, rethinkdb could introduce the concept of "validators" which would function similarly to "strict" indices, but wouldn't actually create the b-trees. This could essentially accomplish #5494, #5879, and #4210, as any json-schema or Joi schema could be compiled into a rql expression and stored as a "validator" expression in the database.
I like the idea, and I think it can be done with a bit of refactoring in our code.
I think we should keep our current behavior as the default (to stay with the philosophy of a schemaless DB), but allow strict index behavior to be enabled via an option as you say.
I think validators are a bit separate, as they aren't really related to indexes per se. (also note that #5813 which is going to ship with 2.4 allows you to implement validators)
@danielmewes thanks for the reply! I totally agree about keeping the current behavior as default, and about my "validators" extrapolation already being covered by #5813 – which I had somehow totally missed! What an awesome proposal!
Activity
danielmewes commentedon Jul 19, 2016
I like the idea, and I think it can be done with a bit of refactoring in our code.
I think we should keep our current behavior as the default (to stay with the philosophy of a schemaless DB), but allow strict index behavior to be enabled via an option as you say.
I think validators are a bit separate, as they aren't really related to indexes per se. (also note that #5813 which is going to ship with 2.4 allows you to implement validators)
mike-marcacci commentedon Jul 19, 2016
@danielmewes thanks for the reply! I totally agree about keeping the current behavior as default, and about my "validators" extrapolation already being covered by #5813 – which I had somehow totally missed! What an awesome proposal!