Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

Commit d1dcafe

Browse files
authored
Add IDENTITY/SERIAL support
1 parent 33f6ea7 commit d1dcafe

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

sqla_vertica_python/vertica_python.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
from sqlalchemy.dialects.postgresql.base import PGDialect
44
from sqlalchemy.dialects.postgresql import INTERVAL
55
from sqlalchemy.engine import reflection
6+
from sqlalchemy.schema import CreateColumn
7+
from sqlalchemy.ext.compiler import compiles
8+
9+
10+
# From Postgresql 10 IDENTITY columns section in sqlalchemy/dialects/postgresql/base.py
11+
@compiles(CreateColumn, 'vertica')
12+
def use_identity(element, compiler, **kw):
13+
text = compiler.visit_create_column(element, **kw)
14+
text = text.replace("SERIAL", "IDENTITY(1,1)")
15+
return text
16+
617

718
class VerticaDialect(PGDialect):
819
""" Vertica Dialect using a vertica-python connection and PGDialect """

0 commit comments

Comments
 (0)