MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_non_autoincrement

Method test_non_autoincrement

test/sql/test_defaults.py:1157–1172  ·  view source on GitHub ↗
(self, connection)

Source from the content-addressed store, hash-verified

1155 @testing.only_on("sqlite")
1156 @testing.provide_metadata
1157 def test_non_autoincrement(self, connection):
1158 # sqlite INT primary keys can be non-unique! (only for ints)
1159 nonai = Table(
1160 "nonaitest",
1161 self.metadata,
1162 Column("id", Integer, autoincrement=False, primary_key=True),
1163 Column("data", String(20)),
1164 )
1165 nonai.create(connection)
1166
1167 # just testing SQLite for now, it passes
1168 with expect_warnings(".*has no Python-side or server-side default.*"):
1169 # postgresql + mysql strict will fail on first row,
1170 # mysql in legacy mode fails on second row
1171 connection.execute(nonai.insert(), dict(data="row 1"))
1172 connection.execute(nonai.insert(), dict(data="row 2"))
1173
1174 @testing.metadata_fixture(ddl="function")
1175 def dataset_no_autoinc(self, metadata):

Callers

nothing calls this directly

Calls 7

createMethod · 0.95
TableClass · 0.90
ColumnClass · 0.90
StringClass · 0.90
expect_warningsFunction · 0.90
executeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected