Bigint showing incorrect value from db

I have the following schema
export const guild = pgTable('Guild', {
id: bigint('id', { mode: 'bigint' }).primaryKey().notNull(),
name: text('name').notNull(),
main: boolean('main').default(false).notNull(),
});

export const guildPartyConfig = pgTable('GuildPartyConfig', {
id: serial('id').primaryKey().notNull(),
partyChannelId: bigint('partyChannelId', { mode: 'bigint' }),
raidRoleId: bigint('raidRoleId', { mode: 'bigint' }),
partyRoleId: bigint('partyRoleId', { mode: 'bigint' }),
dungeonRoleId: bigint('dungeonRoleId', { mode: 'bigint' }),
receiveBroadcasts: boolean('receiveBroadcasts').default(true),
onDelete: boolean('onDelete').default(true),
guildId: bigint('guildId', { mode: 'bigint' }).references(() => guild.id),
});

export const guildRelations = relations(guild, ({ one }) => ({
partyConfig: one(guildPartyConfig, {
fields: [guild.id],
references: [guildPartyConfig.guildId],
}),
}));
export const guild = pgTable('Guild', {
id: bigint('id', { mode: 'bigint' }).primaryKey().notNull(),
name: text('name').notNull(),
main: boolean('main').default(false).notNull(),
});

export const guildPartyConfig = pgTable('GuildPartyConfig', {
id: serial('id').primaryKey().notNull(),
partyChannelId: bigint('partyChannelId', { mode: 'bigint' }),
raidRoleId: bigint('raidRoleId', { mode: 'bigint' }),
partyRoleId: bigint('partyRoleId', { mode: 'bigint' }),
dungeonRoleId: bigint('dungeonRoleId', { mode: 'bigint' }),
receiveBroadcasts: boolean('receiveBroadcasts').default(true),
onDelete: boolean('onDelete').default(true),
guildId: bigint('guildId', { mode: 'bigint' }).references(() => guild.id),
});

export const guildRelations = relations(guild, ({ one }) => ({
partyConfig: one(guildPartyConfig, {
fields: [guild.id],
references: [guildPartyConfig.guildId],
}),
}));
For some reason with partyChannelId set to 998290192232362024 inside the database. When it is queried with the code below in the prepared statement, the ID is read incorrectly and as a result appears as 998290192232361984 during runtime.
drizzle.query.guild
.findMany({ with: { partyConfig: true } })
.prepare('initalGuilds');
drizzle.query.guild
.findMany({ with: { partyConfig: true } })
.prepare('initalGuilds');
Am I using the query functionality incorrect as when queried directly or without utilizing the query method it gets the correct result during runtime, with the value of 998290192232362024 as expected.
drizzle.query.guildPartyConfig.findMany()

// Either Work Fine
drizzle.select({ id: guild.id, name: guild.name, partyConfig: guildPartyConfig }).from(guild).leftJoin(guildPartyConfig, eq(guild.id, guildPartyConfig.guildId))
drizzle.query.guildPartyConfig.findMany()

// Either Work Fine
drizzle.select({ id: guild.id, name: guild.name, partyConfig: guildPartyConfig }).from(guild).leftJoin(guildPartyConfig, eq(guild.id, guildPartyConfig.guildId))
Again I will ask am I using the query API incorrectly or is this a bug?
2 Replies
T2ThatGuy
T2ThatGuy8mo ago
Coming up on a week, with no response I will just assume its a bug that needs fixing somewhere. Have tried both pg and postgres drivers and same issue exists
MAST
MAST8mo ago
Hmm, might be a good idea to file a github issue. I can't think of any reason why this could happen.