deviceoperator
DTDrizzle Team
•Created by deviceoperator on 10/14/2024 in #help
[SOLVED] "Not enough info to infer relation", many-to-many junction table w/ postgres
This behavior is not consistent? Adding relationName to some one-to-many relations in other definitions breaks the inference, whereas in some it is required. Full explanation in answer here: https://stackoverflow.com/questions/79084596/how-to-avoid-not-enough-information-to-infer-relation-in-drizzle-with-many-to
9 replies
DTDrizzle Team
•Created by deviceoperator on 10/14/2024 in #help
[SOLVED] "Not enough info to infer relation", many-to-many junction table w/ postgres
For any future readers, I finally figured it out. You can have different keys on each side of a many-to-many relation, BUT all other one-to-many relations in same relation MUST have a relation name in their config (even if they are unrelated to the junction table specifically)
9 replies
DTDrizzle Team
•Created by deviceoperator on 10/14/2024 in #help
[SOLVED] "Not enough info to infer relation", many-to-many junction table w/ postgres
I also feel like I've seen tutorials show the option with two different names on each side
9 replies
DTDrizzle Team
•Created by deviceoperator on 10/14/2024 in #help
[SOLVED] "Not enough info to infer relation", many-to-many junction table w/ postgres
Is this intended behavior? Can you not have two different names (with matching relation name config) on either side of a many-to-many relation? So you could do
with { colorSets: true }
instead of with { templateDefinitionsToColorSets: true }
I feel like the first option is more logical/better wording when you see the shape of a returned object from an API9 replies
DTDrizzle Team
•Created by deviceoperator on 10/14/2024 in #help
[SOLVED] "Not enough info to infer relation", many-to-many junction table w/ postgres
I finally got this working sort of but am still perplexed about the behavior.
Originally: relations w/ one side colorSets and other side templateDefinitions, both with the same relation name in the config and both pointing to the junction table
many(templateDefinitionsToColorSets)
Working: relations w/ both sides called the same thing "templateDefinitionsToColorSets" and remove the relation name. If they are both the same and still have a relation name it gives the same error.9 replies
DTDrizzle Team
•Created by Chris Dosé on 10/15/2024 in #help
[solved] useLiveQuery seems to always run the query twice
No worries
6 replies
DTDrizzle Team
•Created by Chris Dosé on 10/15/2024 in #help
[solved] useLiveQuery seems to always run the query twice
Mentioned in the behaviors list below the second code block https://react.dev/reference/react/StrictMode
6 replies
DTDrizzle Team
•Created by Chris Dosé on 10/15/2024 in #help
[solved] useLiveQuery seems to always run the query twice
This may not be it, but just an idea: if you are using react in development mode with strict mode enabled (which is often the default) hooks are run twice / components are rendered twice. You could make a prod build and see if the behavior continues to determine if this is the cause or not. Looks like in expo there is a flag to temporarily disable dev mode
6 replies
DTDrizzle Team
•Created by deviceoperator on 10/14/2024 in #help
[SOLVED] "Not enough info to infer relation", many-to-many junction table w/ postgres
Hello, if anybody is available to give some suggestions I'd appreciate it hugely. Here is my entire schema rather than just the relevant parts, if it may help (https://gist.github.com/Connorelsea/64e72ef5b63776e79e6697e1de8cc791) also I am on the latest drizzle version. I have also tried just using
with: { colorSets: true }
instead of the more nested version in my original post, and I get the same infer relations
error9 replies
DTDrizzle Team
•Created by deviceoperator on 10/14/2024 in #help
[SOLVED] "Not enough info to infer relation", many-to-many junction table w/ postgres
Update: I tried to triple check the schema and go ahead and add relation names on "both sides" of all many-to-many relationships. All fail with the same error, but querying using with on one-to-many relationships works. I also see quite a few tutorials with junction tables/MTM able to query using "with" without relationNames at all. Would be very interested to know when these are required and under what circumstances these are necessary and why so I can understand drizzle a bit more deeply
9 replies
DTDrizzle Team
•Created by deviceoperator on 10/14/2024 in #help
[SOLVED] "Not enough info to infer relation", many-to-many junction table w/ postgres
I also tried adding the relation names to the relations() for the junction table itself, but then you get an error that multiple relations have the same name. Have read a ton of threads on this problem but very few dealing with many-to-many junction tables specifically
9 replies