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