From 61bb2dd588751b97195aba4e40b1d3cb0e4dc13f Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Thu, 20 Oct 2016 10:43:44 +0200 Subject: [PATCH 01/26] Fix for ~= operator used with Double ranges --- SQLite/Typed/Operators.swift | 4 ++-- SQLiteTests/OperatorsTests.swift | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/SQLite/Typed/Operators.swift b/SQLite/Typed/Operators.swift index 616015dc..fdd293be 100644 --- a/SQLite/Typed/Operators.swift +++ b/SQLite/Typed/Operators.swift @@ -474,10 +474,10 @@ public func <=(lhs: V, rhs: Expression) -> Expression wher return infix(lhs, rhs) } -public func ~=(lhs: CountableClosedRange, rhs: Expression) -> Expression where V.Datatype : Binding & Comparable { +public func ~=(lhs: ClosedRange, rhs: Expression) -> Expression where V.Datatype : Binding & Comparable { return Expression("\(rhs.template) BETWEEN ? AND ?", rhs.bindings + [lhs.lowerBound as? Binding, lhs.upperBound as? Binding]) } -public func ~=(lhs: CountableClosedRange, rhs: Expression) -> Expression where V.Datatype : Binding & Comparable { +public func ~=(lhs: ClosedRange, rhs: Expression) -> Expression where V.Datatype : Binding & Comparable { return Expression("\(rhs.template) BETWEEN ? AND ?", rhs.bindings + [lhs.lowerBound as? Binding, lhs.upperBound as? Binding]) } diff --git a/SQLiteTests/OperatorsTests.swift b/SQLiteTests/OperatorsTests.swift index 819cf292..d2ce17ef 100644 --- a/SQLiteTests/OperatorsTests.swift +++ b/SQLiteTests/OperatorsTests.swift @@ -245,11 +245,16 @@ class OperatorsTests : XCTestCase { AssertSQL("(1 <= \"boolOptional\")", true <= boolOptional) } - func test_patternMatchingOperator_withComparableInterval_buildsBetweenBooleanExpression() { + func test_patternMatchingOperator_withComparableCountableClosedRange_buildsBetweenBooleanExpression() { AssertSQL("\"int\" BETWEEN 0 AND 5", 0...5 ~= int) AssertSQL("\"intOptional\" BETWEEN 0 AND 5", 0...5 ~= intOptional) } + func test_patternMatchingOperator_withComparableClosedRange_buildsBetweenBooleanExpression() { + AssertSQL("\"double\" BETWEEN 1.2 AND 4.5", 1.2...4.5 ~= double) + AssertSQL("\"doubleOptional\" BETWEEN 1.2 AND 4.5", 1.2...4.5 ~= doubleOptional) + } + func test_doubleAndOperator_withBooleanExpressions_buildsCompoundExpression() { AssertSQL("(\"bool\" AND \"bool\")", bool && bool) AssertSQL("(\"bool\" AND \"boolOptional\")", bool && boolOptional) From 14c0a48d075906efdc3366ad7a42cdf4ba741169 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Thu, 20 Oct 2016 10:48:27 +0200 Subject: [PATCH 02/26] Tag as discardable --- SQLite/Typed/Query.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SQLite/Typed/Query.swift b/SQLite/Typed/Query.swift index 75f29afd..375c1d0a 100644 --- a/SQLite/Typed/Query.swift +++ b/SQLite/Typed/Query.swift @@ -968,7 +968,7 @@ extension Connection { /// - Parameter query: An insert query. /// /// - Returns: The insert’s rowid. - public func run(_ query: Insert) throws -> Int64 { + @discardableResult public func run(_ query: Insert) throws -> Int64 { let expression = query.expression return try sync { try self.run(expression.template, expression.bindings) @@ -984,7 +984,7 @@ extension Connection { /// - Parameter query: An update query. /// /// - Returns: The number of updated rows. - public func run(_ query: Update) throws -> Int { + @discardableResult public func run(_ query: Update) throws -> Int { let expression = query.expression return try sync { try self.run(expression.template, expression.bindings) @@ -999,7 +999,7 @@ extension Connection { /// - Parameter query: A delete query. /// /// - Returns: The number of deleted rows. - public func run(_ query: Delete) throws -> Int { + @discardableResult public func run(_ query: Delete) throws -> Int { let expression = query.expression return try sync { try self.run(expression.template, expression.bindings) From 26ef2597ad40bd42f8a40616c34d857d3f69b40e Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Thu, 20 Oct 2016 10:58:35 +0200 Subject: [PATCH 03/26] Test String ranges --- SQLiteTests/OperatorsTests.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SQLiteTests/OperatorsTests.swift b/SQLiteTests/OperatorsTests.swift index d2ce17ef..f0e585cd 100644 --- a/SQLiteTests/OperatorsTests.swift +++ b/SQLiteTests/OperatorsTests.swift @@ -255,6 +255,11 @@ class OperatorsTests : XCTestCase { AssertSQL("\"doubleOptional\" BETWEEN 1.2 AND 4.5", 1.2...4.5 ~= doubleOptional) } + func test_patternMatchingOperator_withomparableClosedRangeString_buildsBetweenBooleanExpression() { + AssertSQL("\"string\" BETWEEN 'a' AND 'b'", "a"..."b" ~= string) + AssertSQL("\"stringOptional\" BETWEEN 'a' AND 'b'", "a"..."b" ~= stringOptional) + } + func test_doubleAndOperator_withBooleanExpressions_buildsCompoundExpression() { AssertSQL("(\"bool\" AND \"bool\")", bool && bool) AssertSQL("(\"bool\" AND \"boolOptional\")", bool && boolOptional) From d95a518178570c805bb18b971d264b8a48edbcf5 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Fri, 21 Oct 2016 08:56:21 +0200 Subject: [PATCH 04/26] Bump version --- Documentation/Index.md | 8 ++++---- README.md | 4 ++-- SQLite.swift.podspec | 2 +- SQLite/Info.plist | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Documentation/Index.md b/Documentation/Index.md index 6107969a..50d7d840 100644 --- a/Documentation/Index.md +++ b/Documentation/Index.md @@ -78,7 +78,7 @@ install SQLite.swift with Carthage: 2. Update your Cartfile to include the following: ``` - github "stephencelis/SQLite.swift" ~> 0.11.0 + github "stephencelis/SQLite.swift" ~> 0.11.1 ``` 3. Run `carthage update` and [add the appropriate framework][Carthage Usage]. @@ -108,7 +108,7 @@ install SQLite.swift with Carthage: ``` ruby use_frameworks! - pod 'SQLite.swift', '~> 0.11.0' + pod 'SQLite.swift', '~> 0.11.1' ``` 4. Run `pod install`. @@ -119,13 +119,13 @@ install SQLite.swift with Carthage: If you want to use a more recent version of SQLite than what is provided with the OS you can require the `standalone` subspec: ``` ruby - pod 'SQLite.swift/standalone', '~> 0.11.0' + pod 'SQLite.swift/standalone', '~> 0.11.1' ``` By default this will use the most recent version of SQLite without any extras. If you want you can further customize this by adding another dependency to sqlite3 or one of its subspecs: ``` ruby - pod 'SQLite.swift/standalone', '~> 0.11.0' + pod 'SQLite.swift/standalone', '~> 0.11.1' pod 'sqlite3/fts5', '= 3.15.0' # SQLite 3.15.0 with FTS5 enabled ``` diff --git a/README.md b/README.md index 6e9857bd..85767b38 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,7 @@ install SQLite.swift with Carthage: 2. Update your Cartfile to include the following: ``` - github "stephencelis/SQLite.swift" ~> 0.11.0 + github "stephencelis/SQLite.swift" ~> 0.11.1 ``` 3. Run `carthage update` and [add the appropriate framework][Carthage Usage]. @@ -159,7 +159,7 @@ SQLite.swift with CocoaPods: ``` ruby use_frameworks! - pod 'SQLite.swift', '~> 0.11.0' + pod 'SQLite.swift', '~> 0.11.1' ``` 3. Run `pod install`. diff --git a/SQLite.swift.podspec b/SQLite.swift.podspec index 9c3a35e0..ac7ed8bb 100644 --- a/SQLite.swift.podspec +++ b/SQLite.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "SQLite.swift" - s.version = "0.11.0" + s.version = "0.11.1" s.summary = "A type-safe, Swift-language layer over SQLite3 for iOS and OS X." s.description = <<-DESC diff --git a/SQLite/Info.plist b/SQLite/Info.plist index 03d53553..21f24d9d 100644 --- a/SQLite/Info.plist +++ b/SQLite/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.11.0 + 0.11.1 CFBundleSignature ???? CFBundleVersion From f58ebbf2850693d262af7df4521716bd53c74d12 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Tue, 8 Nov 2016 12:45:29 +0000 Subject: [PATCH 05/26] Update CocoaPods doc --- Documentation/Index.md | 2 +- README.md | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Documentation/Index.md b/Documentation/Index.md index 50d7d840..367236ae 100644 --- a/Documentation/Index.md +++ b/Documentation/Index.md @@ -100,7 +100,7 @@ install SQLite.swift with Carthage: ``` sh # Using the default Ruby install will require you to use sudo when # installing and updating gems. - sudo gem install cocoapods + [sudo] gem install cocoapods ``` 3. Update your Podfile to include the following: diff --git a/README.md b/README.md index 85767b38..e3c766a1 100644 --- a/README.md +++ b/README.md @@ -145,8 +145,9 @@ install SQLite.swift with Carthage: [CocoaPods][] is a dependency manager for Cocoa projects. To install SQLite.swift with CocoaPods: - 1. Make sure the latest CocoaPods beta is [installed][CocoaPods - Installation]. (SQLite.swift requires version 1.0.0.beta.6 or greater.) + 1. Verify that your copy of Xcode is installed in the default location (`/Application/Xcode.app`). + + 2. Make sure the latest CocoaPods beta is [installed][CocoaPods Installation]. (SQLite.swift requires version 1.0.0 or greater.) ``` sh # Using the default Ruby install will require you to use sudo when @@ -154,7 +155,7 @@ SQLite.swift with CocoaPods: [sudo] gem install cocoapods ``` - 2. Update your Podfile to include the following: + 3. Update your Podfile to include the following: ``` ruby use_frameworks! @@ -162,7 +163,7 @@ SQLite.swift with CocoaPods: pod 'SQLite.swift', '~> 0.11.1' ``` - 3. Run `pod install`. + 4. Run `pod install`. [CocoaPods]: https://cocoapods.org [CocoaPods Installation]: https://guides.cocoapods.org/using/getting-started.html#getting-started From 2d059b0f4a8759d224e0b78f34b26cfd4f6c5f6d Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Tue, 8 Nov 2016 13:06:04 +0000 Subject: [PATCH 06/26] Docs: restore migration information --- Documentation/Index.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Documentation/Index.md b/Documentation/Index.md index 367236ae..77f9d8e6 100644 --- a/Documentation/Index.md +++ b/Documentation/Index.md @@ -1079,11 +1079,22 @@ try db.run(users.drop(ifExists: true)) ``` - +``` ## Custom Types From bf6a722fc35aef5661edfa165ae43cefbfecd160 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Tue, 8 Nov 2016 13:09:05 +0000 Subject: [PATCH 07/26] Add missing boilerplate --- Documentation/Index.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Documentation/Index.md b/Documentation/Index.md index 77f9d8e6..7fabe836 100644 --- a/Documentation/Index.md +++ b/Documentation/Index.md @@ -1086,9 +1086,11 @@ You can add a convenience property on `Connection` to query and set the [`PRAGMA This is a great way to manage your schema’s version over migrations. ``` swift -public var userVersion: Int32 { - get { return Int32(try! scalar("PRAGMA user_version") as! Int64)} - set { try! run("PRAGMA user_version = \(newValue)") } +extension Connection { + public var userVersion: Int32 { + get { return Int32(try! scalar("PRAGMA user_version") as! Int64)} + set { try! run("PRAGMA user_version = \(newValue)") } + } } ``` From d784548f25a2989cda873f158aec63f2d9f9eedd Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Tue, 8 Nov 2016 13:10:29 +0000 Subject: [PATCH 08/26] Fix link target --- Documentation/Index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/Index.md b/Documentation/Index.md index 7fabe836..a8aa0747 100644 --- a/Documentation/Index.md +++ b/Documentation/Index.md @@ -1081,7 +1081,7 @@ try db.run(users.drop(ifExists: true)) ### Migrations and Schema Versioning -You can add a convenience property on `Connection` to query and set the [`PRAGMA user_version`](https://sqlite.org/pragma.html#pragma_schema_version). +You can add a convenience property on `Connection` to query and set the [`PRAGMA user_version`](https://sqlite.org/pragma.html#pragma_user_version). This is a great way to manage your schema’s version over migrations. From 8b960d443b9475f5c7866e22a5eb0183bcd9618a Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Thu, 10 Nov 2016 15:17:19 +0000 Subject: [PATCH 09/26] Tell users to perform a repo update when installing pods #540 --- Documentation/Index.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/Index.md b/Documentation/Index.md index a8aa0747..e5eda36a 100644 --- a/Documentation/Index.md +++ b/Documentation/Index.md @@ -111,7 +111,7 @@ install SQLite.swift with Carthage: pod 'SQLite.swift', '~> 0.11.1' ``` - 4. Run `pod install`. + 4. Run `pod install --repo-update`. #### Requiring a specific version of SQLite diff --git a/README.md b/README.md index e3c766a1..14c0f6f6 100644 --- a/README.md +++ b/README.md @@ -163,7 +163,7 @@ SQLite.swift with CocoaPods: pod 'SQLite.swift', '~> 0.11.1' ``` - 4. Run `pod install`. + 4. Run `pod install --repo-update`. [CocoaPods]: https://cocoapods.org [CocoaPods Installation]: https://guides.cocoapods.org/using/getting-started.html#getting-started From c2f3fc8b0f2ed5ea413e692952f44b13efe237db Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Sat, 12 Nov 2016 16:11:27 +0000 Subject: [PATCH 10/26] Link to SQLiteMigrationManager.swift now that it is Swift3 compatible --- Documentation/Index.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/Index.md b/Documentation/Index.md index e5eda36a..3678368b 100644 --- a/Documentation/Index.md +++ b/Documentation/Index.md @@ -1107,6 +1107,8 @@ if db.userVersion == 1 { } ``` +For more complex migration requirements check out the schema management system +[SQLiteMigrationManager.swift][]. ## Custom Types @@ -1526,3 +1528,4 @@ We can log SQL using the database’s `trace` function. [ROWID]: https://sqlite.org/lang_createtable.html#rowid +[SQLiteMigrationManager.swift]: https://github.com/garriguv/SQLiteMigrationManager.swift From 6e30a3d40cdecf94124c43729c7566dd03f0d8d8 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Sat, 12 Nov 2016 19:40:24 +0000 Subject: [PATCH 11/26] Add config file for CocoaDocs --- .cocoadocs.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .cocoadocs.yml diff --git a/.cocoadocs.yml b/.cocoadocs.yml new file mode 100644 index 00000000..27840032 --- /dev/null +++ b/.cocoadocs.yml @@ -0,0 +1,2 @@ +additional_guides: + - Documentation/Index.md From 6b784093b8661cd81b2f4a075a8e5880cca2da47 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Tue, 15 Nov 2016 08:04:45 +0000 Subject: [PATCH 12/26] Mention FTS5 query differences in docs Closes #544 --- Documentation/Index.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/Index.md b/Documentation/Index.md index 3678368b..190c1d2d 100644 --- a/Documentation/Index.md +++ b/Documentation/Index.md @@ -1444,6 +1444,13 @@ let config = FTS5Config() try db.run(emails.create(.FTS5(config)) // CREATE VIRTUAL TABLE "emails" USING fts5("subject", "body" UNINDEXED) + +// Note that FTS5 uses a different syntax to select columns, so we need to rewrite +// the last FTS4 query above as: +let replies = emails.filter(emails.match("subject:\"Re:\"*)) +// SELECT * FROM "emails" WHERE "emails" MATCH 'subject:"Re:"*' + +// https://www.sqlite.org/fts5.html#_changes_to_select_statements_ ``` ## Executing Arbitrary SQL From 75394dab16991f64672dbf8a11fbb8e80c17a2e7 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Tue, 15 Nov 2016 11:27:09 +0000 Subject: [PATCH 13/26] Make lastInsertRowid consistent with other SQLite wrappers closes #532 --- SQLite/Core/Connection.swift | 5 ++--- SQLite/Typed/Query.swift | 2 +- SQLiteTests/ConnectionTests.swift | 22 +++++++++++++++++----- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/SQLite/Core/Connection.swift b/SQLite/Core/Connection.swift index 5d6ebcdc..e96a84b5 100644 --- a/SQLite/Core/Connection.swift +++ b/SQLite/Core/Connection.swift @@ -132,9 +132,8 @@ public final class Connection { public var readonly: Bool { return sqlite3_db_readonly(handle, nil) == 1 } /// The last rowid inserted into the database via this connection. - public var lastInsertRowid: Int64? { - let rowid = sqlite3_last_insert_rowid(handle) - return rowid != 0 ? rowid : nil + public var lastInsertRowid: Int64 { + return sqlite3_last_insert_rowid(handle) } /// The last number of changes (inserts, updates, or deletes) made to the diff --git a/SQLite/Typed/Query.swift b/SQLite/Typed/Query.swift index 375c1d0a..288768c1 100644 --- a/SQLite/Typed/Query.swift +++ b/SQLite/Typed/Query.swift @@ -972,7 +972,7 @@ extension Connection { let expression = query.expression return try sync { try self.run(expression.template, expression.bindings) - return self.lastInsertRowid! + return self.lastInsertRowid } } diff --git a/SQLiteTests/ConnectionTests.swift b/SQLiteTests/ConnectionTests.swift index 99b9d8a1..ab0e957c 100644 --- a/SQLiteTests/ConnectionTests.swift +++ b/SQLiteTests/ConnectionTests.swift @@ -43,17 +43,29 @@ class ConnectionTests : SQLiteTestCase { XCTAssertTrue(db.readonly) } - func test_lastInsertRowid_returnsNilOnNewConnections() { - XCTAssert(db.lastInsertRowid == nil) + func test_changes_returnsZeroOnNewConnections() { + XCTAssertEqual(0, db.changes) } func test_lastInsertRowid_returnsLastIdAfterInserts() { try! InsertUser("alice") - XCTAssertEqual(1, db.lastInsertRowid!) + XCTAssertEqual(1, db.lastInsertRowid) } - func test_changes_returnsZeroOnNewConnections() { - XCTAssertEqual(0, db.changes) + func test_lastInsertRowid_doesNotResetAfterError() { + XCTAssert(db.lastInsertRowid == 0) + try! InsertUser("alice") + XCTAssertEqual(1, db.lastInsertRowid) + XCTAssertThrowsError( + try db.run("INSERT INTO \"users\" (email, age, admin) values ('invalid@example.com', 12, 'invalid')") + ) { error in + if case SQLite.Result.error(_, let code, _) = error { + XCTAssertEqual(SQLITE_CONSTRAINT, code) + } else { + XCTFail("expected error") + } + } + XCTAssertEqual(1, db.lastInsertRowid) } func test_changes_returnsNumberOfChanges() { From c7480062ee75bea70ba3f4be157c4ffa0bb293ee Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Tue, 15 Nov 2016 11:28:22 +0000 Subject: [PATCH 14/26] Add changelog --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..ca8da53e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,15 @@ +0.11.1 (unreleased, [diff][diff-0.11.1]) +======================================== + +* Made lastInsertRowid consistent with other SQLite wrappers (#532) +* Fix for ~= operator used with Double ranges +* Various documentation updates + +0.11.0 (19-10-2016) +=================== + +* Swift3 migration ([diff][diff-0.11.0]) + + +[diff-0.11.1]: https://github.com/stephencelis/SQLite.swift/compare/0.11.1...0.11.0 +[diff-0.11.0]: https://github.com/stephencelis/SQLite.swift/compare/0.10.1...0.11.0 From fbea9bf6593100b10f4473a9c241b841b5b84b36 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Tue, 15 Nov 2016 13:03:05 +0000 Subject: [PATCH 15/26] Retry failed builds --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d28be8de..192c9979 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,4 +15,4 @@ before_install: - gem update bundler - gem install xcpretty --no-document script: - - ./run-tests.sh + - travis_retry ./run-tests.sh From 095026d1b1ec8f249a51a624ff44e200251d2407 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Tue, 15 Nov 2016 13:13:00 +0000 Subject: [PATCH 16/26] Add missing imports --- SQLiteTests/ConnectionTests.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SQLiteTests/ConnectionTests.swift b/SQLiteTests/ConnectionTests.swift index ab0e957c..20d4215a 100644 --- a/SQLiteTests/ConnectionTests.swift +++ b/SQLiteTests/ConnectionTests.swift @@ -1,5 +1,10 @@ import XCTest import SQLite +#if SQLITE_SWIFT_STANDALONE +import sqlite3 +#elseif COCOAPODS +import CSQLite +#endif class ConnectionTests : SQLiteTestCase { From e177a1d6f3bb85161e326c20423a0ca014b56b4a Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Tue, 15 Nov 2016 14:26:10 +0000 Subject: [PATCH 17/26] Switch to released CocoaPods version --- CocoaPodsTests/Gemfile | 2 +- CocoaPodsTests/Gemfile.lock | 32 ++++++++++++++++++-------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/CocoaPodsTests/Gemfile b/CocoaPodsTests/Gemfile index 29e72332..94018f18 100644 --- a/CocoaPodsTests/Gemfile +++ b/CocoaPodsTests/Gemfile @@ -1,4 +1,4 @@ source 'https://rubygems.org' -gem 'cocoapods', '~> 1.1.0.rc.3' +gem 'cocoapods', '~> 1.1.0' gem 'minitest' diff --git a/CocoaPodsTests/Gemfile.lock b/CocoaPodsTests/Gemfile.lock index f8cc1118..e8879f13 100644 --- a/CocoaPodsTests/Gemfile.lock +++ b/CocoaPodsTests/Gemfile.lock @@ -1,6 +1,7 @@ GEM remote: https://rubygems.org/ specs: + CFPropertyList (2.3.3) activesupport (4.2.7.1) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) @@ -8,63 +9,66 @@ GEM thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) claide (1.0.1) - cocoapods (1.1.0.rc.3) + cocoapods (1.1.1) activesupport (>= 4.0.2, < 5) claide (>= 1.0.1, < 2.0) - cocoapods-core (= 1.1.0.rc.3) + cocoapods-core (= 1.1.1) cocoapods-deintegrate (>= 1.0.1, < 2.0) - cocoapods-downloader (>= 1.1.1, < 2.0) + cocoapods-downloader (>= 1.1.2, < 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.1.0.beta.1) + cocoapods-trunk (>= 1.1.1, < 2.0) cocoapods-try (>= 1.1.0, < 2.0) colored (~> 1.2) escape (~> 0.0.4) - fourflusher (~> 2.0) + fourflusher (~> 2.0.1) gh_inspector (~> 1.0) molinillo (~> 0.5.1) nap (~> 1.0) - xcodeproj (>= 1.3.2, < 2.0) - cocoapods-core (1.1.0.rc.3) + xcodeproj (>= 1.3.3, < 2.0) + cocoapods-core (1.1.1) activesupport (>= 4.0.2, < 5) fuzzy_match (~> 2.0.4) nap (~> 1.0) cocoapods-deintegrate (1.0.1) - cocoapods-downloader (1.1.1) + cocoapods-downloader (1.1.2) cocoapods-plugins (1.0.0) nap cocoapods-search (1.0.0) cocoapods-stats (1.0.0) - cocoapods-trunk (1.1.0.beta.1) + cocoapods-trunk (1.1.1) nap (>= 0.8, < 2.0) netrc (= 0.7.8) cocoapods-try (1.1.0) colored (1.2) escape (0.0.4) - fourflusher (2.0.0) + fourflusher (2.0.1) fuzzy_match (2.0.4) gh_inspector (1.0.2) i18n (0.7.0) json (1.8.3) minitest (5.9.1) - molinillo (0.5.1) + molinillo (0.5.4) + nanaimo (0.2.2) nap (1.1.0) netrc (0.7.8) thread_safe (0.3.5) tzinfo (1.2.2) thread_safe (~> 0.1) - xcodeproj (1.3.2) + xcodeproj (1.4.1) + CFPropertyList (~> 2.3.3) activesupport (>= 3) claide (>= 1.0.1, < 2.0) colored (~> 1.2) + nanaimo (~> 0.2.0) PLATFORMS ruby DEPENDENCIES - cocoapods (~> 1.1.0.rc.3) + cocoapods (~> 1.1.0) minitest BUNDLED WITH - 1.13.1 + 1.13.3 From bb3b7059a324651e89357da0e6edeaa2c5d06d36 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Wed, 16 Nov 2016 15:09:42 +0000 Subject: [PATCH 18/26] public check method, needed for #389 --- SQLite/Core/Connection.swift | 2 +- SQLiteTests/ConnectionTests.swift | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/SQLite/Core/Connection.swift b/SQLite/Core/Connection.swift index e96a84b5..6b447305 100644 --- a/SQLite/Core/Connection.swift +++ b/SQLite/Core/Connection.swift @@ -674,7 +674,7 @@ public final class Connection { return success! } - @discardableResult func check(_ resultCode: Int32, statement: Statement? = nil) throws -> Int32 { + @discardableResult public func check(_ resultCode: Int32, statement: Statement? = nil) throws -> Int32 { guard let error = Result(errorCode: resultCode, connection: self, statement: statement) else { return resultCode } diff --git a/SQLiteTests/ConnectionTests.swift b/SQLiteTests/ConnectionTests.swift index 20d4215a..6455d30a 100644 --- a/SQLiteTests/ConnectionTests.swift +++ b/SQLiteTests/ConnectionTests.swift @@ -338,4 +338,11 @@ class ConnectionTests : SQLiteTestCase { AssertThrows(try stmt.run()) } + func test_check_with_successCode_returnsCode() { + try! XCTAssertEqual(SQLITE_OK, db.check(SQLITE_OK)) + } + + func test_check_with_errorCode_throws() { + XCTAssertThrowsError(try db.check(SQLITE_CONSTRAINT)) + } } From 6b8661afdf4128379f6382ee55e8eea2b444e5ea Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Wed, 16 Nov 2016 15:11:09 +0000 Subject: [PATCH 19/26] Try out xcode 8.1 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 192c9979..b27d7061 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: objective-c rvm: 2.2 -osx_image: xcode8 +osx_image: xcode8.1 env: global: - IOS_SIMULATOR="iPhone SE" From 433d2479939ba583e3d15939c081126cbd027c0b Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Sun, 20 Nov 2016 09:43:21 +0000 Subject: [PATCH 20/26] Xcode 8.2 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b27d7061..9138ddb7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: objective-c rvm: 2.2 -osx_image: xcode8.1 +osx_image: xcode8.2 env: global: - IOS_SIMULATOR="iPhone SE" From fbf994a331c3f5a2fc1729be5e35605c1943c31b Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Sun, 20 Nov 2016 09:51:04 +0000 Subject: [PATCH 21/26] Specify destination --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2f085b6c..bb459c2c 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ BUILD_TOOL = xcodebuild BUILD_SCHEME = SQLite Mac -IOS_SIMULATOR = iPhone SE +IOS_SIMULATOR = iPhone 6s ifeq ($(BUILD_SCHEME),SQLite iOS) - BUILD_ARGUMENTS = -scheme "$(BUILD_SCHEME)" -destination "platform=iOS Simulator,name=$(IOS_SIMULATOR)" + BUILD_ARGUMENTS = -scheme "$(BUILD_SCHEME)" -destination "platform=iOS Simulator,name=$(IOS_SIMULATOR),OS=9.3" else BUILD_ARGUMENTS = -scheme "$(BUILD_SCHEME)" endif From 6e53f365d7d3d871f95b1705e8af8e0fb9e4e293 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Sun, 20 Nov 2016 10:56:08 +0000 Subject: [PATCH 22/26] Use 6s --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9138ddb7..9e06164f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ rvm: 2.2 osx_image: xcode8.2 env: global: - - IOS_SIMULATOR="iPhone SE" + - IOS_SIMULATOR="iPhone 6s" matrix: include: - env: BUILD_SCHEME="SQLite iOS" From cbf5e0e92103180e539f4e883b3f32ff28ecf0d1 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Sun, 20 Nov 2016 11:01:06 +0000 Subject: [PATCH 23/26] Remove travis_retry workaround --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9e06164f..833c67d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,4 +15,4 @@ before_install: - gem update bundler - gem install xcpretty --no-document script: - - travis_retry ./run-tests.sh + - ./run-tests.sh From f23969f589e84d7f542dbe83db7a7bd391f363dd Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Sun, 20 Nov 2016 11:14:04 +0000 Subject: [PATCH 24/26] Specify iOS version --- .travis.yml | 1 + Makefile | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 833c67d5..818639c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ osx_image: xcode8.2 env: global: - IOS_SIMULATOR="iPhone 6s" + - IOS_VERSION="9.3" matrix: include: - env: BUILD_SCHEME="SQLite iOS" diff --git a/Makefile b/Makefile index bb459c2c..537fb1ff 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,9 @@ BUILD_TOOL = xcodebuild BUILD_SCHEME = SQLite Mac IOS_SIMULATOR = iPhone 6s +IOS_VERSION = 9.3 ifeq ($(BUILD_SCHEME),SQLite iOS) - BUILD_ARGUMENTS = -scheme "$(BUILD_SCHEME)" -destination "platform=iOS Simulator,name=$(IOS_SIMULATOR),OS=9.3" + BUILD_ARGUMENTS = -scheme "$(BUILD_SCHEME)" -destination "platform=iOS Simulator,name=$(IOS_SIMULATOR),OS=$(IOS_VERSION)" else BUILD_ARGUMENTS = -scheme "$(BUILD_SCHEME)" endif From 2e6e3c93b926f8e31d1a52f84c3790826302c1eb Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Sun, 20 Nov 2016 12:49:21 +0000 Subject: [PATCH 25/26] Remove env --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 818639c4..833c67d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ osx_image: xcode8.2 env: global: - IOS_SIMULATOR="iPhone 6s" - - IOS_VERSION="9.3" matrix: include: - env: BUILD_SCHEME="SQLite iOS" From 3472f4e47988223047c6ae0768c6c0ce6c584480 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Sun, 4 Dec 2016 20:52:47 +0000 Subject: [PATCH 26/26] Split testing into separate commands --- CocoaPodsTests/test_running_validator.rb | 2 +- Makefile | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CocoaPodsTests/test_running_validator.rb b/CocoaPodsTests/test_running_validator.rb index 949e8489..410f9465 100644 --- a/CocoaPodsTests/test_running_validator.rb +++ b/CocoaPodsTests/test_running_validator.rb @@ -79,7 +79,7 @@ def add_test_target(pod_file) def run_tests command = [ - 'clean', 'test', + 'clean', 'build', 'build-for-testing', 'test-without-building', '-workspace', File.join(validation_dir, "#{APP_TARGET}.xcworkspace"), '-scheme', TEST_TARGET, '-configuration', 'Debug' diff --git a/Makefile b/Makefile index 537fb1ff..d4f51d53 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ endif XCPRETTY := $(shell command -v xcpretty) SWIFTCOV := $(shell command -v swiftcov) GCOVR := $(shell command -v gcovr) +TEST_ACTIONS := clean build build-for-testing test-without-building default: test @@ -19,9 +20,9 @@ build: test: ifdef XCPRETTY - @set -o pipefail && $(BUILD_TOOL) $(BUILD_ARGUMENTS) test | $(XCPRETTY) -c + @set -o pipefail && $(BUILD_TOOL) $(BUILD_ARGUMENTS) $(TEST_ACTIONS) | $(XCPRETTY) -c else - $(BUILD_TOOL) $(BUILD_ARGUMENTS) test + $(BUILD_TOOL) $(BUILD_ARGUMENTS) $(TEST_ACTIONS) endif coverage: