Skip to content

Commit 5be9fa9

Browse files
authored
Merge pull request stephencelis#853 from hellohuanlin/huan_primary_key_with_4_columns
add primary key with 4 columns
2 parents 36e01b0 + 03eb780 commit 5be9fa9

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Sources/SQLite/Typed/Schema.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,10 @@ public final class TableBuilder {
341341
primaryKey([compositeA, b, c])
342342
}
343343

344+
public func primaryKey<T : Value, U : Value, V : Value, W : Value>(_ compositeA: Expression<T>, _ b: Expression<U>, _ c: Expression<V>, _ d: Expression<W>) {
345+
primaryKey([compositeA, b, c, d])
346+
}
347+
344348
fileprivate func primaryKey(_ composite: [Expressible]) {
345349
definitions.append("PRIMARY KEY".prefix(composite))
346350
}

Tests/SQLiteTests/SchemaTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,10 @@ class SchemaTests : XCTestCase {
545545
"CREATE TABLE \"table\" (PRIMARY KEY (\"int64\", \"string\", \"double\"))",
546546
table.create { t in t.primaryKey(int64, string, double) }
547547
)
548+
XCTAssertEqual(
549+
"CREATE TABLE \"table\" (PRIMARY KEY (\"int64\", \"string\", \"double\", \"date\"))",
550+
table.create { t in t.primaryKey(int64, string, double, date) }
551+
)
548552
}
549553

550554
func test_unique_compilesUniqueExpression() {

0 commit comments

Comments
 (0)