-
Notifications
You must be signed in to change notification settings - Fork 38
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
SearchCriteriaBetween fails when using a DateTime value #524
Comments
I confirm that I can reproduce the problem. In fact, I just realized that the problem occurs whenever you use a DateTime value regardless of the search operator (in other words, it's not specific to the Here's the snippet I used to reproduce: var modifiedDuringPriorYearCriteria = new SearchCriteriaGreaterThan(ContactsFilterField.ModifiedOn, DateTime.UtcNow.AddYears(-1));
var contactsModifiedDuringPriorYearResult = await client.Contacts.SearchAsync(modifiedDuringPriorYearCriteria, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Found {contactsModifiedDuringPriorYearResult.Length} contacts modified during the last year").ConfigureAwait(false); I should have a fix shortly. |
Quick update: If I simply modify our library to add the "TIMESTAMP" keyword, it will fix v1 queries but it will break v2 queries. Which means that I need to figure out a way handle DateTime differently depending on the query language version. All this to say that the fix will not be as simple as I originally thought. That's the bad news. The good news is that there's a temporary workaround for you while you wait for me to fix the problem: you can manually craft you own query expressed as a string when invoking the var myQuery = "last_event_time BETWEEN TIMESTAMP \"2024-06-17T00:00:00.000Z\" AND TIMESTAMP \"2024-06-18T00:00:00.000Z\"";
var searchResult = await client.Contacts.SearchAsync(myQuery, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Found {searchResult.Length} contacts").ConfigureAwait(false); Let me know if this helps. |
Thanks for the update, I was unaware of the ability to pass a string to SearchAsync. FYI I am calling |
This is how developers can specify advanced queries with features that StrongGrid doesn't support such as, for example, using some built-in functions like 'lower()'.
Both searching for contacts and email activities use "old" v1 queries. That's why I was able to reproduce the problem by invoking
Very clever! Hopefully, this will be made obsolete by the improvement I'm working on. |
I published a beta package to my personal NuGet feed called |
It just occurred to me that the workaround I suggested earlier won't work in your situation. I added The fix I'm working on (which you're able to beta test) renders this a moot point but I should raise a new issue to add this enhancement to the EmailActivities resource. |
I've tested 0.109.0 and it works for my scenario. Thanks for the quick update. |
🎉 This issue has been resolved in version 0.109.0 🎉 The release is available on: Your GitReleaseManager bot 📦🚀 |
Excellent. Thank you for confirming. I've published v0.109.0 to NuGet. It includes not only the fix for this issue but also the improvement discussed in #527 which allows you to provide your own queries as a string in case you ever need to utilize a feature of SendGrid's query engine that StrongGrid does not support. |
Thanks, we've updated and everything works great. I had my boss toss $500 your way for the excellent support. https://github.com/ken-swyfft
…________________________________
From: Jericho ***@***.***>
Sent: Friday, June 21, 2024 12:01 PM
To: Jericho/StrongGrid ***@***.***>
Cc: Wayne Allen ***@***.***>; Author ***@***.***>
Subject: Re: [Jericho/StrongGrid] SearchCriteriaBetween fails when using a DateTime value (Issue #524)
Excellent. Thank you for confirming. I've published v0.109.0 to NuGet. It includes not only the fix for this issue but also the improvement discussed in #527<#527> which allows you to provide your own queries as a string in case you ever need to utilize a feature of SendGrid's query engine that StrongGrid does not support.
—
Reply to this email directly, view it on GitHub<#524 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/APSIASE3BLV5AZUURFK2S3DZIRZ77AVCNFSM6AAAAABJQ3DJGKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBTGI4TQNRUGY>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
Disclaimer
The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.
This email has been scanned for viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business. Providing a safer and more useful place for your human generated data. Specializing in; Security, archiving and compliance. To find out more visit the Mimecast website.
|
I sent him a quick note to thank him for the sponsorship. Thank you for advocating for me! Don't hesitate to reach out if you need anything (new feature, fix, general question, etc.). |
Using
SearchCriteriaBetween
you end up with a query likelast_event_time BETWEEN "2024-06-17T00:00:00.000Z" AND "2024-06-18T00:00:00.000Z"
Which results in the error message -
operator >= is incompatible with DATETIME, STRING
The query needs to look like
last_event_time BETWEEN TIMESTAMP "2024-06-17T00:00:00.000Z" AND TIMESTAMP "2024-06-18T00:00:00.000Z"
The text was updated successfully, but these errors were encountered: