MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / go

Method go

test/orm/test_query.py:707–748  ·  view source on GitHub ↗
(stmt, expected, coreorm_exec, selected_columns=None)

Source from the content-addressed store, hash-verified

705 @testing.fixture
706 def assert_row_keys(self):
707 def go(stmt, expected, coreorm_exec, selected_columns=None):
708 if coreorm_exec == "core":
709 with testing.db.connect() as conn:
710 row = conn.execute(stmt).first()
711 else:
712 s = fixture_session()
713
714 row = s.execute(stmt).first()
715
716 eq_(row._mapping.keys(), expected)
717
718 if selected_columns is None:
719 selected_columns = expected
720
721 # we are disambiguating in exported_columns even if
722 # LABEL_STYLE_NONE, this seems weird also
723 if (
724 stmt._label_style is not LABEL_STYLE_NONE
725 and coreorm_exec == "core"
726 ):
727 eq_(stmt.exported_columns.keys(), list(selected_columns))
728
729 if (
730 stmt._label_style is not LABEL_STYLE_NONE
731 and coreorm_exec == "orm"
732 ):
733 for k in expected:
734 is_not_none(getattr(row, k))
735
736 try:
737 column_descriptions = stmt.column_descriptions
738 except (NotImplementedError, AttributeError):
739 pass
740 else:
741 eq_(
742 [
743 entity["name"]
744 for entity in column_descriptions
745 if entity["name"] is not None
746 ],
747 list(selected_columns),
748 )
749
750 return go
751

Callers

nothing calls this directly

Calls 7

fixture_sessionFunction · 0.90
eq_Function · 0.90
is_not_noneFunction · 0.90
connectMethod · 0.45
firstMethod · 0.45
executeMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected