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

Method test_dupe_col_name

test/orm/test_bundle.py:167–218  ·  view source on GitHub ↗

test #11347

(self, stmt_type, col_type)

Source from the content-addressed store, hash-verified

165 )
166 @testing.variation("col_type", ["orm", "core"])
167 def test_dupe_col_name(self, stmt_type, col_type):
168 """test #11347"""
169 Data = self.classes.Data
170 sess = fixture_session()
171
172 if col_type.orm:
173 b1 = Bundle("b1", Data.d1, Data.d3)
174 cols = Data.d1, Data.d2
175 elif col_type.core:
176 data_table = self.tables.data
177 b1 = Bundle("b1", data_table.c.d1, data_table.c.d3)
178 cols = data_table.c.d1, data_table.c.d2
179 else:
180 col_type.fail()
181
182 if stmt_type.legacy:
183 row = (
184 sess.query(cols[0], cols[1], b1)
185 .filter(Data.d1 == "d0d1")
186 .one()
187 )
188 elif stmt_type.newstyle:
189 row = sess.execute(
190 select(cols[0], cols[1], b1).filter(Data.d1 == "d0d1")
191 ).one()
192 elif stmt_type.newstyle_w_label_conv:
193 row = sess.execute(
194 select(cols[0], cols[1], b1)
195 .filter(Data.d1 == "d0d1")
196 .set_label_style(
197 SelectLabelStyle.LABEL_STYLE_TABLENAME_PLUS_COL
198 )
199 ).one()
200 else:
201 stmt_type.fail()
202
203 if stmt_type.newstyle_w_label_conv:
204 # decision is made here that even if a SELECT with the
205 # "tablename_plus_colname" label style, within a Bundle we still
206 # use straight column name, even though the overall row
207 # uses tablename_colname
208 eq_(
209 row._mapping,
210 {"data_d1": "d0d1", "data_d2": "d0d2", "b1": ("d0d1", "d0d3")},
211 )
212 else:
213 eq_(
214 row._mapping,
215 {"d1": "d0d1", "d2": "d0d2", "b1": ("d0d1", "d0d3")},
216 )
217
218 eq_(row[2]._mapping, {"d1": "d0d1", "d3": "d0d3"})
219
220 @testing.variation(
221 "stmt_type", ["legacy", "newstyle", "newstyle_w_label_conv"]

Callers

nothing calls this directly

Calls 10

fixture_sessionFunction · 0.90
BundleClass · 0.90
selectFunction · 0.90
eq_Function · 0.90
failMethod · 0.45
oneMethod · 0.45
filterMethod · 0.45
queryMethod · 0.45
executeMethod · 0.45
set_label_styleMethod · 0.45

Tested by

no test coverage detected