Skip to content

Commit e9cec22

Browse files
lu-zeroshssoichiro
authored andcommitted
fix: Support pg_trgm operators
See https://www.postgresql.org/docs/current/pgtrgm.html
1 parent 3ae1db4 commit e9cec22

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/lib.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1799,7 +1799,7 @@ mod tests {
17991799
"<>", "<", ">=", ">>=", ">>", ">^", "->>", "->", "-|-", "-", "+", "/", "=", "%", "?||",
18001800
"?|", "?-|", "?-", "?#", "?&", "?", "@@@", "@@", "@>", "@?", "@-@", "@", "^@", "^",
18011801
"|&>", "|>>", "|/", "|", "||/", "||", "~>=~", "~>~", "~<=~", "~<~", "~=", "~*", "~~*",
1802-
"~~", "~",
1802+
"~~", "~", "%", "<%", "%>", "<<%", "%>>", "<<->", "<->>", "<<<->", "<->>>",
18031803
];
18041804

18051805
// Test each operator individually
@@ -1838,6 +1838,8 @@ mod tests {
18381838
left |>& right,
18391839
left <^ right,
18401840
left >^ right,
1841+
left <% right,
1842+
left %> right,
18411843
?- left,
18421844
left ?-| right,
18431845
left ?|| right,
@@ -1864,6 +1866,8 @@ SELECT
18641866
left |>& right,
18651867
left <^ right,
18661868
left >^ right,
1869+
left <% right,
1870+
left %> right,
18671871
?- left,
18681872
left ?-| right,
18691873
left ?|| right,

src/tokenizer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ fn get_word_token<'i>(input: &mut &'i str) -> PResult<Token<'i>> {
10491049
fn get_operator_token<'i>(input: &mut &'i str) -> PResult<Token<'i>> {
10501050
// Define the allowed operator characters
10511051
let allowed_operators = (
1052-
'!', '<', '>', '=', '|', ':', '-', '~', '*', '&', '@', '^', '?', '#', '/',
1052+
'!', '<', '>', '=', '|', ':', '-', '~', '*', '&', '@', '^', '?', '#', '/', '%',
10531053
);
10541054

10551055
take_while(2..=5, allowed_operators)

0 commit comments

Comments
 (0)