From 669992bc9c3782b46eea11bb1e21e813908f4de7 Mon Sep 17 00:00:00 2001 From: Adam Kirk Date: Wed, 20 Feb 2019 21:42:45 -0700 Subject: [PATCH] add insert or coding function --- Sources/SQLite/Typed/Coding.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sources/SQLite/Typed/Coding.swift b/Sources/SQLite/Typed/Coding.swift index c3fb931b..585643fb 100644 --- a/Sources/SQLite/Typed/Coding.swift +++ b/Sources/SQLite/Typed/Coding.swift @@ -44,7 +44,13 @@ extension QueryType { try encodable.encode(to: encoder) return self.insert(encoder.setters + otherSetters) } - + + public func insert(or: OnConflict, _ encodable: Encodable, userInfo: [CodingUserInfoKey:Any] = [:], otherSetters: [Setter] = []) throws -> Insert { + let encoder = SQLiteEncoder(userInfo: userInfo) + try encodable.encode(to: encoder) + return self.insert(or: or, encoder.setters + otherSetters) + } + /// Creates an `UPDATE` statement by encoding the given object /// This method converts any custom nested types to JSON data and does not handle any sort /// of object relationships. If you want to support relationships between objects you will