-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Like operator #160
Like operator #160
Changes from 7 commits
d9090ae
260d25a
2d6425a
5b28c5e
dc3ac45
6a197fb
2719559
0ef147e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1287,8 +1287,22 @@ In addition to the standard equality and inequality operators, matching of parti | |||||||||||||||||||||
|
||||||||||||||||||||||
OPTIONAL features: | ||||||||||||||||||||||
|
||||||||||||||||||||||
The following comparison operators are OPTIONAL: | ||||||||||||||||||||||
|
||||||||||||||||||||||
* `identfier LIKE x` | ||||||||||||||||||||||
|
||||||||||||||||||||||
* `identfier UNLIKE x` | ||||||||||||||||||||||
Comment on lines
+1292
to
+1294
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Adds a bit of explanation matching the format for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a strong preference for I guess the precedent for this is our inclusion of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
UNLIKE is shorter, which is significant for URL-embedded querries...
I would say that if LIKE is implemented, UNLIKE also MUST be implemented; i.e. |
||||||||||||||||||||||
|
||||||||||||||||||||||
* Support for x to be an identifier, rather than a string is OPTIONAL. | ||||||||||||||||||||||
|
||||||||||||||||||||||
If implemented, the "LIKE" operator MUST behave as the correspoding standard SQL operator. In particular, | ||||||||||||||||||||||
The `x` string MUST be interpreted as a pattern where an underscore character ('_', ASCII DEC 95, HEX 5F) | ||||||||||||||||||||||
matches any single character and a percent character ('%', ASCII DEC 37, HEX 25) matches an arbitrary | ||||||||||||||||||||||
sequence of characters (including zero characters). | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't then we also explain how to escape these characters, and how to escape the escape character? (should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. MySQL specification says that to search for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @giovannipizzi & @merkys for spotting this deficiency; I'll look up the existing escape rules and suggest a version in the text. I agree with @giovannipizzi that we can use single backslash to escape characters, but we need to think over all possible combinations. I'll propose a variant in a while.
Comment on lines
+1298
to
+1301
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Fix a few typos and enforces one line per sentence There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If we describe, as suggested, the RE syntax in the OPTIMADE independently, we can strengthen the requirements as we see it fit. This is a good opportunity to correct the oversight, if it really was. |
||||||||||||||||||||||
|
||||||||||||||||||||||
If operator "UNLIKE" is supported, the bahavior of this oprtator MUST be the negation of the "LIKE" operator; i.e. | ||||||||||||||||||||||
sauliusg marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
an expression `(property UNLIKE "value")" must behave exactly as `(NOT (property LIKE "value"))`. | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
|
||||||||||||||||||||||
Examples: | ||||||||||||||||||||||
|
||||||||||||||||||||||
* `chemical_formula_anonymous CONTAINS "C2" AND chemical_formula_anonymous STARTS WITH "A2"` | ||||||||||||||||||||||
|
@@ -2188,7 +2202,13 @@ ValueOpRhs = Operator, Value ; | |||||||||||||||||||||
|
||||||||||||||||||||||
KnownOpRhs = IS, ( KNOWN | UNKNOWN ) ; | ||||||||||||||||||||||
|
||||||||||||||||||||||
FuzzyStringOpRhs = CONTAINS, String | STARTS, [ WITH ], String | ENDS, [ WITH ], String ; | ||||||||||||||||||||||
StringProperty = String | Property ; | ||||||||||||||||||||||
|
||||||||||||||||||||||
FuzzyStringOpRhs = CONTAINS, StringProperty | | ||||||||||||||||||||||
STARTS, [ WITH ], StringProperty | | ||||||||||||||||||||||
ENDS, [ WITH ], StringProperty | | ||||||||||||||||||||||
MATCH, ( RegularExpression | StringProperty ) | | ||||||||||||||||||||||
NOT, MATCH, ( RegularExpression | StringProperty ) ; | ||||||||||||||||||||||
|
||||||||||||||||||||||
SetOpRhs = HAS, ( [ Operator ], Value | ALL, ValueList | ANY, ValueList | ONLY, ValueList ) ; | ||||||||||||||||||||||
(* Note: support for ONLY in SetOpRhs is OPTIONAL *) | ||||||||||||||||||||||
|
@@ -2236,6 +2256,8 @@ ALL = 'A', 'L', 'L', [Spaces] ; | |||||||||||||||||||||
ONLY = 'O', 'N', 'L', 'Y', [Spaces] ; | ||||||||||||||||||||||
ANY = 'A', 'N', 'Y', [Spaces] ; | ||||||||||||||||||||||
|
||||||||||||||||||||||
MATCH = 'M', 'A', 'T', 'C', 'H', [Spaces]; | ||||||||||||||||||||||
|
||||||||||||||||||||||
(* OperatorComparison operator tokens: *) | ||||||||||||||||||||||
|
||||||||||||||||||||||
Operator = ( '<', [ '=' ] | '>', [ '=' ] | '=' | '!', '=' ), [Spaces] ; | ||||||||||||||||||||||
|
@@ -2262,16 +2284,34 @@ LowercaseLetter = | |||||||||||||||||||||
|
||||||||||||||||||||||
String = '"', { EscapedChar }, '"', [Spaces] ; | ||||||||||||||||||||||
|
||||||||||||||||||||||
EscapedChar = UnescapedChar | '\', '"' | '\', '\' ; | ||||||||||||||||||||||
UnescapedChar = Letter | Digit | Space | '/' | | ||||||||||||||||||||||
Punctuator | RegexpMetacharacter | | ||||||||||||||||||||||
UnicodeHighChar ; | ||||||||||||||||||||||
|
||||||||||||||||||||||
UnescapedChar = Letter | Digit | Space | Punctuator | UnicodeHighChar ; | ||||||||||||||||||||||
EscapedChar = UnescapedChar | '\', '"' | '\', '\' ; | ||||||||||||||||||||||
|
||||||||||||||||||||||
Punctuator = | ||||||||||||||||||||||
'!' | '#' | '$' | '%' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | | ||||||||||||||||||||||
'-' | '.' | '/' | ':' | ';' | '<' | '=' | '>' | '?' | '@' | '[' | | ||||||||||||||||||||||
']' | '^' | '`' | '{' | '|' | '}' | '~' | ||||||||||||||||||||||
'!' | '#' | '%' | '&' | "'" | ',' | | ||||||||||||||||||||||
'-' | ':' | ';' | '<' | '=' | '>' | '@' | | ||||||||||||||||||||||
'`' | '~' | ||||||||||||||||||||||
; | ||||||||||||||||||||||
|
||||||||||||||||||||||
RegexpMetacharacter = | ||||||||||||||||||||||
'(' | ')' | '[' | ']' | '+' | '*' | '?' | '.' | '{' | '}' | | ||||||||||||||||||||||
'|' | '^' | '$' | ||||||||||||||||||||||
; | ||||||||||||||||||||||
|
||||||||||||||||||||||
(* Regular expressions: *) | ||||||||||||||||||||||
|
||||||||||||||||||||||
UnescapedREChar = Letter | Digit | Space | '"' | | ||||||||||||||||||||||
Punctuator | RegexpMetacharacter | | ||||||||||||||||||||||
UnicodeHighChar ; | ||||||||||||||||||||||
|
||||||||||||||||||||||
EscapedREChar = UnescapedREChar | '\', '/' | '\', '\' | | ||||||||||||||||||||||
'\', RegexpMetacharacter ; | ||||||||||||||||||||||
|
||||||||||||||||||||||
RegularExpression = '/', { EscapedREChar }, '/', [Spaces] ; | ||||||||||||||||||||||
|
||||||||||||||||||||||
(* BEGIN EBNF GRAMMAR Number *) | ||||||||||||||||||||||
(* Number token syntax: *) | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
chemical_formula LIKE "H2 O2" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Filter_001.opt |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
chemical_formula NOT LIKE "C6 H12 O6" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Filter_001.opt |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
chemical_formula UNLIKE "C6 H12 O6" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Filter_001.opt |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
property MATCH /"^.?abc+[a-z0-9]*$"/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Filter_001.opt |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
property MATCH "\"^.?abc+[a-z0-9]\\*$\"" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Filter_001.opt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.