You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error: cannot insert into column "id"
at Parser.parseErrorMessage (D:\repos\testapp\server\node_modules\pg-protocol\src\parser.ts:357:11)
at Parser.handlePacket (D:\repos\testapp\server\node_modules\pg-protocol\src\parser.ts:186:21)
at Parser.parse (D:\repos\testapp\server\node_modules\pg-protocol\src\parser.ts:101:30)
at Socket.<anonymous> (D:\repos\testapp\server\node_modules\pg-protocol\src\index.ts:7:48)
at Socket.emit (node:events:518:28)
at addChunk (node:internal/streams/readable:559:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
at Readable.push (node:internal/streams/readable:390:5)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
length: 272,
severity: 'ERROR',
code: '428C9',
detail: 'Column "id" is an identity column defined as GENERATED ALWAYS.',
hint: 'Use OVERRIDING SYSTEM VALUE to override.',
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'd:\\pginstaller_13.auto\\postgres.windows-x64\\src\\backend\\rewrite\\rewritehandler.c',
line: '820',
routine: 'rewriteTargetListIU'
If I use type serial instead of integer with .generatedAlwaysAsIdentity(), then it will work. How can this work using .generatedAlwaysAsIdentity() as the ID instead of serial?
Edit: I have noticed that it will work with integer and generatedAlwaysAsIdentity() if I insert only a single record instead of an array of records, such as:
it works just fine. Is the inability for an array of records to insert using integer("id").primaryKey().generatedAlwaysAsIdentity() instead of serial("id").primaryKey() a bug?
Expected behavior
The records should insert in to the table using the generated ID, when inserting an array of records
Environment & setup
Node v20.11.2
Windows 11
The text was updated successfully, but these errors were encountered:
elewin
changed the title
[BUG]: 'Column "id" is an identity column defined as GENERATED ALWAYS' when trying to insert a new record
[BUG]: 'Column "id" is an identity column defined as GENERATED ALWAYS' when trying to insert an array of new rows using generatedAlwaysAsIdentity()
Aug 27, 2024
elewin
changed the title
[BUG]: 'Column "id" is an identity column defined as GENERATED ALWAYS' when trying to insert an array of new rows using generatedAlwaysAsIdentity()
[BUG]: Error thrown when trying to insert an array of new rows using generatedAlwaysAsIdentity() for the id column
Aug 27, 2024
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:
However, when I try to run a simple migration, such as:
I get the following error:
If I use type
serial
instead ofinteger
with.generatedAlwaysAsIdentity()
, then it will work. How can this work using.generatedAlwaysAsIdentity()
as the ID instead ofserial
?Edit: I have noticed that it will work with
integer
andgeneratedAlwaysAsIdentity()
if I insert only a single record instead of an array of records, such as:Though if I define the id in the schema as
then try to insert an array of records such as
it works just fine. Is the inability for an array of records to insert using
integer("id").primaryKey().generatedAlwaysAsIdentity()
instead ofserial("id").primaryKey()
a bug?Expected behavior
The records should insert in to the table using the generated ID, when inserting an array of records
Environment & setup
Node v20.11.2
Windows 11
The text was updated successfully, but these errors were encountered: