pg - optional id for `generated always as identity`
raduconst06 opened this issue · 0 comments
raduconst06 commented
Hello,
First I would like to congratulate on this very cool project.
I have a question regarding whether the id's should be optional when they are auto generated primary keys, as described below:
Given the following sql script migration
CREATE TABLE IF NOT EXISTS project (
id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
title varchar(100) NOT NULL
);
the following type for insertion is created:
/**
* !!! This file is autogenerated do not edit by hand !!!
*
* Generated by: @databases/pg-schema-print-types
* Checksum: l01RsxWnWb0RbxhBjInr7WGCBU8GDkc5dcPk8lJLY4D/dVPv4f/TudI3XAGryrwXVVcbziOtcbpetdYuUCvqFA==
*/
/* eslint-disable */
// tslint:disable
interface Project {
id: number & {readonly __brand?: 'project_id'}
title: string
}
export default Project;
interface Project_InsertParameters {
id: number & {readonly __brand?: 'project_id'}
title: string
}
export type {Project_InsertParameters}
Given the id is an auto-generated primary key I would expect to have something similar to the following type for Project_InsertParameters:
interface Project_InsertParameters (notice OptionalId) {
id?: number & {readonly __brand?: 'project_id'}
title: string
}
Why?
The value is generated by the database, I should not have to provide it.
Can you confirm if the current behavior is expected or if I am using the generated types wrong?
Thank you!