Skip to content
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

Contact queries with explicit property types part 1 #1252

Merged
merged 2 commits into from
May 15, 2024

Conversation

rowanseymour
Copy link
Member

This adds support for parsing property conditions like fields.age > 34 and urns.tel != "".

Note that it doesn't normalize queries to look like that - that comes in separate push otherwise there's risk of one mailroom instance creating queries the other can't parse.

Copy link

codecov bot commented May 14, 2024

Codecov Report

Attention: Patch coverage is 99.51220% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 81.45%. Comparing base (5646549) to head (f14cd0e).

Files Patch % Lines
antlr/gen/contactql/contactql_parser.go 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1252      +/-   ##
==========================================
+ Coverage   81.42%   81.45%   +0.02%     
==========================================
  Files         278      278              
  Lines       14620    14642      +22     
==========================================
+ Hits        11905    11927      +22     
  Misses       2148     2148              
  Partials      567      567              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -5,6 +5,8 @@ import LexUnicode;
// Lexer rules
fragment HAS: [Hh][Aa][Ss];
fragment IS: [Ii][Ss];
fragment PROPTYPE: (UnicodeLetter)+;
fragment PROPKEY: (UnicodeLetter | UnicodeDigit | '_')+;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could make this stuff stricter but it's actually easier to deal with errors higher up in the parser rather in the lexer

@@ -21,6 +21,7 @@ const (
ErrUnsupportedContains = "unsupported_contains" // `property` the property key
ErrUnsupportedComparison = "unsupported_comparison" // `property` the property key, `operator` one of =>, <, >=, <=
ErrUnsupportedSetCheck = "unsupported_setcheck" // `property` the property key, `operator` one of =, !=
ErrUnknownPropertyType = "unknown_property_type" // `type` the property type
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to add support for this on RP side where we turn these into readable error messages

if err != nil {
return NewQueryError(ErrInvalidLanguage, "'%s' is not a valid language code", c.value).withExtra("value", c.value)
// for some text attributes, do some additional validation
if c.propType == PropertyTypeAttribute {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

little bit of reorg here so that if you have a field called language.. we don't enforce that the value is valid language code etc

@rowanseymour rowanseymour merged commit 4e0a37b into main May 15, 2024
7 checks passed
@rowanseymour rowanseymour deleted the contactql_prefixes branch May 15, 2024 14:57
@github-actions github-actions bot locked and limited conversation to collaborators May 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants