Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions crates/squawk_linter/src/rules/prefer_identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,22 @@ create table users (
);
create table users (
id bigserial
);
create table users (
id BIGSERIAL
);
"#;
let file = squawk_syntax::SourceFile::parse(sql);
let mut linter = Linter::from([Rule::PreferIdentity]);
let errors = linter.lint(file, sql);
assert_ne!(errors.len(), 0);
assert_eq!(errors.len(), 6);
assert_eq!(errors.len(), 7);
assert_eq!(
errors
.iter()
.filter(|x| x.code == Rule::PreferIdentity)
.count(),
6
7
);
assert_debug_snapshot!(errors);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: crates/squawk_linter/src/rules/prefer_identity.rs
assertion_line: 86
expression: errors
---
[
Expand Down Expand Up @@ -51,4 +52,12 @@ expression: errors
"Use an `IDENTITY` column instead.",
),
},
Violation {
code: PreferIdentity,
message: "Serial types make schema, dependency, and permission management difficult.",
text_range: 268..277,
help: Some(
"Use an `IDENTITY` column instead.",
),
},
]
2 changes: 1 addition & 1 deletion crates/squawk_linter/src/visitors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub(crate) fn is_not_valid_int_type(ty: &ast::Type, invalid_type_names: &HashSet
return false;
};
let name = trim_quotes(ty_name.as_str());
invalid_type_names.contains(name)
invalid_type_names.contains(name.to_lowercase().as_str())
}
ast::Type::CharType(_) => false,
ast::Type::BitType(_) => false,
Expand Down
Loading