Skip to content

Commit

Permalink
bind value to avoid possibility of sql injection
Browse files Browse the repository at this point in the history
  • Loading branch information
rausnitz committed Feb 23, 2019
1 parent f68e3d5 commit 703ccb0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Sources/FluentSQL/SQL+QuerySupporting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ extension QuerySupporting where
QueryKey.Expression == QueryKey.Expression.Function.Argument.Expression
{
/// See `QuerySupporting`.
public static func queryAggregate<D>(_ name: QueryAggregate, _ fields: [QueryKey], default: D) -> QueryKey
where D: Decodable
public static func queryAggregate<C>(_ name: QueryAggregate, _ fields: [QueryKey], default: C) -> QueryKey
where C: Codable
{
let args: [QueryKey.Expression.Function.Argument] = fields.compactMap { expr in
if expr.isAll {
Expand All @@ -170,8 +170,7 @@ extension QuerySupporting where
return nil
}
}

return .expression(.coalesce(.function(.function(name, args)), .literal(.numeric(String(describing: `default`)))), alias: .identifier("fluentAggregate"))
return .expression(.coalesce(.function(.function(name, args)), .bind(.encodable(`default`))), alias: .identifier("fluentAggregate"))
}

/// See `QuerySupporting`.
Expand Down

0 comments on commit 703ccb0

Please sign in to comment.