useLiveQuery returns wrongly relations queries

I have such piece of code
const queuedIssues = useLiveQuery(
db.query.issueQueue.findMany({
with: {
issue: true,
},
}),
);
const queuedIssues = useLiveQuery(
db.query.issueQueue.findMany({
with: {
issue: true,
},
}),
);
` which return properly results
const queuedIssues = useLiveQuery(
db
.select()
.from(issueQueue)
.leftJoin(issue, eq(issueQueue.issueId, issue.id)),
);
const queuedIssues = useLiveQuery(
db
.select()
.from(issueQueue)
.leftJoin(issue, eq(issueQueue.issueId, issue.id)),
);
above ☝️ return an empty array, and i have no idea why here are my schemas
import { relations } from "drizzle-orm/relations";
import { integer, sqliteTable } from "drizzle-orm/sqlite-core";

import { issue } from "./issue";

export const issueQueue = sqliteTable("issue_queue", {
id: integer("id").primaryKey(),
issueId: integer("issue_id")
.notNull()
.references(() => issue.id, {
onDelete: "cascade",
}),
});

export const issueQueueRelations = relations(issueQueue, ({ one }) => ({
issue: one(issue, {
fields: [issueQueue.issueId],
references: [issue.id],
}),
}));

export type IssueQueue = typeof issueQueue.$inferSelect;
export type InsertIssueQueue = typeof issueQueue.$inferInsert;
import { relations } from "drizzle-orm/relations";
import { integer, sqliteTable } from "drizzle-orm/sqlite-core";

import { issue } from "./issue";

export const issueQueue = sqliteTable("issue_queue", {
id: integer("id").primaryKey(),
issueId: integer("issue_id")
.notNull()
.references(() => issue.id, {
onDelete: "cascade",
}),
});

export const issueQueueRelations = relations(issueQueue, ({ one }) => ({
issue: one(issue, {
fields: [issueQueue.issueId],
references: [issue.id],
}),
}));

export type IssueQueue = typeof issueQueue.$inferSelect;
export type InsertIssueQueue = typeof issueQueue.$inferInsert;
and db definition
import { drizzle } from "drizzle-orm/expo-sqlite";
import { openDatabaseSync } from "expo-sqlite/next";

import { issue } from "./schema/issue";
import { issueQueue } from "./schema/issue-queue";

const expoDb = openDatabaseSync("db.db", {
enableChangeListener: true,
});
const db = drizzle(expoDb, {
schema: {
issue,
issueQueue,
},
});

export { expoDb, db };
import { drizzle } from "drizzle-orm/expo-sqlite";
import { openDatabaseSync } from "expo-sqlite/next";

import { issue } from "./schema/issue";
import { issueQueue } from "./schema/issue-queue";

const expoDb = openDatabaseSync("db.db", {
enableChangeListener: true,
});
const db = drizzle(expoDb, {
schema: {
issue,
issueQueue,
},
});

export { expoDb, db };
do you see anything being wrong here?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server