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

Method test_select_from_bindparam

test/sql/test_query.py:349–372  ·  view source on GitHub ↗

Test result row processing when selecting from a plain bind param.

(self, connection)

Source from the content-addressed store, hash-verified

347
348 @testing.requires.standalone_binds
349 def test_select_from_bindparam(self, connection):
350 """Test result row processing when selecting from a plain bind
351 param."""
352
353 class MyInteger(TypeDecorator):
354 impl = Integer
355 cache_ok = True
356
357 def process_bind_param(self, value, dialect):
358 return int(value[4:])
359
360 def process_result_value(self, value, dialect):
361 return "INT_%d" % value
362
363 eq_(
364 connection.scalar(select(cast("INT_5", type_=MyInteger))),
365 "INT_5",
366 )
367 eq_(
368 connection.scalar(
369 select(cast("INT_5", type_=MyInteger).label("foo"))
370 ),
371 "INT_5",
372 )
373
374 def test_order_by(self, connection):
375 """Exercises ORDER BY clause generation.

Callers

nothing calls this directly

Calls 5

eq_Function · 0.90
selectFunction · 0.90
castFunction · 0.90
scalarMethod · 0.45
labelMethod · 0.45

Tested by

no test coverage detected