rbravo
rbravo
Explore posts from servers
DTDrizzle Team
Created by nk on 1/19/2024 in #help
Recursive category/subcategories, can't infer relation
Yeah, this is exactly my use case where I'm also seeing the error. And btw, this case that you described: "you could easily delete a category and have a null subcategory, since you can't put a notNull on it". Could be fixed with onDelete: 'cascade'. https://www.answeroverflow.com/m/1110915016959475743 IMO your initial relation is ok and should work without "workarounds"
6 replies
DTDrizzle Team
Created by rbravo on 1/19/2024 in #help
Error: There is not enough information to infer relation
(And please correct me if I'm wrong, maybe I'm missing something)
38 replies
DTDrizzle Team
Created by rbravo on 1/19/2024 in #help
Error: There is not enough information to infer relation
Maybe what @nk suggested is a way to do this, but ideallly I wouldn't need to change the current schema, which is something like this:
model Message {
reactions Reaction[]
replies Message[]
replyTo Message?
model Message {
reactions Reaction[]
replies Message[]
replyTo Message?
38 replies
DTDrizzle Team
Created by rbravo on 1/19/2024 in #help
Error: There is not enough information to infer relation
It's a bit different, you're going from users > follows & follows and follows > users & users. In my case: I'm going from messages > messages & messages
export const messagesRelations = relations(messages, ({ one, many }) => ({
replies: many(messages, { relationName: "messageReplies" }),
replyTo: one(messages, {
fields: [messages.replyToId],
references: [messages.id],
relationName: "messageReplyTo",
}),
export const messagesRelations = relations(messages, ({ one, many }) => ({
replies: many(messages, { relationName: "messageReplies" }),
replyTo: one(messages, {
fields: [messages.replyToId],
references: [messages.id],
relationName: "messageReplyTo",
}),
38 replies
DTDrizzle Team
Created by rbravo on 1/19/2024 in #help
Error: There is not enough information to infer relation
38 replies
DTDrizzle Team
Created by rbravo on 1/19/2024 in #help
Error: There is not enough information to infer relation
Yeah, that's the problem!
38 replies
DTDrizzle Team
Created by rbravo on 1/19/2024 in #help
Error: There is not enough information to infer relation
Thank you for sending this @nk! But my case here is that I'm declaring the relations of the table "A", and I stablish 2 relations to itselft
38 replies
DTDrizzle Team
Created by rbravo on 1/19/2024 in #help
Error: There is not enough information to infer relation
This is what I'm using and I'm still seeing the error when starting the Drizzle Studio:
export const messagesRelations = relations(messages, ({ one, many }) => ({
reactions: many(reactions),
replies: many(messages, { relationName: "messageReplies" }),
replyTo: one(messages, {
fields: [messages.replyToId],
references: [messages.id],
relationName: "messageReplyTo",
}),
conversation: one(conversations, {
fields: [messages.conversationId],
references: [conversations.id],
}),
user: one(users, {
fields: [messages.userId],
references: [users.id],
}),
}));
export const messagesRelations = relations(messages, ({ one, many }) => ({
reactions: many(reactions),
replies: many(messages, { relationName: "messageReplies" }),
replyTo: one(messages, {
fields: [messages.replyToId],
references: [messages.id],
relationName: "messageReplyTo",
}),
conversation: one(conversations, {
fields: [messages.conversationId],
references: [conversations.id],
}),
user: one(users, {
fields: [messages.userId],
references: [users.id],
}),
}));
38 replies
DTDrizzle Team
Created by rbravo on 1/19/2024 in #help
Error: There is not enough information to infer relation
The thing is that here, it's all related to the same table, the Message table.
38 replies
DTDrizzle Team
Created by rbravo on 1/19/2024 in #help
Error: There is not enough information to infer relation
replies: many(messages, { relationName: "messageReplies" }),
replyTo: one(messages, {
fields: [messages.replyToId],
references: [messages.id],
relationName: "messageReplyTo",
}),
replies: many(messages, { relationName: "messageReplies" }),
replyTo: one(messages, {
fields: [messages.replyToId],
references: [messages.id],
relationName: "messageReplyTo",
}),
Like this?
38 replies
DTDrizzle Team
Created by rbravo on 1/19/2024 in #help
Error: There is not enough information to infer relation
Wow, that was fast haha In this case, what would be the other "side"? Since it's all "messages" (i.e replies also refers to messages)
38 replies
DTDrizzle Team
Created by rbravo on 1/19/2024 in #help
Error: There is not enough information to infer relation
Here's the relation code:
export const messagesRelations = relations(messages, ({ one, many }) => ({
reactions: many(reactions),
replies: many(messages, { relationName: "messageReplies" }),
replyTo: one(messages, {
fields: [messages.replyToId],
references: [messages.id],
relationName: "messageReplyTo",
}),
conversation: one(conversations, {
fields: [messages.conversationId],
references: [conversations.id],
}),
user: one(users, {
fields: [messages.userId],
references: [users.id],
}),
}));
export const messagesRelations = relations(messages, ({ one, many }) => ({
reactions: many(reactions),
replies: many(messages, { relationName: "messageReplies" }),
replyTo: one(messages, {
fields: [messages.replyToId],
references: [messages.id],
relationName: "messageReplyTo",
}),
conversation: one(conversations, {
fields: [messages.conversationId],
references: [conversations.id],
}),
user: one(users, {
fields: [messages.userId],
references: [users.id],
}),
}));
38 replies