@@ -5,12 +5,15 @@ use squawk_syntax::{
55 ast:: { self , AstNode } ,
66} ;
77
8- use crate :: { Linter , Rule , Violation , text:: trim_quotes} ;
8+ use crate :: {
9+ Linter , Rule , Violation ,
10+ identifier:: Identifier ,
11+ } ;
912
1013pub fn tables_created_in_transaction (
1114 assume_in_transaction : bool ,
1215 file : & ast:: SourceFile ,
13- ) -> HashSet < String > {
16+ ) -> HashSet < Identifier > {
1417 let mut created_table_names = HashSet :: new ( ) ;
1518 let mut inside_transaction = assume_in_transaction;
1619 for stmt in file. stmts ( ) {
@@ -29,7 +32,7 @@ pub fn tables_created_in_transaction(
2932 else {
3033 continue ;
3134 } ;
32- created_table_names. insert ( trim_quotes ( & table_name. text ( ) ) . to_string ( ) ) ;
35+ created_table_names. insert ( Identifier :: new ( & table_name. text ( ) ) ) ;
3336 }
3437 _ => ( ) ,
3538 }
@@ -43,7 +46,7 @@ fn not_valid_validate_in_transaction(
4346 file : & ast:: SourceFile ,
4447) {
4548 let mut inside_transaction = assume_in_transaction;
46- let mut not_valid_names: HashSet < String > = HashSet :: new ( ) ;
49+ let mut not_valid_names: HashSet < Identifier > = HashSet :: new ( ) ;
4750 for stmt in file. stmts ( ) {
4851 match stmt {
4952 ast:: Stmt :: AlterTable ( alter_table) => {
@@ -54,7 +57,7 @@ fn not_valid_validate_in_transaction(
5457 validate_constraint. name_ref ( ) . map ( |x| x. text ( ) . to_string ( ) )
5558 {
5659 if inside_transaction
57- && not_valid_names. contains ( trim_quotes ( & constraint_name) )
60+ && not_valid_names. contains ( & Identifier :: new ( & constraint_name) )
5861 {
5962 ctx. report (
6063 Violation :: new (
@@ -70,9 +73,7 @@ fn not_valid_validate_in_transaction(
7073 if add_constraint. not_valid ( ) . is_some ( ) {
7174 if let Some ( constraint) = add_constraint. constraint ( ) {
7275 if let Some ( constraint_name) = constraint. name ( ) {
73- not_valid_names. insert (
74- trim_quotes ( & constraint_name. text ( ) ) . to_string ( ) ,
75- ) ;
76+ not_valid_names. insert ( Identifier :: new ( & constraint_name. text ( ) ) ) ;
7677 }
7778 }
7879 }
@@ -117,7 +118,7 @@ pub(crate) fn constraint_missing_not_valid(ctx: &mut Linter, parse: &Parse<Sourc
117118 } ;
118119 for action in alter_table. actions ( ) {
119120 if let ast:: AlterTableAction :: AddConstraint ( add_constraint) = action {
120- if !tables_created. contains ( trim_quotes ( & table_name) )
121+ if !tables_created. contains ( & Identifier :: new ( & table_name) )
121122 && add_constraint. not_valid ( ) . is_none ( )
122123 {
123124 if let Some ( ast:: Constraint :: UniqueConstraint ( uc) ) =
0 commit comments