Skip to content

Commit

Permalink
sql joins list fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 committed Oct 10, 2019
1 parent 354c843 commit 510b23e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions Sources/SQLKit/Query/SQLList.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
public struct SQLList: SQLExpression {
public let expressions: [SQLExpression]

public init(_ expressions: [SQLExpression]) {
public let separator: SQLExpression

public init(_ expressions: [SQLExpression], separator: SQLExpression = SQLRaw(", ")) {
self.expressions = expressions
self.separator = separator
}

public func serialize(to serializer: inout SQLSerializer) {
var first = true
for el in self.expressions {
if !first {
serializer.write(", ")
self.separator.serialize(to: &serializer)
}
first = false
el.serialize(to: &serializer)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SQLKit/Query/SQLSelect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public struct SQLSelect: SQLExpression {
SQLList(self.tables).serialize(to: &serializer)
if !self.joins.isEmpty {
serializer.write(" ")
SQLList(self.joins).serialize(to: &serializer)
SQLList(self.joins, separator: SQLRaw(" ")).serialize(to: &serializer)
}
if let predicate = self.predicate {
serializer.write(" WHERE ")
Expand Down

0 comments on commit 510b23e

Please sign in to comment.