Drizzle incorrectly building query with DEFAULT instead of $11 in insertion

Drizzle ORM built this query:
INSERT INTO "domains" (
"name",
"formatted_name",
"root_name",
"tld",
"godaddy_auction_id",
"price",
"bid_count",
"auction_end_time",
"majestic_trust_flow",
"majestic_citation_flow",
"majestic_backlink_count",
"majestic_referring_domain_count"
) VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, DEFAULT, DEFAULT),
($11, $12, $13, $14, $15, $16, $17, $18, $19, $20, DEFAULT, DEFAULT),
($21, $22, $23, $24, $25, $26, $27, $28, $29, $30, DEFAULT, DEFAULT),
($31, $32, $33, $34, $35, $36, $37, $38, $39, $40, DEFAULT, DEFAULT),
($41, $42, $43, $44, $45, $46, $47, $48, $49, $50, DEFAULT, DEFAULT)
ON CONFLICT ("name") DO UPDATE
SET "majestic_backlink_count" = excluded.majestic_backlink_count;
INSERT INTO "domains" (
"name",
"formatted_name",
"root_name",
"tld",
"godaddy_auction_id",
"price",
"bid_count",
"auction_end_time",
"majestic_trust_flow",
"majestic_citation_flow",
"majestic_backlink_count",
"majestic_referring_domain_count"
) VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, DEFAULT, DEFAULT),
($11, $12, $13, $14, $15, $16, $17, $18, $19, $20, DEFAULT, DEFAULT),
($21, $22, $23, $24, $25, $26, $27, $28, $29, $30, DEFAULT, DEFAULT),
($31, $32, $33, $34, $35, $36, $37, $38, $39, $40, DEFAULT, DEFAULT),
($41, $42, $43, $44, $45, $46, $47, $48, $49, $50, DEFAULT, DEFAULT)
ON CONFLICT ("name") DO UPDATE
SET "majestic_backlink_count" = excluded.majestic_backlink_count;
Here's the query:
const rez = await db
.insert(domains)
.values(values)
.onConflictDoUpdate({
target: domains.name,
set: buildConflictUpdateColumns(domains, [
"auctionPrice",
"bidCount",
"auctionEndTime",
"majesticTrustFlow",
"majesticCitationFlow",
"majesticBacklinkCount",
"majesticReferringDomainCount",
]),
})
const rez = await db
.insert(domains)
.values(values)
.onConflictDoUpdate({
target: domains.name,
set: buildConflictUpdateColumns(domains, [
"auctionPrice",
"bidCount",
"auctionEndTime",
"majesticTrustFlow",
"majesticCitationFlow",
"majesticBacklinkCount",
"majesticReferringDomainCount",
]),
})
Why do majestic_backlink_count and majestic_referring_domain_count not have values like $11? This is resulting in data being set to NULL instead of the number value I've specified. How do I fix this?
1 Reply
zerokelvin
zerokelvinOP7mo ago
Here's my schema, there seems to be no reason why majestic_citation_flow would be treated any differently than the others:
import { pgTable, timestamp, index, text, integer, date } from "drizzle-orm/pg-core";

export const domains = pgTable('domains', {
name: text('name').primaryKey(),
formattedName: text('formatted_name').notNull(),
rootName: text('root_name').notNull(),
tld: text('tld').notNull(),

godaddyAuctionId: integer('godaddy_auction_id').unique(),

auctionPrice: integer('price'),
bidCount: integer('bid_count'),
auctionEndTime: timestamp('auction_end_time', {mode: 'date'}),

majesticTrustFlow: integer('majestic_trust_flow'),
majesticCitationFlow: integer('majestic_citation_flow'),
majesticBacklinkCount: integer('majestic_backlink_count'),
majesticReferringDomainCount: integer('majestic_referring_domain_count'),
});

export const schema = {
domains,
};
import { pgTable, timestamp, index, text, integer, date } from "drizzle-orm/pg-core";

export const domains = pgTable('domains', {
name: text('name').primaryKey(),
formattedName: text('formatted_name').notNull(),
rootName: text('root_name').notNull(),
tld: text('tld').notNull(),

godaddyAuctionId: integer('godaddy_auction_id').unique(),

auctionPrice: integer('price'),
bidCount: integer('bid_count'),
auctionEndTime: timestamp('auction_end_time', {mode: 'date'}),

majesticTrustFlow: integer('majestic_trust_flow'),
majesticCitationFlow: integer('majestic_citation_flow'),
majesticBacklinkCount: integer('majestic_backlink_count'),
majesticReferringDomainCount: integer('majestic_referring_domain_count'),
});

export const schema = {
domains,
};
Huh, I guess the commonality between the two that aren't getting values is that they both end in _count It seems renaming the columns to not end in _count fixes it This is a nasty bug in Drizzle, though
Want results from more Discord servers?
Add your server