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

Changed query comparison operators paths to KeyPath #360

Merged
merged 2 commits into from Jan 31, 2018

Conversation

Projects
None yet
3 participants
@calebkleveter
Copy link
Member

calebkleveter commented Jan 22, 2018

This PR modifies the query comparison operator argument types:

public func == <Model, Value>(lhs: KeyPath<Model, Value>, rhs: Value) -> ModelFilterMethod<Model>
public func == <Model, Value>(lhs: KeyPath<Model, Value?>, rhs: Value) -> ModelFilterMethod<Model>
public func != <Model, Value>(lhs: KeyPath<Model, Value>, rhs: Value) -> ModelFilterMethod<Model>

By changing ReferenceWritableKeyPath for KeyPath, we can compare constant, as well as variable model properties. Previously, trying to use the operator with a constant would result in an error something like this:

Binary operator '==' cannot be applied to operands of type 'KeyPath<Model, String>' and 'String'
@twof

This comment has been minimized.

Copy link
Member

twof commented Jan 22, 2018

What was the reason for using ReferenceWritableKeyPath in the first place?

@calebkleveter

This comment has been minimized.

Copy link
Member Author

calebkleveter commented Jan 22, 2018

No idea. @tanner0101 was open to the idea of changing it when we discussed it on Slack, so I decided a PR would be nice.

@tanner0101 tanner0101 added this to the 3.0.0 milestone Jan 22, 2018

@tanner0101 tanner0101 self-assigned this Jan 22, 2018

@tanner0101 tanner0101 merged commit 2647b3f into vapor:beta Jan 31, 2018

1 check failed

ci/circleci: linux Your tests failed on CircleCI
Details

@tanner0101 tanner0101 added this to Done in Vapor 3 Feb 12, 2018

@calebkleveter calebkleveter deleted the calebkleveter:remove-writable-key-comperison-query branch Mar 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment