summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 7a898cb8a..fd258bc5a 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -68,8 +68,7 @@ The CREATE TABLE for the above :class:`_schema.Table` object would be:
.. sourcecode:: sql
CREATE TABLE data (
- id INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 42 CYCLE)
- NOT NULL,
+ id INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 42 CYCLE),
data VARCHAR,
PRIMARY KEY (id)
)
@@ -107,7 +106,7 @@ The CREATE TABLE for the above :class:`_schema.Table` object would be:
Will generate on the backing database as::
CREATE TABLE t (
- id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
+ id INT GENERATED BY DEFAULT AS IDENTITY,
data VARCHAR,
PRIMARY KEY (id)
)
@@ -2325,8 +2324,10 @@ class PGDDLCompiler(compiler.DDLCompiler):
if column.identity is not None:
colspec += " " + self.process(column.identity)
- if not column.nullable:
+ if not column.nullable and not column.identity:
colspec += " NOT NULL"
+ elif column.nullable and column.identity:
+ colspec += " NULL"
return colspec
def visit_check_constraint(self, constraint):