MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_inline_defaults

Method test_inline_defaults

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

Source from the content-addressed store, hash-verified

225 )
226
227 def test_inline_defaults(self):
228 m = MetaData()
229 foo = Table("foo", m, Column("id", Integer))
230
231 t = Table(
232 "test",
233 m,
234 Column("col1", Integer, default=func.foo(1)),
235 Column(
236 "col2",
237 Integer,
238 default=select(func.coalesce(func.max(foo.c.id))),
239 ),
240 )
241
242 self.assert_compile(
243 t.insert().values({}),
244 "INSERT INTO test (col1, col2) VALUES (foo(:foo_1), "
245 "(SELECT coalesce(max(foo.id)) AS coalesce_1 FROM "
246 "foo))",
247 )
248
249 self.assert_compile(
250 t.insert().inline().values({}),
251 "INSERT INTO test (col1, col2) VALUES (foo(:foo_1), "
252 "(SELECT coalesce(max(foo.id)) AS coalesce_1 FROM "
253 "foo))",
254 )
255
256 def test_generic_insert_bind_params_all_columns(self):
257 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