(self)
| 86 | ) |
| 87 | |
| 88 | def test_node_position_changed(self): |
| 89 | expr_src = parse_one("SELECT a, b, c") |
| 90 | expr_tgt = parse_one("SELECT c, a, b") |
| 91 | |
| 92 | self._validate_delta_only( |
| 93 | diff_delta_only(expr_src, expr_tgt), |
| 94 | [ |
| 95 | Move(source=expr_src.selects[2], target=expr_tgt.selects[0]), |
| 96 | ], |
| 97 | ) |
| 98 | |
| 99 | expr_src = parse_one("SELECT a + b") |
| 100 | expr_tgt = parse_one("SELECT b + a") |
| 101 | |
| 102 | self._validate_delta_only( |
| 103 | diff_delta_only(expr_src, expr_tgt), |
| 104 | [ |
| 105 | Move(source=expr_src.selects[0].left, target=expr_tgt.selects[0].right), |
| 106 | ], |
| 107 | ) |
| 108 | |
| 109 | expr_src = parse_one("SELECT aaaa AND bbbb") |
| 110 | expr_tgt = parse_one("SELECT bbbb AND aaaa") |
| 111 | |
| 112 | self._validate_delta_only( |
| 113 | diff_delta_only(expr_src, expr_tgt), |
| 114 | [ |
| 115 | Move(source=expr_src.selects[0].left, target=expr_tgt.selects[0].right), |
| 116 | ], |
| 117 | ) |
| 118 | |
| 119 | expr_src = parse_one("SELECT aaaa OR bbbb OR cccc") |
| 120 | expr_tgt = parse_one("SELECT cccc OR bbbb OR aaaa") |
| 121 | |
| 122 | self._validate_delta_only( |
| 123 | diff_delta_only(expr_src, expr_tgt), |
| 124 | [ |
| 125 | Move(source=expr_src.selects[0].left.left, target=expr_tgt.selects[0].right), |
| 126 | Move(source=expr_src.selects[0].right, target=expr_tgt.selects[0].left.left), |
| 127 | ], |
| 128 | ) |
| 129 | |
| 130 | expr_src = parse_one("SELECT a, b FROM t WHERE CONCAT('a', 'b') = 'ab'") |
| 131 | expr_tgt = parse_one("SELECT a FROM t WHERE CONCAT('a', 'b', b) = 'ab'") |
| 132 | |
| 133 | self._validate_delta_only( |
| 134 | diff_delta_only(expr_src, expr_tgt), |
| 135 | [ |
| 136 | Move(source=expr_src.selects[1], target=expr_tgt.find(exp.Concat).expressions[-1]), |
| 137 | ], |
| 138 | ) |
| 139 | |
| 140 | expr_src = parse_one("SELECT a as a, b as b FROM t WHERE CONCAT('a', 'b') = 'ab'") |
| 141 | expr_tgt = parse_one("SELECT a as a FROM t WHERE CONCAT('a', 'b', b) = 'ab'") |
| 142 | |
| 143 | b_alias = expr_src.selects[1] |
| 144 | |
| 145 | self._validate_delta_only( |
nothing calls this directly
no test coverage detected