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

Contains in Queries does not work with optionals. #329

Closed
proggeramlug opened this issue Jun 16, 2020 · 0 comments · Fixed by #349
Closed

Contains in Queries does not work with optionals. #329

proggeramlug opened this issue Jun 16, 2020 · 0 comments · Fixed by #349
Labels
bug Something isn't working

Comments

@proggeramlug
Copy link
Contributor

proggeramlug commented Jun 16, 2020

I'm passing a String (non-optional) into a query like:

let name: String = "test"
query.filter(\.$name ~~ name)

and I'm getting:

Fatal error: Only string binds are supported with contains.

The fix (not the best probably) for me right now is this:

extension Optional: CustomStringConvertible where Wrapped == String {
    public var description: String {
        return self ?? ""
    }
}

However, I'm wondering why there is an Optional<String> in the function at all, I'm passing a String. https://github.com/vapor/fluent-kit/blob/master/Sources/FluentSQL/SQLQueryConverter.swift#L248

@tanner0101 tanner0101 added the bug Something isn't working label Jul 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants