From 140374a1f25df9a50c9e014679844bb2de70542d Mon Sep 17 00:00:00 2001 From: Geoff MacDonald Date: Fri, 30 Apr 2021 11:09:45 -0700 Subject: [PATCH 01/11] implement batch insert, insertMany() --- Sources/SQLite/Typed/Coding.swift | 25 +++++++++++++++++++- Sources/SQLite/Typed/Query.swift | 37 ++++++++++++++++++++++++++++++ Tests/SQLiteTests/QueryTests.swift | 37 ++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) diff --git a/Sources/SQLite/Typed/Coding.swift b/Sources/SQLite/Typed/Coding.swift index c3fb931b..34edbc49 100644 --- a/Sources/SQLite/Typed/Coding.swift +++ b/Sources/SQLite/Typed/Coding.swift @@ -38,13 +38,36 @@ extension QueryType { /// /// - otherSetters: Any other setters to include in the insert /// - /// - Returns: An `INSERT` statement fort the encodable object + /// - Returns: An `INSERT` statement for the encodable object public func insert(_ encodable: Encodable, userInfo: [CodingUserInfoKey:Any] = [:], otherSetters: [Setter] = []) throws -> Insert { let encoder = SQLiteEncoder(userInfo: userInfo) try encodable.encode(to: encoder) return self.insert(encoder.setters + otherSetters) } + /// Creates a batch `INSERT` statement by encoding the array of given objects + /// 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 + /// have to provide your own Encodable implementations that encode the correct ids. + /// + /// - Parameters: + /// + /// - encodables: Encodable objects to insert + /// + /// - userInfo: User info to be passed to encoder + /// + /// - otherSetters: Any other setters to include in the inserts, per row/object. + /// + /// - Returns: An `INSERT` statement for the encodable objects + public func insertMany(_ encodables: [Encodable], userInfo: [CodingUserInfoKey:Any] = [:], otherSetters: [Setter] = []) throws -> Insert { + let combinedSetters = try encodables.map { encodable -> [Setter] in + let encoder = SQLiteEncoder(userInfo: userInfo) + try encodable.encode(to: encoder) + return encoder.setters + otherSetters + } + return self.insertMany(combinedSetters) + } + /// 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 diff --git a/Sources/SQLite/Typed/Query.swift b/Sources/SQLite/Typed/Query.swift index f6ef6df8..61deaa1f 100644 --- a/Sources/SQLite/Typed/Query.swift +++ b/Sources/SQLite/Typed/Query.swift @@ -631,6 +631,18 @@ extension QueryType { return insert(onConflict, values) } + public func insertMany( _ values: [[Setter]]) -> Insert { + return insertMany(nil, values) + } + + public func insertMany(or onConflict: OnConflict, _ values: [[Setter]]) -> Insert { + return insertMany(onConflict, values) + } + + public func insertMany(or onConflict: OnConflict, _ values: [Setter]...) -> Insert { + return insertMany(onConflict, values) + } + fileprivate func insert(_ or: OnConflict?, _ values: [Setter]) -> Insert { let insert = values.reduce((columns: [Expressible](), values: [Expressible]())) { insert, setter in (insert.columns + [setter.column], insert.values + [setter.value]) @@ -650,6 +662,29 @@ extension QueryType { return Insert(" ".join(clauses.compactMap { $0 }).expression) } + fileprivate func insertMany(_ or: OnConflict?, _ values: [[Setter]]) -> Insert { + guard values.count > 0 else { + return insert() + } + let insertRows = values.map { rowValues in + rowValues.reduce((columns: [Expressible](), values: [Expressible]())) { insert, setter in + (insert.columns + [setter.column], insert.values + [setter.value]) + } + } + + let clauses: [Expressible?] = [ + Expression(literal: "INSERT"), + or.map { Expression(literal: "OR \($0.rawValue)") }, + Expression(literal: "INTO"), + tableName(), + "".wrap(insertRows[0].columns) as Expression, + Expression(literal: "VALUES"), + ", ".join(insertRows.map(\.values).map({ "".wrap($0) as Expression })), + whereClause + ] + return Insert(" ".join(clauses.compactMap { $0 }).expression) + } + /// Runs an `INSERT` statement against the query with `DEFAULT VALUES`. public func insert() -> Insert { return Insert(" ".join([ @@ -1010,6 +1045,8 @@ extension Connection { /// - SeeAlso: `QueryType.insert(value:_:)` /// - SeeAlso: `QueryType.insert(values:)` /// - SeeAlso: `QueryType.insert(or:_:)` + /// - SeeAlso: `QueryType.insertMany(values:)` + /// - SeeAlso: `QueryType.insertMany(or:_:)` /// - SeeAlso: `QueryType.insert()` /// /// - Parameter query: An insert query. diff --git a/Tests/SQLiteTests/QueryTests.swift b/Tests/SQLiteTests/QueryTests.swift index 2a9e4ecb..f48f49b9 100644 --- a/Tests/SQLiteTests/QueryTests.swift +++ b/Tests/SQLiteTests/QueryTests.swift @@ -247,6 +247,26 @@ class QueryTests : XCTestCase { ) } + func test_insert_many_compilesInsertManyExpression() { + AssertSQL( + "INSERT INTO \"users\" (\"email\", \"age\") VALUES ('alice@example.com', 30), ('geoff@example.com', 32), ('alex@example.com', 83)", + users.insertMany([[email <- "alice@example.com", age <- 30], [email <- "geoff@example.com", age <- 32], [email <- "alex@example.com", age <- 83]]) + ) + } + func test_insert_many_compilesInsertManyNoneExpression() { + AssertSQL( + "INSERT INTO \"users\" DEFAULT VALUES", + users.insertMany([]) + ) + } + + func test_insert_many_withOnConflict_compilesInsertManyOrOnConflictExpression() { + AssertSQL( + "INSERT OR REPLACE INTO \"users\" (\"email\", \"age\") VALUES ('alice@example.com', 30), ('geoff@example.com', 32), ('alex@example.com', 83)", + users.insertMany(or: .replace, [[email <- "alice@example.com", age <- 30], [email <- "geoff@example.com", age <- 32], [email <- "alex@example.com", age <- 83]]) + ) + } + func test_insert_encodable() throws { let emails = Table("emails") let value = TestCodable(int: 1, string: "2", bool: true, float: 3, double: 4, optional: nil, sub: nil) @@ -270,6 +290,18 @@ class QueryTests : XCTestCase { ) } + func test_insert_many_encodable() throws { + let emails = Table("emails") + let value1 = TestCodable(int: 1, string: "2", bool: true, float: 3, double: 4, optional: nil, sub: nil) + let value2 = TestCodable(int: 2, string: "3", bool: true, float: 3, double: 5, optional: nil, sub: nil) + let value3 = TestCodable(int: 3, string: "4", bool: true, float: 3, double: 6, optional: nil, sub: nil) + let insert = try emails.insertMany([value1, value2, value3]) + AssertSQL( + "INSERT INTO \"emails\" (\"int\", \"string\", \"bool\", \"float\", \"double\") VALUES (1, '2', 1, 3.0, 4.0), (2, '3', 1, 3.0, 5.0), (3, '4', 1, 3.0, 6.0)", + insert + ) + } + func test_update_compilesUpdateExpression() { AssertSQL( "UPDATE \"users\" SET \"age\" = 30, \"admin\" = 1 WHERE (\"id\" = 1)", @@ -483,6 +515,11 @@ class QueryIntegrationTests : SQLiteTestCase { XCTAssertEqual(1, id) } + func test_insert_many() { + let id = try! db.run(users.insertMany([[email <- "alice@example.com"], [email <- "geoff@example.com"]])) + XCTAssertEqual(2, id) + } + func test_update() { let changes = try! db.run(users.update(email <- "alice@example.com")) XCTAssertEqual(0, changes) From 087264792a7c75c446106ef4090d9fd669b37e8a Mon Sep 17 00:00:00 2001 From: Geoff MacDonald Date: Fri, 30 Apr 2021 11:27:42 -0700 Subject: [PATCH 02/11] Update Index.md --- Documentation/Index.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/Index.md b/Documentation/Index.md index 70d67c2d..2f441c8c 100644 --- a/Documentation/Index.md +++ b/Documentation/Index.md @@ -638,6 +638,18 @@ do { } ``` +Multiple rows can be inserted at once by similarily calling `insertMany` with an array of per-row [setters](#setters). + +```swift +do { + let rowid = try db.run(users.insertMany([mail <- "alice@mac.com"], [email <- "geoff@mac.com"])) + print("inserted id: \(rowid)") +} catch { + print("insertion failed: \(error)") +} +``` + + The [`update`](#updating-rows) and [`delete`](#deleting-rows) functions follow similar patterns. From 05c404fcec8df8043d68d38617a9c69f54772f50 Mon Sep 17 00:00:00 2001 From: Geoff MacDonald Date: Fri, 30 Apr 2021 11:37:22 -0700 Subject: [PATCH 03/11] cleanup sql creation --- Sources/SQLite/Typed/Query.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Sources/SQLite/Typed/Query.swift b/Sources/SQLite/Typed/Query.swift index 61deaa1f..54e44fa5 100644 --- a/Sources/SQLite/Typed/Query.swift +++ b/Sources/SQLite/Typed/Query.swift @@ -663,12 +663,14 @@ extension QueryType { } fileprivate func insertMany(_ or: OnConflict?, _ values: [[Setter]]) -> Insert { - guard values.count > 0 else { + guard let firstInsert = values.first else { + // must be at least 1 object or else we don't know columns. Default to default inserts. return insert() } - let insertRows = values.map { rowValues in - rowValues.reduce((columns: [Expressible](), values: [Expressible]())) { insert, setter in - (insert.columns + [setter.column], insert.values + [setter.value]) + let columns = firstInsert.map { $0.column } + let insertValues = values.map { rowValues in + rowValues.reduce([Expressible]()) { insert, setter in + insert + [setter.value] } } @@ -677,9 +679,9 @@ extension QueryType { or.map { Expression(literal: "OR \($0.rawValue)") }, Expression(literal: "INTO"), tableName(), - "".wrap(insertRows[0].columns) as Expression, + "".wrap(columns) as Expression, Expression(literal: "VALUES"), - ", ".join(insertRows.map(\.values).map({ "".wrap($0) as Expression })), + ", ".join(insertValues.map({ "".wrap($0) as Expression })), whereClause ] return Insert(" ".join(clauses.compactMap { $0 }).expression) From 4fde8dba065b213ae0a5a067a1d8d31680091b5a Mon Sep 17 00:00:00 2001 From: Geoff MacDonald Date: Fri, 30 Apr 2021 14:52:52 -0700 Subject: [PATCH 04/11] try and fix travis? --- .travis.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index c8fc5feb..ea60b063 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,11 @@ language: objective-c -rvm: 2.3 +rvm: 2.7.3 # https://docs.travis-ci.com/user/reference/osx -osx_image: xcode10.2 +osx_image: xcode12.2 env: global: - - IOS_SIMULATOR="iPhone XS" - - IOS_VERSION="12.2" + - IOS_SIMULATOR="iPhone 11" + - IOS_VERSION="14.2" matrix: include: - env: BUILD_SCHEME="SQLite iOS" @@ -25,7 +25,4 @@ before_install: - brew update - brew outdated carthage || brew upgrade carthage script: -# Workaround for Xcode 10.2/tvOS 9.1 bug -# See https://stackoverflow.com/questions/55389080/xcode-10-2-failed-to-run-app-on-simulator-with-ios-10 - - sudo mkdir /Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS\ 9.1.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift - ./run-tests.sh From 183a43948f40637643c15e6e19a4b983d2df8325 Mon Sep 17 00:00:00 2001 From: Geoff MacDonald Date: Fri, 30 Apr 2021 15:32:43 -0700 Subject: [PATCH 05/11] Update Planning.md --- Documentation/Planning.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/Documentation/Planning.md b/Documentation/Planning.md index 5f885de8..62df1f24 100644 --- a/Documentation/Planning.md +++ b/Documentation/Planning.md @@ -33,6 +33,3 @@ be referred to when it comes time to add the corresponding feature._ _Features that are not actively being considered, perhaps because of no clean type-safe way to implement them with the current Swift, or bugs, or just general uncertainty._ - - * provide a mechanism for INSERT INTO multiple values, per - [#168](https://github.com/stephencelis/SQLite.swift/issues/168) From b260b0a4aa1754b609ac48c637578ef1cea0898c Mon Sep 17 00:00:00 2001 From: Geoff MacDonald Date: Fri, 30 Apr 2021 15:35:12 -0700 Subject: [PATCH 06/11] upgrade test deps to force it working --- .travis.yml | 2 +- Tests/CocoaPods/Gemfile.lock | 46 ++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index ea60b063..2a0460bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ matrix: - env: CARTHAGE_PLATFORM="tvOS" - env: PACKAGE_MANAGER_COMMAND="test" before_install: - - gem update bundler + - gem install bundler - gem install xcpretty --no-document - brew update - brew outdated carthage || brew upgrade carthage diff --git a/Tests/CocoaPods/Gemfile.lock b/Tests/CocoaPods/Gemfile.lock index b5172144..e5c53ea3 100644 --- a/Tests/CocoaPods/Gemfile.lock +++ b/Tests/CocoaPods/Gemfile.lock @@ -1,18 +1,18 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (3.0.0) - activesupport (4.2.11) + CFPropertyList (3.0.3) + activesupport (4.2.11.3) i18n (~> 0.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) atomos (0.1.3) - claide (1.0.2) - cocoapods (1.6.0.beta.2) + claide (1.0.3) + cocoapods (1.6.2) activesupport (>= 4.0.2, < 5) claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.6.0.beta.2) + cocoapods-core (= 1.6.2) cocoapods-deintegrate (>= 1.0.2, < 2.0) cocoapods-downloader (>= 1.2.2, < 2.0) cocoapods-plugins (>= 1.0.0, < 2.0) @@ -22,56 +22,56 @@ GEM cocoapods-try (>= 1.1.0, < 2.0) colored2 (~> 3.1) escape (~> 0.0.4) - fourflusher (~> 2.0.1) + fourflusher (>= 2.2.0, < 3.0) gh_inspector (~> 1.0) molinillo (~> 0.6.6) nap (~> 1.0) - ruby-macho (~> 1.3, >= 1.3.1) - xcodeproj (>= 1.7.0, < 2.0) - cocoapods-core (1.6.0.beta.2) + ruby-macho (~> 1.4) + xcodeproj (>= 1.8.1, < 2.0) + cocoapods-core (1.6.2) activesupport (>= 4.0.2, < 6) fuzzy_match (~> 2.0.4) nap (~> 1.0) - cocoapods-deintegrate (1.0.2) - cocoapods-downloader (1.2.2) + cocoapods-deintegrate (1.0.4) + cocoapods-downloader (1.4.0) cocoapods-plugins (1.0.0) nap cocoapods-search (1.0.0) - cocoapods-stats (1.0.0) - cocoapods-trunk (1.3.1) + cocoapods-stats (1.1.0) + cocoapods-trunk (1.5.0) nap (>= 0.8, < 2.0) netrc (~> 0.11) - cocoapods-try (1.1.0) + cocoapods-try (1.2.0) colored2 (3.1.2) - concurrent-ruby (1.1.4) + concurrent-ruby (1.1.8) escape (0.0.4) - fourflusher (2.0.1) + fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) i18n (0.9.5) concurrent-ruby (~> 1.0) minitest (5.11.3) molinillo (0.6.6) - nanaimo (0.2.6) + nanaimo (0.3.0) nap (1.1.0) netrc (0.11.0) - ruby-macho (1.3.1) + ruby-macho (1.4.0) thread_safe (0.3.6) - tzinfo (1.2.5) + tzinfo (1.2.9) thread_safe (~> 0.1) - xcodeproj (1.7.0) + xcodeproj (1.19.0) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) colored2 (~> 3.1) - nanaimo (~> 0.2.6) + nanaimo (~> 0.3.0) PLATFORMS ruby DEPENDENCIES - cocoapods (~> 1.6.0beta2) + cocoapods (~> 1.6.1) minitest BUNDLED WITH - 1.17.1 + 1.17.2 From e40e3369c14319df540bbac476c419cfea20294e Mon Sep 17 00:00:00 2001 From: Geoff MacDonald Date: Fri, 30 Apr 2021 17:43:16 -0700 Subject: [PATCH 07/11] update deps --- Tests/CocoaPods/Gemfile | 2 +- Tests/CocoaPods/Gemfile.lock | 51 +++++++++++++++++++---------- Tests/CocoaPods/integration_test.rb | 2 +- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/Tests/CocoaPods/Gemfile b/Tests/CocoaPods/Gemfile index 77d90eec..19db2b36 100644 --- a/Tests/CocoaPods/Gemfile +++ b/Tests/CocoaPods/Gemfile @@ -1,4 +1,4 @@ source 'https://rubygems.org' -gem 'cocoapods', '~> 1.6.1' +gem 'cocoapods', '~> 1.10.1' gem 'minitest' diff --git a/Tests/CocoaPods/Gemfile.lock b/Tests/CocoaPods/Gemfile.lock index e5c53ea3..d99ac49a 100644 --- a/Tests/CocoaPods/Gemfile.lock +++ b/Tests/CocoaPods/Gemfile.lock @@ -2,42 +2,51 @@ GEM remote: https://rubygems.org/ specs: CFPropertyList (3.0.3) - activesupport (4.2.11.3) - i18n (~> 0.7) + activesupport (5.2.5) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + algoliasearch (1.27.5) + httpclient (~> 2.8, >= 2.8.3) + json (>= 1.5.1) atomos (0.1.3) claide (1.0.3) - cocoapods (1.6.2) - activesupport (>= 4.0.2, < 5) + cocoapods (1.10.1) + addressable (~> 2.6) claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.6.2) - cocoapods-deintegrate (>= 1.0.2, < 2.0) - cocoapods-downloader (>= 1.2.2, < 2.0) + cocoapods-core (= 1.10.1) + cocoapods-deintegrate (>= 1.0.3, < 2.0) + cocoapods-downloader (>= 1.4.0, < 2.0) cocoapods-plugins (>= 1.0.0, < 2.0) cocoapods-search (>= 1.0.0, < 2.0) - cocoapods-stats (>= 1.0.0, < 2.0) - cocoapods-trunk (>= 1.3.1, < 2.0) + cocoapods-trunk (>= 1.4.0, < 2.0) cocoapods-try (>= 1.1.0, < 2.0) colored2 (~> 3.1) escape (~> 0.0.4) - fourflusher (>= 2.2.0, < 3.0) + fourflusher (>= 2.3.0, < 3.0) gh_inspector (~> 1.0) molinillo (~> 0.6.6) nap (~> 1.0) ruby-macho (~> 1.4) - xcodeproj (>= 1.8.1, < 2.0) - cocoapods-core (1.6.2) - activesupport (>= 4.0.2, < 6) + xcodeproj (>= 1.19.0, < 2.0) + cocoapods-core (1.10.1) + activesupport (> 5.0, < 6) + addressable (~> 2.6) + algoliasearch (~> 1.0) + concurrent-ruby (~> 1.1) fuzzy_match (~> 2.0.4) nap (~> 1.0) + netrc (~> 0.11) + public_suffix + typhoeus (~> 1.0) cocoapods-deintegrate (1.0.4) cocoapods-downloader (1.4.0) cocoapods-plugins (1.0.0) nap cocoapods-search (1.0.0) - cocoapods-stats (1.1.0) cocoapods-trunk (1.5.0) nap (>= 0.8, < 2.0) netrc (~> 0.11) @@ -45,18 +54,26 @@ GEM colored2 (3.1.2) concurrent-ruby (1.1.8) escape (0.0.4) + ethon (0.14.0) + ffi (>= 1.15.0) + ffi (1.15.0) fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) - i18n (0.9.5) + httpclient (2.8.3) + i18n (1.8.10) concurrent-ruby (~> 1.0) + json (2.5.1) minitest (5.11.3) molinillo (0.6.6) nanaimo (0.3.0) nap (1.1.0) netrc (0.11.0) + public_suffix (4.0.6) ruby-macho (1.4.0) thread_safe (0.3.6) + typhoeus (1.4.0) + ethon (>= 0.9.0) tzinfo (1.2.9) thread_safe (~> 0.1) xcodeproj (1.19.0) @@ -70,7 +87,7 @@ PLATFORMS ruby DEPENDENCIES - cocoapods (~> 1.6.1) + cocoapods (~> 1.10.1) minitest BUNDLED WITH diff --git a/Tests/CocoaPods/integration_test.rb b/Tests/CocoaPods/integration_test.rb index 98a539b5..2ce2997c 100755 --- a/Tests/CocoaPods/integration_test.rb +++ b/Tests/CocoaPods/integration_test.rb @@ -40,7 +40,7 @@ def test_pod super unless consumer.platform_name == :watchos end - def xcodebuild(action, scheme, configuration) + def xcodebuild(action, scheme, configuration, _) require 'fourflusher' command = %W(#{action} -workspace #{File.join(validation_dir, 'App.xcworkspace')} -scheme #{scheme} -configuration #{configuration}) case consumer.platform_name From 0742ee04976029504502b6212b60462017519887 Mon Sep 17 00:00:00 2001 From: Geoff MacDonald Date: Fri, 30 Apr 2021 17:46:47 -0700 Subject: [PATCH 08/11] apparently carthage doesnt support xcode 12 out of box --- .travis.yml | 8 ++++---- Makefile | 2 +- Tests/Carthage/Makefile | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2a0460bb..b8b2eaba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,11 @@ language: objective-c rvm: 2.7.3 # https://docs.travis-ci.com/user/reference/osx -osx_image: xcode12.2 +osx_image: xcode11.6 env: global: - - IOS_SIMULATOR="iPhone 11" - - IOS_VERSION="14.2" + - IOS_SIMULATOR="iPhone XS" + - IOS_VERSION="13.6" matrix: include: - env: BUILD_SCHEME="SQLite iOS" @@ -20,7 +20,7 @@ matrix: - env: CARTHAGE_PLATFORM="tvOS" - env: PACKAGE_MANAGER_COMMAND="test" before_install: - - gem install bundler + - gem install bundler - gem install xcpretty --no-document - brew update - brew outdated carthage || brew upgrade carthage diff --git a/Makefile b/Makefile index 50d07148..b38b90e0 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ BUILD_TOOL = xcodebuild BUILD_SCHEME = SQLite Mac IOS_SIMULATOR = iPhone XS -IOS_VERSION = 12.2 +IOS_VERSION = 13.6 ifeq ($(BUILD_SCHEME),SQLite iOS) BUILD_ARGUMENTS = -scheme "$(BUILD_SCHEME)" -destination "platform=iOS Simulator,name=$(IOS_SIMULATOR),OS=$(IOS_VERSION)" else diff --git a/Tests/Carthage/Makefile b/Tests/Carthage/Makefile index f28eb25b..7f068985 100644 --- a/Tests/Carthage/Makefile +++ b/Tests/Carthage/Makefile @@ -3,7 +3,7 @@ CARTHAGE_PLATFORM := iOS CARTHAGE_CONFIGURATION := Release CARTHAGE_DIR := Carthage CARTHAGE_ARGS := --no-use-binaries -CARTHAGE_TOOLCHAIN := com.apple.dt.toolchain.Swift_3_0 +CARTHAGE_TOOLCHAIN := com.apple.dt.toolchain.XcodeDefault CARTHAGE_CMDLINE := --configuration $(CARTHAGE_CONFIGURATION) --platform $(CARTHAGE_PLATFORM) --toolchain $(CARTHAGE_TOOLCHAIN) $(CARTHAGE_ARGS) test: $(CARTHAGE) Cartfile From a78d8c4ae303c7d4875a29a01bc307e48095f7d6 Mon Sep 17 00:00:00 2001 From: Geoff MacDonald Date: Fri, 30 Apr 2021 18:04:29 -0700 Subject: [PATCH 09/11] try 2.6 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b8b2eaba..e9d5ec2a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -rvm: 2.7.3 +rvm: 2.6 # https://docs.travis-ci.com/user/reference/osx osx_image: xcode11.6 env: From 5052cbbd6d881396c87a9ede9de2e30a8f86a706 Mon Sep 17 00:00:00 2001 From: Geoff MacDonald Date: Fri, 30 Apr 2021 18:13:28 -0700 Subject: [PATCH 10/11] use iphone 11 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e9d5ec2a..7bff9ce2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ rvm: 2.6 osx_image: xcode11.6 env: global: - - IOS_SIMULATOR="iPhone XS" + - IOS_SIMULATOR="iPhone 11" - IOS_VERSION="13.6" matrix: include: From 75a177a688ada617cef0efbc910f2fc3bdfbd1ff Mon Sep 17 00:00:00 2001 From: Nathan Fallet Date: Sat, 21 Aug 2021 18:03:32 +0200 Subject: [PATCH 11/11] Fixed codable insert many --- Tests/SQLiteTests/QueryTests.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/SQLiteTests/QueryTests.swift b/Tests/SQLiteTests/QueryTests.swift index 9e6e9f7e..79e6871e 100644 --- a/Tests/SQLiteTests/QueryTests.swift +++ b/Tests/SQLiteTests/QueryTests.swift @@ -310,12 +310,12 @@ class QueryTests : XCTestCase { func test_insert_many_encodable() throws { let emails = Table("emails") - let value1 = TestCodable(int: 1, string: "2", bool: true, float: 3, double: 4, optional: nil, sub: nil) - let value2 = TestCodable(int: 2, string: "3", bool: true, float: 3, double: 5, optional: nil, sub: nil) - let value3 = TestCodable(int: 3, string: "4", bool: true, float: 3, double: 6, optional: nil, sub: nil) + let value1 = TestCodable(int: 1, string: "2", bool: true, float: 3, double: 4, date: Date(timeIntervalSince1970: 0), optional: nil, sub: nil) + let value2 = TestCodable(int: 2, string: "3", bool: true, float: 3, double: 5, date: Date(timeIntervalSince1970: 0), optional: nil, sub: nil) + let value3 = TestCodable(int: 3, string: "4", bool: true, float: 3, double: 6, date: Date(timeIntervalSince1970: 0), optional: nil, sub: nil) let insert = try emails.insertMany([value1, value2, value3]) AssertSQL( - "INSERT INTO \"emails\" (\"int\", \"string\", \"bool\", \"float\", \"double\") VALUES (1, '2', 1, 3.0, 4.0), (2, '3', 1, 3.0, 5.0), (3, '4', 1, 3.0, 6.0)", + "INSERT INTO \"emails\" (\"int\", \"string\", \"bool\", \"float\", \"double\", \"date\") VALUES (1, '2', 1, 3.0, 4.0, '1970-01-01T00:00:00.000'), (2, '3', 1, 3.0, 5.0, '1970-01-01T00:00:00.000'), (3, '4', 1, 3.0, 6.0, '1970-01-01T00:00:00.000')", insert ) }