Skip to content

Commit

Permalink
Merge branch 'postgresql' of github.com:JabRef/jabref into postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Sep 23, 2024
2 parents 9028748 + 58d7e25 commit 1787b5b
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,25 @@ class SearchToSqlConversionTest {
@ParameterizedTest
@CsvSource({
// Default search, query without any field name (case insensitive contains)
"SELECT entry_id FROM tableName WHERE (field_value ~* 'compute'), compute",
"SELECT entry_id FROM tableName WHERE (field_value ~* 'computer'), computer",
"SELECT entry_id FROM tableName WHERE (field_value ~* 'computer science'), \"computer science\"", // Phrase search
"SELECT entry_id FROM tableName WHERE (field_value ~* 'computer') OR (field_value ~* 'science'), computer science", // Should be searched as a phrase or as two separate words (OR)?
"SELECT entry_id FROM tableName WHERE (field_value ~* '!computer'), !computer", // Is the explanation should be escaped?
"SELECT entry_id FROM tableName WHERE (field_value ~* '!computer'), \"!computer\"",
// search in all fields case sensitive contains
"SELECT entry_id FROM tableName WHERE (field_value ~ 'computer'), any=!computer",
"SELECT entry_id FROM tableName WHERE (field_value ~ '!computer'), any=! !computer", // Is the explanation should be escaped?
// Regex search
"SELECT entry_id FROM tableName WHERE (field_value ~* 'Jabref.*Search'), Jabref.*Search",
"SELECT entry_id FROM tableName WHERE (field_value ~* 'Jabref.*Search'), \"Jabref.*Search\"", // This is wrong, this query should be a string literal searching for "Jabref.*Search" as string, should use syntax LIKE %...%
// And
"SELECT entry_id FROM tableName WHERE (field_value ~* 'computer') AND (field_value ~* 'science'), computer AND science",
// Or
"SELECT entry_id FROM tableName WHERE (field_value ~* 'computer') OR (field_value ~* 'science'), computer OR science",
// Grouping
"SELECT entry_id FROM tableName WHERE ((field_value ~* 'computer') AND (field_value ~* 'science')) OR (field_value ~* 'math'), (computer AND science) OR math",
"SELECT entry_id FROM tableName WHERE (field_value ~* 'computer') AND ((field_value ~* 'science') OR (field_value ~* 'math')), computer AND (science OR math)",
"SELECT entry_id FROM tableName WHERE ((field_value ~* 'computer') OR (field_value ~* 'science')) AND ((field_value ~* 'math') OR (field_value ~* 'physics')), (computer OR science) AND (math OR physics)",
// case insensitive contains
"SELECT entry_id FROM tableName WHERE (field_name = 'title' AND field_value ~* 'compute'), title=compute",
// case sensitive contains
Expand Down

0 comments on commit 1787b5b

Please sign in to comment.