MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_freeze

Method test_freeze

test/sql/test_resultset.py:118–159  ·  view source on GitHub ↗

test #8963

(self, type_, connection)

Source from the content-addressed store, hash-verified

116 "type_", ["text", "driversql", "core", "textstar", "driverstar"]
117 )
118 def test_freeze(self, type_, connection):
119 """test #8963"""
120
121 users = self.tables.users
122 connection.execute(
123 users.insert(),
124 [
125 dict(user_id=1, user_name="john"),
126 dict(user_id=2, user_name="jack"),
127 ],
128 )
129
130 if type_.core:
131 stmt = select(users).order_by(users.c.user_id)
132 else:
133 if "star" in type_.name:
134 stmt = "select * from users order by user_id"
135 else:
136 stmt = "select user_id, user_name from users order by user_id"
137
138 if "text" in type_.name:
139 stmt = text(stmt)
140
141 if "driver" in type_.name:
142 result = connection.exec_driver_sql(stmt)
143 else:
144 result = connection.execute(stmt)
145
146 frozen = result.freeze()
147
148 unfrozen = frozen()
149 eq_(unfrozen.keys(), ["user_id", "user_name"])
150 eq_(unfrozen.all(), [(1, "john"), (2, "jack")])
151
152 unfrozen = frozen()
153 eq_(
154 unfrozen.mappings().all(),
155 [
156 {"user_id": 1, "user_name": "john"},
157 {"user_id": 2, "user_name": "jack"},
158 ],
159 )
160
161 @testing.requires.insert_executemany_returning
162 @testing.variation("filters", ["unique", "sliced", "plain"])

Callers

nothing calls this directly

Calls 11

selectFunction · 0.90
textFunction · 0.90
eq_Function · 0.90
executeMethod · 0.45
insertMethod · 0.45
order_byMethod · 0.45
exec_driver_sqlMethod · 0.45
freezeMethod · 0.45
keysMethod · 0.45
allMethod · 0.45
mappingsMethod · 0.45

Tested by

no test coverage detected