Skip to content

Commit c6e8a1b

Browse files
authored
linter: false positive with constraint-missing-not-valid (#694)
rel: #693
1 parent 99563c9 commit c6e8a1b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

crates/squawk_linter/src/rules/constraint_missing_not_valid.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,13 @@ pub(crate) fn constraint_missing_not_valid(ctx: &mut Linter, parse: &Parse<Sourc
126126
continue;
127127
}
128128
}
129+
if let Some(ast::Constraint::PrimaryKeyConstraint(pk)) =
130+
add_constraint.constraint()
131+
{
132+
if pk.using_index().is_some() {
133+
continue;
134+
}
135+
}
129136

130137
ctx.report(Violation::for_node(
131138
Rule::ConstraintMissingNotValid,
@@ -206,6 +213,15 @@ ALTER TABLE distributors VALIDATE CONSTRAINT distfk;
206213
assert_eq!(errors.len(), 0);
207214
}
208215

216+
#[test]
217+
fn adding_using_index_ok() {
218+
let sql = r#"
219+
ALTER TABLE account ADD CONSTRAINT account_pk PRIMARY KEY USING INDEX account_pk_idx;
220+
"#;
221+
let errors = lint(sql, Rule::ConstraintMissingNotValid);
222+
assert_eq!(errors.len(), 0);
223+
}
224+
209225
#[test]
210226
fn adding_check_constraint_err() {
211227
let sql = r#"

0 commit comments

Comments
 (0)