Postgres's Serial column type doesn't automatically have a default
Hello, when using postgres's
serial
types, and setting them as primary keys, there is an issue currently that does not mark them as has default
. What I mean is, from the docs The data types smallserial, serial and bigserial are not true types, but merely a notational convenience for creating unique identifier columns (similar to the AUTO_INCREMENT property supported by some other databases)
, the Serial
types already have a default implementation, but if you use them as is in Drizzle, they aren't regarded as having a default
I'd expect it to be nullable for inserts as serials have default5 Replies
Looks like a bug, could you create an issue on GH please?
GitHub
[BUG]: Serial type in PostgreSQL not recognized as having a default...
What version of drizzle-orm are you using? 0.26.1 What version of drizzle-kit are you using? 0.18.1 Describe the Bug I have encountered an issue with handling PostgreSQL's serial types (smallse...
Thank you! I thought I was going crazy, but I have the same issue.
+1 here
Related bugs are https://github.com/drizzle-team/drizzle-orm/issues/295 and https://github.com/drizzle-team/drizzle-orm/issues/261
GitHub
PostgreSQL: add
generated always as identity
as modern alternativ...It's basically the newer (and recommended) way to make auto incrementing columns. Example: create table old_way (id serial primary key); create table new_way (id integer primary key generated a...
GitHub
Support generated columns · Issue #261 · drizzle-team/drizzle-orm
CREATE TABLE t1( a INTEGER PRIMARY KEY, b INT, c TEXT, d INT GENERATED ALWAYS AS (a*abs(b)) VIRTUAL, e TEXT GENERATED ALWAYS AS (substr(c,b,b+1)) STORED );