Skip to content

Commit 74e80d3

Browse files
committed
Un-camelcase collating sequence names
As with .Autoincrement, let the standard be to merely capitalize the raw, uppercased value. This is a breaking change and .NoCase and .RTrim must be changed to .Nocase and .Rtrim. Let's also better document RTRIM. Signed-off-by: Stephen Celis <[email protected]>
1 parent 82f9c75 commit 74e80d3

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

Documentation/Index.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,11 @@ The `column` function is used for a single column definition. It takes an [expre
322322
- `collate` adds a `COLLATE` clause to `Expression<String>` (and `Expression<String?>`) column definitions with [a collating sequence](https://www.sqlite.org/datatype3.html#collation) defined in the `Collation` enumeration.
323323
324324
``` swift
325-
t.column(email, collate: .NoCase)
325+
t.column(email, collate: .Nocase)
326326
// "email" TEXT NOT NULL COLLATE "NOCASE"
327+
328+
t.column(name, collate: .Rtrim)
329+
// "name" TEXT COLLATE "RTRIM"
327330
```
328331
329332
- `references` adds a `REFERENCES` clause to `Expression<Int64>` (and `Expression<Int64?>`) column definitions and accepts a table (`Query`) or namespaced column expression. (See the `foreignKey` function under [Table Constraints](#table-constraints) for non-integer foreign key support.)
@@ -953,8 +956,11 @@ The `alter` function shares several of the same [`column` function parameters](#
953956
- `collate` adds a `COLLATE` clause to `Expression<String>` (and `Expression<String?>`) column definitions with [a collating sequence](https://www.sqlite.org/datatype3.html#collation) defined in the `Collation` enumeration.
954957
955958
``` swift
956-
t.column(email, collate: .NoCase)
959+
t.column(email, collate: .Nocase)
957960
// email TEXT NOT NULL COLLATE "NOCASE"
961+
962+
t.column(name, collate: .Rtrim)
963+
// name TEXT COLLATE "RTRIM"
958964
```
959965
960966
- `references` adds a `REFERENCES` clause to `Int64` (and `Int64?`) column definitions and accepts a table or namespaced column expression. (See the `foreignKey` function under [Table Constraints](#table-constraints) for non-integer foreign key support.)

SQLite Tests/ExpressionTests.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,13 @@ class ExpressionTests: XCTestCase {
296296

297297
func test_collateOperator_withStringExpression_buildsCollationExpression() {
298298
ExpectExecutionMatches("('A' COLLATE \"BINARY\")", collate(.Binary, stringA))
299-
ExpectExecutionMatches("('B' COLLATE \"NOCASE\")", collate(.NoCase, stringB))
300-
ExpectExecutionMatches("('A' COLLATE \"RTRIM\")", collate(.RTrim, stringA))
299+
ExpectExecutionMatches("('B' COLLATE \"NOCASE\")", collate(.Nocase, stringB))
300+
ExpectExecutionMatches("('A' COLLATE \"RTRIM\")", collate(.Rtrim, stringA))
301301

302-
let NoDiacritic = "NODIACRITIC"
303-
db.create(collation: NoDiacritic) { lhs, rhs in
302+
db.create(collation: "NODIACRITIC") { lhs, rhs in
304303
return lhs.compare(rhs, options: .DiacriticInsensitiveSearch)
305304
}
306-
ExpectExecutionMatches("('A' COLLATE \"NODIACRITIC\")", collate(.Custom(NoDiacritic), stringA))
305+
ExpectExecutionMatches("('A' COLLATE \"NODIACRITIC\")", collate(.Custom("NODIACRITIC"), stringA))
307306
}
308307

309308
func test_cast_buildsCastingExpressions() {

SQLite Tests/SchemaTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class SchemaTests: XCTestCase {
9696
func test_createTable_stringColumn_collation_buildsCollateClause() {
9797
ExpectExecution(db, "CREATE TABLE \"users\" (\"email\" TEXT NOT NULL COLLATE NOCASE)",
9898
db.create(table: users) { t in
99-
t.column(email, collate: .NoCase)
99+
t.column(email, collate: .Nocase)
100100
}
101101
)
102102
}
@@ -309,11 +309,11 @@ class SchemaTests: XCTestCase {
309309
let columnB = Expression<String?>("column_b")
310310

311311
ExpectExecution(db, "ALTER TABLE \"users\" ADD COLUMN \"column_a\" TEXT NOT NULL DEFAULT '' COLLATE \"NOCASE\"",
312-
db.alter(table: users, add: columnA, defaultValue: "", collate: .NoCase)
312+
db.alter(table: users, add: columnA, defaultValue: "", collate: .Nocase)
313313
)
314314

315315
ExpectExecution(db, "ALTER TABLE \"users\" ADD COLUMN \"column_b\" TEXT COLLATE \"NOCASE\"",
316-
db.alter(table: users, add: columnB, collate: .NoCase)
316+
db.alter(table: users, add: columnB, collate: .Nocase)
317317
)
318318
}
319319

SQLite/Expression.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ public enum Collation {
286286

287287
case Binary
288288

289-
case NoCase
289+
case Nocase
290290

291-
case RTrim
291+
case Rtrim
292292

293293
case Custom(String)
294294

@@ -300,9 +300,9 @@ extension Collation: Printable {
300300
switch self {
301301
case Binary:
302302
return "BINARY"
303-
case NoCase:
303+
case Nocase:
304304
return "NOCASE"
305-
case RTrim:
305+
case Rtrim:
306306
return "RTRIM"
307307
case Custom(let collation):
308308
return collation

0 commit comments

Comments
 (0)