Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Allow parameterized queries on RawSQLBuilder #79

Merged
merged 1 commit into from
Oct 16, 2019
Merged

Allow parameterized queries on RawSQLBuilder #79

merged 1 commit into from
Oct 16, 2019

Conversation

madsodgaard
Copy link
Contributor

This PR adds functionality to call .binds and .bind on a RawSQLBuilder object in order to support parameterized queries.

@madsodgaard
Copy link
Contributor Author

@steffendsommer Do you have time to take a look? 😄

@@ -34,6 +34,18 @@ public class RawSQLBuilder<Database, Result> where

self.sqlRawCountBuilder = connection.raw(countQuery)
}

public func bind(_ encodable: Encodable) -> Self {
_ = sqlRawBuilder.bind(encodable)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the _ = be avoided? Otherwise LGTM

Copy link
Contributor

Choose a reason for hiding this comment

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

I just looked at it and it's just because bind on SQLRawBuilder is defined as public func bind(_ encodable: Encodable) -> Self {. It could be avoided like this:

    public func bind(_ encodable: Encodable) -> Self {
        sqlRawBuilder.binds.append(encodable)
        sqlRawCountBuilder?.binds.append(encodable)
        return self
    }

But that's really doing the same thing. So 👍 from me too 🙂

@steffendsommer steffendsommer merged commit 1e3394e into ml-archive:master Oct 16, 2019
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.

3 participants