 }
 
 extension SQLStatement: SQLStatementConvertible {
+    /// Returns `self`.
     public var sqlStatement: SQLStatement {
         return self
     }


import Foundation

public protocol SQLStatementConvertible {
    var sqlStatement: SQLStatement { get }
}

public struct SQLStatement {
    public enum Segment {
        case raw (String)
        case parameter (SQLValue?)

}

extension SQLStatement {
    /// Appends raw SQL in a string to the statement.
    public mutating func append(raw sql: String) {
        append(SQLStatement(raw: sql))
    }
    
    /// Appends a safely-passed parameter to the statement.
    public mutating func append(parameter value: SQLValue?) {
        append(SQLStatement(parameter: value))
    }
    
    /// Returns the concatenation of `self` and the statement created by `other`.
    public func appending(_ other: SQLStatementConvertible) -> SQLStatement {
        var copy = self
        copy.append(other)
        return copy
    }
    
    /// Returns the concatenation of `self` and the raw SQL in the string. 
    public func appending(raw sql: String) -> SQLStatement {
        var copy = self
        copy.append(raw: sql)
        return copy
    }
    
    // Returns the concatenation of `self` and the safely-passed parameter. 
    public func appending(parameter value: SQLValue?) -> SQLStatement {
        var copy = self
        copy.append(parameter: value)
        return copy
    }
}

/// Appends another `SQLStatement` or convertible instance to a `SQLStatement`.  
public func += (lhs: inout SQLStatement, rhs: SQLStatementConvertible) {
    lhs.append(rhs)
}

/// Returns the concatenation of two `SQLStatement`s or convertible instances.
public func + (lhs: SQLStatementConvertible, rhs: SQLStatementConvertible) -> SQLStatement {
    var statement = SQLStatement(lhs)
    statement += rhs
