Non-indexed relationship fields – better defaults and optional config #8676
molomby
started this conversation in
Feature requests
Replies: 1 comment 1 reply
-
Yup, having a similar issue. I want to pass |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently, anywhere a foreign key is stored in the DB, the field is indexed. Ideally, the creation of an index would:
Current Behaviour
Currently, anytime Keystone creates a relationship all foreign keys added to the DB are indexed. In many cases, this makes sense. Certainly, if you have a corresponding relationship field setup on the other list, there's an implication you'll be selecting items from that "side" so a index is probably needed. So, for example this:
Produces...
Which is probably correct.
But if we don't need to retrieve posts according to their author, surely that index is unneeded. Eg, ideally, this would not produce the same DB schema:
A similar situation arrises with many-to-many relationships (which may also only be accessed from one side) but that case is slightly more complex as a unique constraint is needed across both columns to prevent duplicate records. Currently, you'll see a DB schema like this:
Sometimes, that second, non-unique index is redundant.
Solution Thoughts
As above, Keystone can do a better job of defaulting based on what it already knows but I believe it should be possible to override the default using the conventional
isIndexed: true | false | 'unique'
config. Most field types support this option – relationship fields currently do not.Beta Was this translation helpful? Give feedback.
All reactions