MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_inline_defaults

Method test_inline_defaults

test/sql/test_insert.py:215–242  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

213 )
214
215 def test_inline_defaults(self):
216 m = MetaData()
217 foo = Table("foo", m, Column("id", Integer))
218
219 t = Table(
220 "test",
221 m,
222 Column("col1", Integer, default=func.foo(1)),
223 Column(
224 "col2",
225 Integer,
226 default=select(func.coalesce(func.max(foo.c.id))),
227 ),
228 )
229
230 self.assert_compile(
231 t.insert().values({}),
232 "INSERT INTO test (col1, col2) VALUES (foo(:foo_1), "
233 "(SELECT coalesce(max(foo.id)) AS coalesce_1 FROM "
234 "foo))",
235 )
236
237 self.assert_compile(
238 t.insert().inline().values({}),
239 "INSERT INTO test (col1, col2) VALUES (foo(:foo_1), "
240 "(SELECT coalesce(max(foo.id)) AS coalesce_1 FROM "
241 "foo))",
242 )
243
244 def test_generic_insert_bind_params_all_columns(self):
245 table1 = self.tables.mytable

Callers

nothing calls this directly

Calls 11

MetaDataClass · 0.90
TableClass · 0.90
ColumnClass · 0.90
selectFunction · 0.90
coalesceMethod · 0.80
maxMethod · 0.80
assert_compileMethod · 0.80
fooMethod · 0.45
valuesMethod · 0.45
insertMethod · 0.45
inlineMethod · 0.45

Tested by

no test coverage detected