diff --git a/crates/lib-dialects/src/postgres.rs b/crates/lib-dialects/src/postgres.rs index 0af942122..6d7ff7f04 100644 --- a/crates/lib-dialects/src/postgres.rs +++ b/crates/lib-dialects/src/postgres.rs @@ -58,6 +58,11 @@ pub fn raw_dialect() -> Dialect { r#"->>|#>>|->|#>|@>|<@|\?\||\?|\?&|#-"#, SyntaxKind::JsonOperator ), + Matcher::regex( + "trgm_operator", + r#"(<<<->|<->>>|<<->|<->>|<->|<<%|%>>|%>|<%|%)"#, + SyntaxKind::LikeOperator + ), Matcher::string( "at", "@", diff --git a/crates/lib-dialects/test/fixtures/dialects/postgres/pgtrgm.sql b/crates/lib-dialects/test/fixtures/dialects/postgres/pgtrgm.sql new file mode 100644 index 000000000..7ec9f5c7b --- /dev/null +++ b/crates/lib-dialects/test/fixtures/dialects/postgres/pgtrgm.sql @@ -0,0 +1,10 @@ +SELECT text % text; +SELECT text <% text; +SELECT text %> text; +SELECT text <<% text; +SELECT text %>> text; +SELECT text <-> text; +SELECT text <<-> text; +SELECT text <->> text; +SELECT text <<<-> text; +SELECT text <->>> text; diff --git a/crates/lib-dialects/test/fixtures/dialects/postgres/pgtrgm.yml b/crates/lib-dialects/test/fixtures/dialects/postgres/pgtrgm.yml new file mode 100644 index 000000000..0e032a56d --- /dev/null +++ b/crates/lib-dialects/test/fixtures/dialects/postgres/pgtrgm.yml @@ -0,0 +1,121 @@ +file: +- statement: + - select_statement: + - select_clause: + - keyword: SELECT + - select_clause_element: + - expression: + - column_reference: + - naked_identifier: text + - binary_operator: '%' + - column_reference: + - naked_identifier: text +- statement_terminator: ; +- statement: + - select_statement: + - select_clause: + - keyword: SELECT + - select_clause_element: + - expression: + - column_reference: + - naked_identifier: text + - comparison_operator: <% + - column_reference: + - naked_identifier: text +- statement_terminator: ; +- statement: + - select_statement: + - select_clause: + - keyword: SELECT + - select_clause_element: + - expression: + - column_reference: + - naked_identifier: text + - comparison_operator: '%>' + - column_reference: + - naked_identifier: text +- statement_terminator: ; +- statement: + - select_statement: + - select_clause: + - keyword: SELECT + - select_clause_element: + - expression: + - column_reference: + - naked_identifier: text + - comparison_operator: <<% + - column_reference: + - naked_identifier: text +- statement_terminator: ; +- statement: + - select_statement: + - select_clause: + - keyword: SELECT + - select_clause_element: + - expression: + - column_reference: + - naked_identifier: text + - comparison_operator: '%>>' + - column_reference: + - naked_identifier: text +- statement_terminator: ; +- statement: + - select_statement: + - select_clause: + - keyword: SELECT + - select_clause_element: + - expression: + - column_reference: + - naked_identifier: text + - comparison_operator: <-> + - column_reference: + - naked_identifier: text +- statement_terminator: ; +- statement: + - select_statement: + - select_clause: + - keyword: SELECT + - select_clause_element: + - expression: + - column_reference: + - naked_identifier: text + - comparison_operator: <<-> + - column_reference: + - naked_identifier: text +- statement_terminator: ; +- statement: + - select_statement: + - select_clause: + - keyword: SELECT + - select_clause_element: + - expression: + - column_reference: + - naked_identifier: text + - comparison_operator: <->> + - column_reference: + - naked_identifier: text +- statement_terminator: ; +- statement: + - select_statement: + - select_clause: + - keyword: SELECT + - select_clause_element: + - expression: + - column_reference: + - naked_identifier: text + - comparison_operator: <<<-> + - column_reference: + - naked_identifier: text +- statement_terminator: ; +- statement: + - select_statement: + - select_clause: + - keyword: SELECT + - select_clause_element: + - expression: + - column_reference: + - naked_identifier: text + - comparison_operator: <->>> + - column_reference: + - naked_identifier: text +- statement_terminator: ;