Skip to content

Commit

Permalink
Merge pull request #1121 from stephencelis/pk
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Fallet authored Mar 27, 2022
2 parents c93728f + b53434e commit 4d543d8
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 13 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
0.13.3 (25-01-2022), [diff][diff-0.13.3]
========================================

* UUID Fix ([#1112][])
* Add prepareRowIterator method to an extension of Statement. ([#1119][])
* Adding primary key support to column with references ([#1121][])

0.13.2 (25-01-2022), [diff][diff-0.13.2]
========================================

Expand Down Expand Up @@ -102,6 +109,7 @@
[diff-0.13.0]: https://github.com/stephencelis/SQLite.swift/compare/0.12.2...0.13.0
[diff-0.13.1]: https://github.com/stephencelis/SQLite.swift/compare/0.13.0...0.13.1
[diff-0.13.2]: https://github.com/stephencelis/SQLite.swift/compare/0.13.1...0.13.2
[diff-0.13.3]: https://github.com/stephencelis/SQLite.swift/compare/0.13.2...0.13.3

[#142]: https://github.com/stephencelis/SQLite.swift/issues/142
[#315]: https://github.com/stephencelis/SQLite.swift/issues/315
Expand Down Expand Up @@ -142,3 +150,6 @@
[#1095]: https://github.com/stephencelis/SQLite.swift/pull/1095
[#1100]: https://github.com/stephencelis/SQLite.swift/pull/1100
[#1105]: https://github.com/stephencelis/SQLite.swift/pull/1105
[#1112]: https://github.com/stephencelis/SQLite.swift/pull/1112
[#1119]: https://github.com/stephencelis/SQLite.swift/pull/1119
[#1121]: https://github.com/stephencelis/SQLite.swift/pull/1121
12 changes: 6 additions & 6 deletions Documentation/Index.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ process of downloading, compiling, and linking dependencies.

```swift
dependencies: [
.package(url: "https://github.com/stephencelis/SQLite.swift.git", from: "0.13.2")
.package(url: "https://github.com/stephencelis/SQLite.swift.git", from: "0.13.3")
]
```

Expand All @@ -102,7 +102,7 @@ install SQLite.swift with Carthage:
2. Update your Cartfile to include the following:

```ruby
github "stephencelis/SQLite.swift" ~> 0.13.2
github "stephencelis/SQLite.swift" ~> 0.13.3
```

3. Run `carthage update` and [add the appropriate framework][Carthage Usage].
Expand Down Expand Up @@ -132,7 +132,7 @@ install SQLite.swift with Carthage:
use_frameworks!

target 'YourAppTargetName' do
pod 'SQLite.swift', '~> 0.13.2'
pod 'SQLite.swift', '~> 0.13.3'
end
```

Expand All @@ -146,7 +146,7 @@ with the OS you can require the `standalone` subspec:

```ruby
target 'YourAppTargetName' do
pod 'SQLite.swift/standalone', '~> 0.13.2'
pod 'SQLite.swift/standalone', '~> 0.13.3'
end
```

Expand All @@ -156,7 +156,7 @@ dependency to sqlite3 or one of its subspecs:

```ruby
target 'YourAppTargetName' do
pod 'SQLite.swift/standalone', '~> 0.13.2'
pod 'SQLite.swift/standalone', '~> 0.13.3'
pod 'sqlite3/fts5', '= 3.15.0' # SQLite 3.15.0 with FTS5 enabled
end
```
Expand All @@ -172,7 +172,7 @@ If you want to use [SQLCipher][] with SQLite.swift you can require the
target 'YourAppTargetName' do
# Make sure you only require the subspec, otherwise you app might link against
# the system SQLite, which means the SQLCipher-specific methods won't work.
pod 'SQLite.swift/SQLCipher', '~> 0.13.2'
pod 'SQLite.swift/SQLCipher', '~> 0.13.3'
end
```

Expand Down
2 changes: 1 addition & 1 deletion Documentation/Planning.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ additions and Pull Requests, as well as to keep the Issues list clear of
enhancement requests so that bugs are more visible.

> ⚠ This document is currently not actively maintained. See
> the [0.13.3 milestone](https://github.com/stephencelis/SQLite.swift/issues?q=is%3Aopen+is%3Aissue+milestone%3A0.13.3)
> the [0.13.4 milestone](https://github.com/stephencelis/SQLite.swift/issues?q=is%3Aopen+is%3Aissue+milestone%3A0.13.4)
> on Github for additional information about planned features for the next release.
## Roadmap
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Swift code.

```swift
dependencies: [
.package(url: "https://github.com/stephencelis/SQLite.swift.git", from: "0.13.2")
.package(url: "https://github.com/stephencelis/SQLite.swift.git", from: "0.13.3")
]
```

Expand All @@ -160,7 +160,7 @@ install SQLite.swift with Carthage:
2. Update your Cartfile to include the following:

```ruby
github "stephencelis/SQLite.swift" ~> 0.13.2
github "stephencelis/SQLite.swift" ~> 0.13.3
```

3. Run `carthage update` and
Expand Down Expand Up @@ -191,7 +191,7 @@ SQLite.swift with CocoaPods:
use_frameworks!

target 'YourAppTargetName' do
pod 'SQLite.swift', '~> 0.13.2'
pod 'SQLite.swift', '~> 0.13.3'
end
```

Expand Down
2 changes: 1 addition & 1 deletion SQLite.swift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SQLite.swift"
s.version = "0.13.2"
s.version = "0.13.3"
s.summary = "A type-safe, Swift-language layer over SQLite3."

s.description = <<-DESC
Expand Down
4 changes: 2 additions & 2 deletions SQLite.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@
INFOPLIST_FILE = "$(SRCROOT)/Sources/SQLite/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 0.13.2;
MARKETING_VERSION = 0.13.3;
PRODUCT_BUNDLE_IDENTIFIER = com.stephencelis.SQLite;
PRODUCT_NAME = SQLite;
SKIP_INSTALL = YES;
Expand All @@ -1356,7 +1356,7 @@
INFOPLIST_FILE = "$(SRCROOT)/Sources/SQLite/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 0.13.2;
MARKETING_VERSION = 0.13.3;
PRODUCT_BUNDLE_IDENTIFIER = com.stephencelis.SQLite;
PRODUCT_NAME = SQLite;
SKIP_INSTALL = YES;
Expand Down
20 changes: 20 additions & 0 deletions Sources/SQLite/Typed/Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,26 @@ public final class TableBuilder {
column(name, V.declaredDatatype, nil, true, unique, check, nil, (table, other), nil)
}

public func column<V: Value>(_ name: Expression<V>, primaryKey: Bool, check: Expression<Bool>? = nil,
references table: QueryType, _ other: Expression<V>) where V.Datatype == Int64 {
column(name, V.declaredDatatype, primaryKey ? .default : nil, false, false, check, nil, (table, other), nil)
}

public func column<V: Value>(_ name: Expression<V>, primaryKey: Bool, check: Expression<Bool?>,
references table: QueryType, _ other: Expression<V>) where V.Datatype == Int64 {
column(name, V.declaredDatatype, primaryKey ? .default : nil, false, false, check, nil, (table, other), nil)
}

public func column<V: Value>(_ name: Expression<V?>, primaryKey: Bool, check: Expression<Bool>? = nil,
references table: QueryType, _ other: Expression<V>) where V.Datatype == Int64 {
column(name, V.declaredDatatype, primaryKey ? .default : nil, true, false, check, nil, (table, other), nil)
}

public func column<V: Value>(_ name: Expression<V?>, primaryKey: Bool, check: Expression<Bool?>,
references table: QueryType, _ other: Expression<V>) where V.Datatype == Int64 {
column(name, V.declaredDatatype, primaryKey ? .default : nil, true, false, check, nil, (table, other), nil)
}

public func column<V: Value>(_ name: Expression<V>, unique: Bool = false, check: Expression<Bool>? = nil,
defaultValue: Expression<V>? = nil, collate: Collation) where V.Datatype == String {
column(name, V.declaredDatatype, nil, false, unique, check, defaultValue, nil, collate)
Expand Down
27 changes: 27 additions & 0 deletions Tests/SQLiteTests/SchemaTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ class SchemaTests: XCTestCase {
"CREATE TABLE \"table\" (\"int64\" INTEGER NOT NULL UNIQUE REFERENCES \"table\" (\"int64\"))",
table.create { t in t.column(int64, unique: true, references: table, int64) }
)
XCTAssertEqual(
"CREATE TABLE \"table\" (\"int64\" INTEGER PRIMARY KEY NOT NULL REFERENCES \"table\" (\"int64\"))",
table.create { t in t.column(int64, primaryKey: true, references: table, int64) }
)
XCTAssertEqual(
"CREATE TABLE \"table\" (\"int64\" INTEGER NOT NULL CHECK (\"int64\" > 0) REFERENCES \"table\" (\"int64\"))",
table.create { t in t.column(int64, check: int64 > 0, references: table, int64) }
Expand All @@ -329,13 +333,24 @@ class SchemaTests: XCTestCase {
"CREATE TABLE \"table\" (\"int64\" INTEGER NOT NULL UNIQUE CHECK (\"int64\" > 0) REFERENCES \"table\" (\"int64\"))",
table.create { t in t.column(int64, unique: true, check: int64 > 0, references: table, int64) }
)
XCTAssertEqual(
"CREATE TABLE \"table\" (\"int64\" INTEGER PRIMARY KEY NOT NULL CHECK (\"int64\" > 0) REFERENCES \"table\" (\"int64\"))",
table.create { t in t.column(int64, primaryKey: true, check: int64 > 0, references: table, int64) }
)
XCTAssertEqual(
"""
CREATE TABLE \"table\" (\"int64\" INTEGER NOT NULL UNIQUE CHECK (\"int64Optional\" > 0) REFERENCES
\"table\" (\"int64\"))
""".replacingOccurrences(of: "\n", with: ""),
table.create { t in t.column(int64, unique: true, check: int64Optional > 0, references: table, int64) }
)
XCTAssertEqual(
"""
CREATE TABLE \"table\" (\"int64\" INTEGER PRIMARY KEY NOT NULL CHECK (\"int64Optional\" > 0) REFERENCES
\"table\" (\"int64\"))
""".replacingOccurrences(of: "\n", with: ""),
table.create { t in t.column(int64, primaryKey: true, check: int64Optional > 0, references: table, int64) }
)

XCTAssertEqual(
"CREATE TABLE \"table\" (\"int64Optional\" INTEGER REFERENCES \"table\" (\"int64\"))",
Expand All @@ -345,6 +360,10 @@ class SchemaTests: XCTestCase {
"CREATE TABLE \"table\" (\"int64Optional\" INTEGER UNIQUE REFERENCES \"table\" (\"int64\"))",
table.create { t in t.column(int64Optional, unique: true, references: table, int64) }
)
XCTAssertEqual(
"CREATE TABLE \"table\" (\"int64Optional\" INTEGER PRIMARY KEY REFERENCES \"table\" (\"int64\"))",
table.create { t in t.column(int64Optional, primaryKey: true, references: table, int64) }
)
XCTAssertEqual(
"CREATE TABLE \"table\" (\"int64Optional\" INTEGER CHECK (\"int64\" > 0) REFERENCES \"table\" (\"int64\"))",
table.create { t in t.column(int64Optional, check: int64 > 0, references: table, int64) }
Expand All @@ -357,10 +376,18 @@ class SchemaTests: XCTestCase {
"CREATE TABLE \"table\" (\"int64Optional\" INTEGER UNIQUE CHECK (\"int64\" > 0) REFERENCES \"table\" (\"int64\"))",
table.create { t in t.column(int64Optional, unique: true, check: int64 > 0, references: table, int64) }
)
XCTAssertEqual(
"CREATE TABLE \"table\" (\"int64Optional\" INTEGER PRIMARY KEY CHECK (\"int64\" > 0) REFERENCES \"table\" (\"int64\"))",
table.create { t in t.column(int64Optional, primaryKey: true, check: int64 > 0, references: table, int64) }
)
XCTAssertEqual(
"CREATE TABLE \"table\" (\"int64Optional\" INTEGER UNIQUE CHECK (\"int64Optional\" > 0) REFERENCES \"table\" (\"int64\"))",
table.create { t in t.column(int64Optional, unique: true, check: int64Optional > 0, references: table, int64) }
)
XCTAssertEqual(
"CREATE TABLE \"table\" (\"int64Optional\" INTEGER PRIMARY KEY CHECK (\"int64Optional\" > 0) REFERENCES \"table\" (\"int64\"))",
table.create { t in t.column(int64Optional, primaryKey: true, check: int64Optional > 0, references: table, int64) }
)
}

func test_column_withStringExpression_compilesCollatedColumnDefinitionExpression() {
Expand Down

0 comments on commit 4d543d8

Please sign in to comment.