Skip to content

Commit 1837266

Browse files
committed
Swift3 enum casing
1 parent 33f712d commit 1837266

File tree

7 files changed

+46
-46
lines changed

7 files changed

+46
-46
lines changed

Documentation/Index.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ On iOS, you can create a writable database in your app’s **Documents** directo
192192

193193
``` swift
194194
let path = NSSearchPathForDirectoriesInDomains(
195-
.DocumentDirectory, .UserDomainMask, true
195+
.documentDirectory, .userDomainMask, true
196196
).first!
197197

198198
let db = try Connection("\(path)/db.sqlite3")
@@ -202,7 +202,7 @@ On OS X, you can use your app’s **Application Support** directory:
202202

203203
``` swift
204204
var path = NSSearchPathForDirectoriesInDomains(
205-
.ApplicationSupportDirectory, .UserDomainMask, true
205+
.applicationSupportDirectory, .userDomainMask, true
206206
).first! + NSBundle.mainBundle().bundleIdentifier!
207207

208208
// create parent directory iff it doesn’t exist
@@ -225,21 +225,21 @@ let db = try Connection(path, readonly: true)
225225
```
226226

227227
> _Note:_ Signed applications cannot modify their bundle resources. If you bundle a database file with your app for the purpose of bootstrapping, copy it to a writable location _before_ establishing a connection (see [Read-Write Databases](#read-write-databases), above, for typical, writable locations).
228-
>
228+
>
229229
> See these two Stack Overflow questions for more information about iOS apps with SQLite databases: [1](https://stackoverflow.com/questions/34609746/what-different-between-store-database-in-different-locations-in-ios), [2](https://stackoverflow.com/questions/34614968/ios-how-to-copy-pre-seeded-database-at-the-first-running-app-with-sqlite-swift). We welcome sample code to show how to successfully copy and use a bundled "seed" database for writing in an app.
230230

231231
#### In-Memory Databases
232232

233233
If you omit the path, SQLite.swift will provision an [in-memory database](https://www.sqlite.org/inmemorydb.html).
234234

235235
``` swift
236-
let db = try Connection() // equivalent to `Connection(.InMemory)`
236+
let db = try Connection() // equivalent to `Connection(.inMemory)`
237237
```
238238

239239
To create a temporary, disk-backed database, pass an empty file name.
240240

241241
``` swift
242-
let db = try Connection(.Temporary)
242+
let db = try Connection(.temporary)
243243
```
244244

245245
In-memory databases are automatically deleted when the database connection is closed.
@@ -367,15 +367,15 @@ The `column` function is used for a single column definition. It takes an [expre
367367
t.column(id, primaryKey: true)
368368
// "id" INTEGER PRIMARY KEY NOT NULL
369369

370-
t.column(id, primaryKey: .Autoincrement)
370+
t.column(id, primaryKey: .autoincrement)
371371
// "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
372372
```
373373

374374
> _Note:_ The `primaryKey` parameter cannot be used alongside `references`. If you need to create a column that has a default value and is also a primary and/or foreign key, use the `primaryKey` and `foreignKey` functions mentioned under [Table Constraints](#table-constraints).
375375
>
376376
> Primary keys cannot be optional (_e.g._, `Expression<Int64?>`).
377377
>
378-
> Only an `INTEGER PRIMARY KEY` can take `.Autoincrement`.
378+
> Only an `INTEGER PRIMARY KEY` can take `.autoincrement`.
379379

380380
- `unique` adds a `UNIQUE` constraint to the column. (See the `unique` function under [Table Constraints](#table-constraints) for uniqueness over multiple columns).
381381

@@ -403,10 +403,10 @@ The `column` function is used for a single column definition. It takes an [expre
403403
- `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.
404404

405405
``` swift
406-
t.column(email, collate: .Nocase)
406+
t.column(email, collate: .nocase)
407407
// "email" TEXT NOT NULL COLLATE "NOCASE"
408408

409-
t.column(name, collate: .Rtrim)
409+
t.column(name, collate: .rtrim)
410410
// "name" TEXT COLLATE "RTRIM"
411411
```
412412

@@ -454,7 +454,7 @@ Additional constraints may be provided outside the scope of a single column usin
454454
- `foreignKey` adds a `FOREIGN KEY` constraint to the table. Unlike [the `references` constraint, above](#column-constraints), it supports all SQLite types, both [`ON UPDATE` and `ON DELETE` actions](https://www.sqlite.org/foreignkeys.html#fk_actions), and composite (multiple column) keys.
455455

456456
``` swift
457-
t.foreignKey(user_id, references: users, id, delete: .SetNull)
457+
t.foreignKey(user_id, references: users, id, delete: .setNull)
458458
// FOREIGN KEY("user_id") REFERENCES "users"("id") ON DELETE SET NULL
459459
```
460460

@@ -471,7 +471,7 @@ We can insert rows into a table by calling a [query’s](#queries) `insert` func
471471
try db.run(users.insert(email <- "alice@mac.com", name <- "Alice"))
472472
// INSERT INTO "users" ("email", "name") VALUES ('alice@mac.com', 'Alice')
473473

474-
try db.run(users.insert(or: .Replace, email <- "alice@mac.com", name <- "Alice B."))
474+
try db.run(users.insert(or: .replace, email <- "alice@mac.com", name <- "Alice B."))
475475
// INSERT OR REPLACE INTO "users" ("email", "name") VALUES ('alice@mac.com', 'Alice B.')
476476
```
477477

@@ -637,7 +637,7 @@ users.join(posts, on: user_id == users[id])
637637
// SELECT * FROM "users" INNER JOIN "posts" ON ("user_id" = "users"."id")
638638
```
639639

640-
The `join` function takes a [query](#queries) object (for the table being joined on), a join condition (`on`), and is prefixed with an optional join type (default: `.Inner`). Join conditions can be built using [filter operators and functions](#filter-operators-and-functions), generally require [namespacing](#column-namespacing), and sometimes require [aliasing](#table-aliasing).
640+
The `join` function takes a [query](#queries) object (for the table being joined on), a join condition (`on`), and is prefixed with an optional join type (default: `.inner`). Join conditions can be built using [filter operators and functions](#filter-operators-and-functions), generally require [namespacing](#column-namespacing), and sometimes require [aliasing](#table-aliasing).
641641

642642

643643
##### Column Namespacing
@@ -996,10 +996,10 @@ The `addColumn` function shares several of the same [`column` function parameter
996996
- `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.
997997

998998
``` swift
999-
try db.run(users.addColumn(email, collate: .Nocase))
999+
try db.run(users.addColumn(email, collate: .nocase))
10001000
// ALTER TABLE "users" ADD COLUMN "email" TEXT NOT NULL COLLATE "NOCASE"
10011001

1002-
try db.run(users.addColumn(name, collate: .Rtrim))
1002+
try db.run(users.addColumn(name, collate: .rtrim))
10031003
// ALTER TABLE "users" ADD COLUMN "name" TEXT COLLATE "RTRIM"
10041004
```
10051005

@@ -1367,14 +1367,14 @@ We can create custom collating sequences by calling `createCollation` on a datab
13671367

13681368
``` swift
13691369
try db.createCollation("NODIACRITIC") { lhs, rhs in
1370-
return lhs.compare(rhs, options: .DiacriticInsensitiveSearch)
1370+
return lhs.compare(rhs, options: .diacriticInsensitiveSearch)
13711371
}
13721372
```
13731373

13741374
We can reference a custom collation using the `Custom` member of the `Collation` enumeration.
13751375

13761376
``` swift
1377-
restaurants.order(collate(.Custom("NODIACRITIC"), name))
1377+
restaurants.order(collate(.custom("NODIACRITIC"), name))
13781378
// SELECT * FROM "restaurants" ORDER BY "name" COLLATE "NODIACRITIC"
13791379
```
13801380

@@ -1409,7 +1409,7 @@ let config = FTS4Config()
14091409
.column(subject)
14101410
.column(body, [.unindexed])
14111411
.languageId("lid")
1412-
.order(.Desc)
1412+
.order(.desc)
14131413

14141414
try db.run(emails.create(.FTS4(config))
14151415
// CREATE VIRTUAL TABLE "emails" USING fts4("subject", "body", notindexed="body", languageid="lid", order="desc")

SQLite/Core/Connection.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,13 @@ public final class Connection {
274274
public enum TransactionMode : String {
275275

276276
/// Defers locking the database till the first read/write executes.
277-
case Deferred = "DEFERRED"
277+
case deferred = "DEFERRED"
278278

279279
/// Immediately acquires a reserved lock on the database.
280-
case Immediate = "IMMEDIATE"
280+
case immediate = "IMMEDIATE"
281281

282282
/// Immediately acquires an exclusive lock on all databases.
283-
case Exclusive = "EXCLUSIVE"
283+
case exclusive = "EXCLUSIVE"
284284

285285
}
286286

@@ -301,7 +301,7 @@ public final class Connection {
301301
/// must throw to roll the transaction back.
302302
///
303303
/// - Throws: `Result.Error`, and rethrows.
304-
public func transaction(_ mode: TransactionMode = .Deferred, block: @escaping () throws -> Void) throws {
304+
public func transaction(_ mode: TransactionMode = .deferred, block: @escaping () throws -> Void) throws {
305305
try transaction("BEGIN \(mode.rawValue) TRANSACTION", block, "COMMIT TRANSACTION", or: "ROLLBACK TRANSACTION")
306306
}
307307

SQLite/Typed/Query.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ extension QueryType {
221221
///
222222
/// - Returns: A query with the given `JOIN` clause applied.
223223
public func join(_ table: QueryType, on condition: Expression<Bool?>) -> Self {
224-
return join(.Inner, table, on: condition)
224+
return join(.inner, table, on: condition)
225225
}
226226

227227
/// Adds a `JOIN` clause to the query.
@@ -401,7 +401,7 @@ extension QueryType {
401401
public func order(_ by: Expressible...) -> Self {
402402
return order(by)
403403
}
404-
404+
405405
/// Sets an `ORDER BY` clause on the query.
406406
///
407407
/// let users = Table("users")
@@ -1100,28 +1100,28 @@ public struct Row {
11001100
public enum JoinType : String {
11011101

11021102
/// A `CROSS` join.
1103-
case Cross = "CROSS"
1103+
case cross = "CROSS"
11041104

11051105
/// An `INNER` join.
1106-
case Inner = "INNER"
1106+
case inner = "INNER"
11071107

11081108
/// A `LEFT OUTER` join.
1109-
case LeftOuter = "LEFT OUTER"
1109+
case leftOuter = "LEFT OUTER"
11101110

11111111
}
11121112

11131113
/// ON CONFLICT resolutions.
11141114
public enum OnConflict: String {
11151115

1116-
case Replace = "REPLACE"
1116+
case replace = "REPLACE"
11171117

1118-
case Rollback = "ROLLBACK"
1118+
case rollback = "ROLLBACK"
11191119

1120-
case Abort = "ABORT"
1120+
case abort = "ABORT"
11211121

1122-
case Fail = "FAIL"
1122+
case fail = "FAIL"
11231123

1124-
case Ignore = "IGNORE"
1124+
case ignore = "IGNORE"
11251125

11261126
}
11271127

SQLite/Typed/Schema.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,16 +369,16 @@ public final class TableBuilder {
369369

370370
public enum Dependency: String {
371371

372-
case NoAction = "NO ACTION"
372+
case noAction = "NO ACTION"
373373

374-
case Restrict = "RESTRICT"
374+
case restrict = "RESTRICT"
375375

376-
case SetNull = "SET NULL"
376+
case setNull = "SET NULL"
377377

378-
case SetDefault = "SET DEFAULT"
378+
case setDefault = "SET DEFAULT"
379+
380+
case cascade = "CASCADE"
379381

380-
case Cascade = "CASCADE"
381-
382382
}
383383

384384
public func foreignKey<T : Value>(_ column: Expression<T>, references table: QueryType, _ other: Expression<T>, update: Dependency? = nil, delete: Dependency? = nil) {

SQLiteTests/ConnectionTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,19 @@ class ConnectionTests : SQLiteTestCase {
9595
}
9696

9797
func test_transaction_executesBeginDeferred() {
98-
try! db.transaction(.Deferred) {}
98+
try! db.transaction(.deferred) {}
9999

100100
AssertSQL("BEGIN DEFERRED TRANSACTION")
101101
}
102102

103103
func test_transaction_executesBeginImmediate() {
104-
try! db.transaction(.Immediate) {}
104+
try! db.transaction(.immediate) {}
105105

106106
AssertSQL("BEGIN IMMEDIATE TRANSACTION")
107107
}
108108

109109
func test_transaction_executesBeginExclusive() {
110-
try! db.transaction(.Exclusive) {}
110+
try! db.transaction(.exclusive) {}
111111

112112
AssertSQL("BEGIN EXCLUSIVE TRANSACTION")
113113
}

SQLiteTests/QueryTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ class QueryTests : XCTestCase {
2020
func test_select_withExpression_compilesSelectClause() {
2121
AssertSQL("SELECT \"email\" FROM \"users\"", users.select(email))
2222
}
23-
23+
2424
func test_select_withStarExpression_compilesSelectClause() {
2525
AssertSQL("SELECT * FROM \"users\"", users.select(*))
2626
}
27-
27+
2828
func test_select_withNamespacedStarExpression_compilesSelectClause() {
2929
AssertSQL("SELECT \"users\".* FROM \"users\"", users.select(users[*]))
3030
}
@@ -59,12 +59,12 @@ class QueryTests : XCTestCase {
5959
func test_join_withExplicitType_compilesJoinClauseWithType() {
6060
AssertSQL(
6161
"SELECT * FROM \"users\" LEFT OUTER JOIN \"posts\" ON (\"posts\".\"user_id\" = \"users\".\"id\")",
62-
users.join(.LeftOuter, posts, on: posts[userId] == users[id])
62+
users.join(.leftOuter, posts, on: posts[userId] == users[id])
6363
)
6464

6565
AssertSQL(
6666
"SELECT * FROM \"users\" CROSS JOIN \"posts\" ON (\"posts\".\"user_id\" = \"users\".\"id\")",
67-
users.join(.Cross, posts, on: posts[userId] == users[id])
67+
users.join(.cross, posts, on: posts[userId] == users[id])
6868
)
6969
}
7070

@@ -192,7 +192,7 @@ class QueryTests : XCTestCase {
192192
func test_insert_withOnConflict_compilesInsertOrOnConflictExpression() {
193193
AssertSQL(
194194
"INSERT OR REPLACE INTO \"users\" (\"email\", \"age\") VALUES ('alice@example.com', 30)",
195-
users.insert(or: .Replace, email <- "alice@example.com", age <- 30)
195+
users.insert(or: .replace, email <- "alice@example.com", age <- 30)
196196
)
197197
}
198198

SQLiteTests/SchemaTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ class SchemaTests : XCTestCase {
568568

569569
XCTAssertEqual(
570570
"CREATE TABLE \"table\" (FOREIGN KEY (\"string\") REFERENCES \"table\" (\"string\") ON UPDATE CASCADE ON DELETE SET NULL)",
571-
table.create { t in t.foreignKey(string, references: table, string, update: .Cascade, delete: .SetNull) }
571+
table.create { t in t.foreignKey(string, references: table, string, update: .cascade, delete: .setNull) }
572572
)
573573

574574
XCTAssertEqual(

0 commit comments

Comments
 (0)