Commit 360e3ee
authored
Ignore postgres version in adding-not-nullable-field (#412)
### Summary
Hey there, I noticed in #301 that the logic for handling adding new fields as null was split out from [adding-not-nullable-field](https://squawkhq.com/docs/adding-not-nullable-field) into [adding-required-field](https://squawkhq.com/docs/adding-required-field).
The logic for performing the pg version check wasn't removed however, so this causes the rule to fail to detect changing existing columns to be not null. All the logic for checking not null for adding cols was extracted to `adding-required-field` or covered by `adding-required-field`, so I think we can remove the version check altogether.
### Examples
#301 has nice examples showing how the other rules cover the adding column with not null. I've included the part below to show what changes with this PR.
Previously with --pg-version >=12:
```SQL
ALTER TABLE foo ALTER COLUMN d SET NOT NULL; -- no warning,
```
This PR with --pg-version >=12:
```SQL
ALTER TABLE foo ALTER COLUMN d SET NOT NULL; -- triggers adding-not-nullable-field
```
### Documentation
I updated `adding-not-nullable-field` to explicitly mention that it no longer covers adding cols, and added to the problem+solution sections as well.
I think ideally it'd be best to maybe re-name this rule to clarify the fact that it only covers modifying existing cols now, but that may be hard to do
---
Please let me know if this change may not be the best approach, or if there are any concerns!1 parent d84da4f commit 360e3ee
File tree
3 files changed
+56
-91
lines changed- docs/docs
- linter/src/rules
3 files changed
+56
-91
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
| 13 | + | |
| 14 | + | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | 8 | | |
14 | 9 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 10 | + | |
29 | 11 | | |
30 | | - | |
31 | 12 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 13 | + | |
39 | 14 | | |
40 | | - | |
| 15 | + | |
41 | 16 | | |
42 | | - | |
| 17 | + | |
43 | 18 | | |
44 | 19 | | |
45 | 20 | | |
| |||
54 | 29 | | |
55 | 30 | | |
56 | 31 | | |
57 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
58 | 36 | | |
59 | | - | |
60 | 37 | | |
61 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
62 | 46 | | |
63 | 47 | | |
64 | 48 | | |
| |||
68 | 52 | | |
69 | 53 | | |
70 | 54 | | |
71 | | - | |
| 55 | + | |
| 56 | + | |
72 | 57 | | |
73 | 58 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
83 | 66 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
90 | 73 | | |
91 | | - | |
92 | 74 | | |
93 | 75 | | |
94 | | - | |
95 | | - | |
96 | 76 | | |
97 | 77 | | |
98 | 78 | | |
99 | 79 | | |
100 | 80 | | |
101 | 81 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | 82 | | |
107 | 83 | | |
108 | 84 | | |
109 | 85 | | |
110 | 86 | | |
111 | 87 | | |
| 88 | + | |
| 89 | + | |
112 | 90 | | |
113 | 91 | | |
114 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
115 | 99 | | |
116 | 100 | | |
117 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
118 | 108 | | |
119 | 109 | | |
120 | 110 | | |
121 | 111 | | |
122 | | - | |
123 | 112 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | 14 | | |
21 | 15 | | |
22 | 16 | | |
| |||
42 | 36 | | |
43 | 37 | | |
44 | 38 | | |
45 | | - | |
46 | | - | |
47 | 39 | | |
48 | 40 | | |
49 | | - | |
50 | 41 | | |
51 | 42 | | |
52 | 43 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| 44 | + | |
| 45 | + | |
61 | 46 | | |
62 | 47 | | |
63 | 48 | | |
64 | 49 | | |
65 | 50 | | |
66 | 51 | | |
67 | | - | |
| 52 | + | |
68 | 53 | | |
69 | 54 | | |
70 | | - | |
| 55 | + | |
71 | 56 | | |
72 | 57 | | |
73 | 58 | | |
| |||
80 | 65 | | |
81 | 66 | | |
82 | 67 | | |
83 | | - | |
| 68 | + | |
84 | 69 | | |
85 | 70 | | |
86 | 71 | | |
| |||
89 | 74 | | |
90 | 75 | | |
91 | 76 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 77 | + | |
106 | 78 | | |
107 | 79 | | |
0 commit comments