Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pypika/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class SqlTypes:
NUMERIC = "NUMERIC"
SIGNED = "SIGNED"
UNSIGNED = "UNSIGNED"
INTEGER_AUTO_INCREMENT = "INTEGER AUTO_INCREMENT"

DATE = "DATE"
TIME = "TIME"
Expand Down
9 changes: 8 additions & 1 deletion pypika/tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from pypika import Column, Columns, Query, Tables, Table
from pypika.terms import ValueWrapper, Index
from pypika.enums import ReferenceOption
from pypika.enums import ReferenceOption, SqlTypes


class CreateTableTests(unittest.TestCase):
Expand Down Expand Up @@ -124,6 +124,13 @@ def test_create_table_with_columns(self):

self.assertEqual('CREATE TABLE IF NOT EXISTS "abc" ("a" INT,"b" VARCHAR(100))', str(q))

with self.subTest("with primary key & auto increment"):
a = Column("a", SqlTypes.INTEGER_AUTO_INCREMENT, False)
b = Column("b", "VARCHAR(100)", default="foo")
q = Query.create_table(self.new_table).columns(a, b).primary_key(a)

self.assertEqual('CREATE TABLE "abc" ("a" INTEGER AUTO_INCREMENT NOT NULL,"b" VARCHAR(100) DEFAULT \'foo\',PRIMARY KEY ("a"))', str(q))

def test_create_table_with_select(self):
select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar)

Expand Down