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

Respecting key types for after and before comparisons #926

Merged

Conversation

luizalfredo23
Copy link
Contributor

Hello guys,

I'm trying to use the Java Time prototypes, but I've found a problem when using ERXKey after and before methods.

These methods are implemented to always compare the key type with NSTimeStamp, so when changed de key type from NSTimeStamp to LocalDateTime, for example, the implementation blocked me from that.

When talking to @hprange about this problem he realized another problem, any type could be compared to NSTimeStamp, for instance:

Person.country.after(date)

Even though the code above compiles, it throws an exception in runtime.

This pull request would make the two methods more flexible and ensure the compared value types are always compatible.

@paulhoadley
Copy link
Contributor

I like this. I take it that it's backwards compatible, in that there's no behaviour change if you are supplying an NSTimestamp? Also, does this make these two methods just synonyms now for greaterThan() and lessThan()?

@hprange
Copy link
Contributor

hprange commented Jan 21, 2020

I take it that it's backwards compatible, in that there's no behaviour change if you are supplying an NSTimestamp?

Yes, it is as long as it has been used correctly. In other words, only with attributes of type NSTimestamp. Any code where the attribute type is not compatible with NSTimestamp will now fail at compile time. Before this change, they would fail in runtime only.

Also, does this make these two methods just synonyms now for greaterThan() and lessThan()?

Yes, in the end, they're aliases that sound better for dates.

@darkv darkv merged commit 1d08aea into wocommunity:master Feb 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants