|
| 1 | +public enum FluentPostgreSQLQueryStatement: FluentSQLQueryStatement { |
| 2 | + public static var insert: FluentPostgreSQLQueryStatement { return ._insert } |
| 3 | + public static var select: FluentPostgreSQLQueryStatement { return ._select } |
| 4 | + public static var update: FluentPostgreSQLQueryStatement { return ._update } |
| 5 | + public static var delete: FluentPostgreSQLQueryStatement { return ._delete } |
| 6 | + |
| 7 | + public var isInsert: Bool { |
| 8 | + switch self { |
| 9 | + case ._insert: return true |
| 10 | + default: return false |
| 11 | + } |
| 12 | + } |
| 13 | + |
| 14 | + case _insert |
| 15 | + case _select |
| 16 | + case _update |
| 17 | + case _delete |
| 18 | +} |
| 19 | + |
| 20 | +public struct FluentPostgreSQLQuery: FluentSQLQuery { |
| 21 | + public typealias Statement = FluentPostgreSQLQueryStatement |
| 22 | + public typealias TableIdentifier = PostgreSQLTableIdentifier |
| 23 | + public typealias Expression = PostgreSQLExpression |
| 24 | + public typealias SelectExpression = PostgreSQLSelectExpression |
| 25 | + public typealias Join = PostgreSQLJoin |
| 26 | + public typealias OrderBy = PostgreSQLOrderBy |
| 27 | + public typealias GroupBy = PostgreSQLGroupBy |
| 28 | + public typealias Upsert = PostgreSQLUpsert |
| 29 | + |
| 30 | + public var statement: Statement |
| 31 | + public var table: TableIdentifier |
| 32 | + public var keys: [SelectExpression] |
| 33 | + public var values: [String : Expression] |
| 34 | + public var joins: [Join] |
| 35 | + public var predicate: Expression? |
| 36 | + public var orderBy: [OrderBy] |
| 37 | + public var groupBy: [GroupBy] |
| 38 | + public var limit: Int? |
| 39 | + public var offset: Int? |
| 40 | + public var upsert: PostgreSQLUpsert? |
| 41 | + public var defaultBinaryOperator: PostgreSQLBinaryOperator |
| 42 | + |
| 43 | + public static func query(_ statement: Statement, _ table: TableIdentifier) -> FluentPostgreSQLQuery { |
| 44 | + return .init( |
| 45 | + statement: statement, |
| 46 | + table: table, |
| 47 | + keys: [], |
| 48 | + values: [:], |
| 49 | + joins: [], |
| 50 | + predicate: nil, |
| 51 | + orderBy: [], |
| 52 | + groupBy: [], |
| 53 | + limit: nil, |
| 54 | + offset: nil, |
| 55 | + upsert: nil, |
| 56 | + defaultBinaryOperator: .and |
| 57 | + ) |
| 58 | + } |
| 59 | +} |
0 commit comments