Repository navigation
Commit 39fef4b
authored
feat: batch renames, Python import rewrites and repairs of existing rule failures in sqb rename and sqb mv (#1229)
* feat: batch model renames, Python import rewrites and repairs of existing rule failures in sqb rename and sqb mv
sqb rename takes several model TARGET NEW_NAME pairs, or --from-file, and plans
and verifies them together like batch moves: one compile before, one of the
edited project after, all or nothing. Each renamed model gets its own
migrate_from, so every old name keeps a compatibility view. Column renames and
--cascade stay single and are refused in batch form; name reuse stays refused.
The scratch copy and the real write now apply changes in the same order: write
every change, then remove only the moved sources no change writes to, so a
chained move cannot lose a file in the real write while verification passes.
sqb mv rewrites project Python imports of the Python files it moves (direct,
aliased, grouped, from-package and relative imports) through a reusable
import-rewrite function, and refuses with the file and line when an import
cannot be rewritten safely: an unaliased import, a star import from the moved
module's package, a dynamic import naming it, or a mixed from-package import.
A project that already fails project rules can be refactored: existing rule
failures no longer block planning, and the edited project is compared with
them. New or worse rule failures, and every other error, still block. Text and
JSON output, including --dry-run, explain the failures before and after.
Projects failing at the input stage, such as a duplicate macro name, are
refused cleanly with their compile error, and --json prints an error document
on stdout when the project does not compile or the request is invalid.
* fix: plan SQL tests beside existing rule failures and block any growth in a rule failure
With rule failures in the project, the compiles of sqb rename and sqb mv
skipped SQL-test planning, so a planning error could pass verification.
They now plan SQL tests whenever the only errors are rule failures, as
sqb compile does; planning errors block.
A rule failure of the edited project is existing only with the same code,
place and message, or when only its numbers changed and none grew. Any
other change blocks, wherever it is reported, so a failure reported at a
sample file can no longer grow unnoticed. Nothing counts as resolved when
another error may have kept rules from running.
Python import rewriting also refuses importing a moved module by name from
a package whose __init__.py binds that name, or when the move renames the
module, and refuses a move while a project Python file is not UTF-8.
sqb rename with a target and no new name, or with nothing, is again a
usage error with exit code 2.
* test: regenerate refactor goldens for the rule baseline report1 parent 368a23e commit 39fef4b
82 files changed
Lines changed: 3413 additions & 311 deletions
File tree
- crates
- sqlbuild-cli/src
- argv
- _helpers
- tests
- dispatch
- main
- tests
- sqlbuild-pysource/src
- import_rewrites
- _helpers
- main
- tests
- sqlbuild-python/src/bindings/_helpers
- cli
- refactor
- sqlbuild-refactor
- src
- refactor_command
- _helpers
- main
- tests
- refactoring
- _helpers
- files
- planning
- main
- tests
- src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli
- tests
- e2e/src/sqlbuild/cli/commands/main/refactor
- goldens/compiler/failure
- website/src/content/docs/docs/cli
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
| 8 | + | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
99 | 105 | | |
100 | 106 | | |
101 | 107 | | |
| |||
263 | 269 | | |
264 | 270 | | |
265 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4891 | 4891 | | |
4892 | 4892 | | |
4893 | 4893 | | |
4894 | | - | |
| 4894 | + | |
4895 | 4895 | | |
4896 | 4896 | | |
4897 | 4897 | | |
4898 | 4898 | | |
4899 | 4899 | | |
4900 | 4900 | | |
4901 | 4901 | | |
4902 | | - | |
| 4902 | + | |
4903 | 4903 | | |
4904 | 4904 | | |
4905 | 4905 | | |
| 4906 | + | |
| 4907 | + | |
| 4908 | + | |
| 4909 | + | |
| 4910 | + | |
| 4911 | + | |
| 4912 | + | |
| 4913 | + | |
| 4914 | + | |
| 4915 | + | |
| 4916 | + | |
| 4917 | + | |
| 4918 | + | |
| 4919 | + | |
| 4920 | + | |
| 4921 | + | |
| 4922 | + | |
| 4923 | + | |
| 4924 | + | |
4906 | 4925 | | |
4907 | 4926 | | |
4908 | 4927 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
91 | 103 | | |
92 | 104 | | |
93 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| |||
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 23 | + | |
29 | 24 | | |
30 | 25 | | |
31 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | 100 | | |
102 | 101 | | |
103 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
101 | 95 | | |
102 | 96 | | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
| 97 | + | |
| 98 | + | |
108 | 99 | | |
109 | 100 | | |
110 | 101 | | |
| |||
0 commit comments