cannot insert into column "id"

i get this error when i try to insert more than one value into my postgres
export const productsTable = pgTable("products", {
id: integer().primaryKey().generatedAlwaysAsIdentity({ startWith: 1000 }),
name: varchar({ length: 255 }).notNull(),
})

const result = await db
.insert(productsTable)
.values([
{ name: 'test' },
{ name: 'test2' },
])
export const productsTable = pgTable("products", {
id: integer().primaryKey().generatedAlwaysAsIdentity({ startWith: 1000 }),
name: varchar({ length: 255 }).notNull(),
})

const result = await db
.insert(productsTable)
.values([
{ name: 'test' },
{ name: 'test2' },
])
error: cannot insert into column "id"
at .../node_modules/.pnpm/[email protected][email protected]/node_modules/pg-pool/index.js:45:11
at processTicksAndRejections (node:internal/process/task_queues:105:5)
error: cannot insert into column "id"
at .../node_modules/.pnpm/[email protected][email protected]/node_modules/pg-pool/index.js:45:11
at processTicksAndRejections (node:internal/process/task_queues:105:5)
can anyone help me?
8 Replies
RWOverdijk
RWOverdijk2mo ago
Code seems right to me. Are you on an old version perhaps?
RWOverdijk
RWOverdijk2mo ago
GitHub
[BUG]: Error thrown when trying to insert an array of new rows usin...
What version of drizzle-orm are you using? 0.33.0 What version of drizzle-kit are you using? 0.24.0 Describe the Bug I have a simple schema file: import { pgTable, integer, text } from "drizzl...
ORACLE
ORACLEOP2mo ago
im using: "drizzle-orm": "^0.40.0" and "drizzle-kit": "^0.30.5", i really cant explain why it wont work
RWOverdijk
RWOverdijk2mo ago
Super weird. It sounds similar to that issue, so maybe a regression? I can't see anything obviously wrong
ORACLE
ORACLEOP2mo ago
:sad:
ORACLE
ORACLEOP2mo ago
GitHub
Batch of bugfixes for the ORM by L-Mario564 · Pull Request #2938 · ...
Addresses #2146, #2272, #2849, #2603. limit and offset now accepts placeholders as values in MySQL. Added appropriate tests. (#2146). Bugs described in #2272 and #2849 seem to no longer be present...
ORACLE
ORACLEOP2mo ago
doesnt work either but it works as soon as i only add one at a time i also tried to downgrade the version to 0.36.1
RWOverdijk
RWOverdijk2mo ago
Maybe make a minimal reproduction and create a new issue with it Makes it a lot easier to test

Did you find this page helpful?