| 2045 | @testing.variation("add_to_pk", [True, False]) |
| 2046 | @testing.variation("existing_pk", [True, False]) |
| 2047 | def test_insert_column_table(self, positions, add_to_pk, existing_pk): |
| 2048 | t = Table( |
| 2049 | "t", |
| 2050 | MetaData(), |
| 2051 | Column("a", Integer, primary_key=bool(existing_pk)), |
| 2052 | Column("b", Integer), |
| 2053 | Column("c", Integer), |
| 2054 | ) |
| 2055 | expected_cols = ["a", "b", "c"] |
| 2056 | |
| 2057 | if existing_pk: |
| 2058 | expected_pk_cols = ["a"] |
| 2059 | else: |
| 2060 | expected_pk_cols = [] |
| 2061 | |
| 2062 | for pos in positions: |
| 2063 | t.insert_column( |
| 2064 | Column(f"i{pos}", Integer, primary_key=bool(add_to_pk)), pos |
| 2065 | ) |
| 2066 | expected_cols.insert(pos, f"i{pos}") |
| 2067 | if add_to_pk: |
| 2068 | expected_pk_cols.append(f"i{pos}") |
| 2069 | eq_([c.key for c in t.c], expected_cols) |
| 2070 | |
| 2071 | eq_([c.key for c in t.primary_key], expected_pk_cols) |
| 2072 | |
| 2073 | @testing.combinations(-4, -3, -2, -1, 0, 1, 2, 3) |
| 2074 | def test_replace_col_with_index(self, new_index): |