820 Commits
Author SHA1 Message Date
Gwendal Roué a89dad2554 Fix Swiftlint warnings 2022-10-29 14:21:33 +02:00
Gwendal Roué 2ade133b50 Move availability check below doc comment 2022-10-20 08:27:46 +02:00
Josip Cavar c57e76be52 Add support for .strict table option in 3.37+ 2022-10-19 15:55:46 +02:00
Gwendal Roué 82b4d90a82 Xcode 14 RC doesn't ship with the Swift 5.6 stdlib
https://forums.swift.org/t/xcode-14-rc-cannot-specialize-protocol-type/60171
2022-09-09 08:16:55 +02:00
Gwendal Roué b0f7493765 BREAKING: rename request methods that build a DatabasePromise
This creates an opportunity for future `request.filter { ... }` apis that look like standard ones. Why not `Player.filter { $0.score > 1000 }` eventually, perhaps with code generation?
2022-09-06 22:56:40 +02:00
Gwendal Roué fdbcb07452 Fix #1275 2022-09-06 08:25:21 +02:00
Gwendal Roué 58f970701f BREAKING: Fix failing test for #1267
The regression was probably due to a bad interaction between Implicitly Opened Existentials (SE-0352) and Opaque Parameter Declarations (SE-0341) which GRDB 6 now uses in a lot of places.

Considering the sample code below:

    try db.create(table: ...) { t in
      t.column(...).check { $0 != Column(...) }
    }

- The `check` method accepts a closure that returns `any SQLExpressible` (the same as GRDB 5)
- The `!=` SQL comparison operator is `(some SQLSpecificExpressible, some SQLSpecificExpressible) -> SQLExpression`, when it was `(SQLSpecificExpressible, SQLSpecificExpressible) -> SQLExpression` in GRDB 5

The compiler has started preferring interpreting the != operator as Column's Equatable implementation, instead of the `!=` SQL comparison operator

We force the compiler to use the SQL comparison operator by removing the Equatable conformance from Column. It was introduced in a70b42c, as a support for a feature that has been removed since then.

This is a breaking change, but this also is an improvement. Now `column1 != column2` has a single meaning, and the library is less prone to similar regressions in the future.
2022-08-25 08:26:37 +02:00
Gwendal Roué c6657b7063 ColumnAssignment that does nothing
A cool upsert feature is to overwrite an existing value in case of conflict, but another cool upsert feature is to NOT overwrite an existing value. This commit makes it possible to create a ColumnAssignement that does nothing.
2022-08-23 20:02:17 +02:00
Gwendal Roué 2789444acd Enable UPSERT and RETURNING with SQLCipher 2022-08-21 21:22:34 +02:00
Gwendal Roué a702fe6bc9 BREAKING: persistence callbacks, and support for RETURNING
- Replace performInsert, performUpdate, etc with callbacks: willInsert, aroundInsert, didInsert, etc.
- Always call didInsert, even with INSERT OR IGNORE
- Explicit conflict resolution in persistence methods
- Add ...AndFetch... methods
2022-08-21 21:22:34 +02:00
Gwendal Roué c553d2d69e Documentation 2022-08-21 21:22:34 +02:00
Gwendal Roué 5243db7fbc Spelling 2022-08-21 21:22:34 +02:00
Gwendal Roué 4ced8c78e7 Less "iff" (some people think this is a typo)
iff = if and only if
2022-08-21 21:22:34 +02:00
Gwendal Roué c38d903f4d Make RequestProtocols.swift easier to read 2022-08-21 21:22:34 +02:00
Gwendal Roué 1239c14e6d Explicit initializers for HasOneThrough and HasManyThrough associations 2022-08-21 21:22:34 +02:00
Gwendal Roué c86581dedc Make SQLQueryGenerator.swift easier to read 2022-08-21 21:22:34 +02:00
Gwendal Roué 1bfba945d3 Fix invalid Swift syntax in documentation 2022-08-21 21:22:34 +02:00
Gwendal Roué 4c73456f86 Make SQL.swift easier to read 2022-08-21 21:22:34 +02:00
Gwendal Roué 5b7c58faf4 Make Database+Schema.swift easier to read 2022-08-21 21:22:34 +02:00
Gwendal Roué b2eafd4a13 SE-0361: Extensions on bound generic types
https://github.com/apple/swift-evolution/blob/main/proposals/0361-bound-generic-extensions.md
2022-08-21 21:22:34 +02:00
Gwendal Roué 36892fee55 BREAKING: Bump minimum SQLite version to 3.19.3 2022-08-21 21:22:34 +02:00
Gwendal Roué 80ec31f588 BREAKING: remove DerivableRequest.limit(_:offset:) 2022-08-21 21:22:34 +02:00
Gwendal Roué 895964de16 BREAKING: Throwing FetchableRecord.init(row:) 2022-08-21 21:22:34 +02:00
Gwendal Roué 11a6d53d8a SE-0326: closure result type inference
https://github.com/apple/swift-evolution/blob/main/proposals/0326-extending-multi-statement-closure-inference.md
2022-08-21 21:22:34 +02:00
Gwendal Roué 42987dd849 Cleanup filter(rawKeys:) 2022-08-21 21:22:34 +02:00
Gwendal Roué 7ffc332327 BREAKING: replace selectID() with selectPrimaryKey(as:)
Since Optional is a database value like others, selectID would be a request of optionals for records with an optional ID type:

    struct Player: Identifiable, MutablePersistableRecord {
        var id: Int64?
    }

    Player.selectID() // QueryInterface<Int64?>

This is not good, because primary keys are not null. And those requests would fetch impractical types such as [Int64?], Set<Int64?>, Int64??.

Instead, we introduce selectPrimaryKey(as:), which allows the user to provide the desired type.

    Player.selectPrimaryKey(as: Int64.self) // QueryInterface<Int64>
2022-08-21 21:22:34 +02:00
Gwendal Roué a9fcf1b9c1 SE-0335, SE-0341, SE-0346, SE-0352, SE-0358: some, any, primary associated types 2022-08-21 21:22:34 +02:00
Gwendal Roué c0c6b34869 SE-0346: primary associated types 2022-08-21 21:22:34 +02:00
Gwendal Roué dd55175978 SE-0345: if let x { }
https://github.com/apple/swift-evolution/blob/main/proposals/0345-if-let-shorthand.md
2022-08-21 21:22:34 +02:00
Gwendal Roué 58293befc9 BREAKING: Optional is a database value like others 2022-08-21 21:22:34 +02:00
Gwendal Roué fe225fe452 BREAKING: Remove deprecated methods 2022-08-21 19:21:57 +02:00
Gwendal Roué 23cbf13af0 Swift 5.7 required: Availability checks 2022-08-21 19:21:57 +02:00
Gwendal Roué 6da7d47394 Swift 5.7 required: Remove compiler checks 2022-08-21 19:21:57 +02:00
Ethan Wong f313a43ef9 Update doc issue on TableRequest.filter(keys:). 2022-05-07 13:32:31 +08:00
Gwendal Roué 09922c34ff Code formatting 2022-01-23 12:24:34 +01:00
Gwendal Roué 301fb34702 Fix failing test for including(all:) on limited request and composite primary keys 2022-01-21 13:42:42 +01:00
Gwendal Roué 28109a3947 Merge pull request #1144 from TimAEllis/feature/add-drop-column
Add drop column support
2022-01-19 08:06:24 +01:00
BB9z 6d3f309cad Fix typos 2022-01-19 00:10:42 +08:00
Timothy Ellis daf44d9baa Exposed drop(column:) to custom builds and cipher 2022-01-18 10:11:12 +11:00
Timothy Ellis 869d776962 Added drop column support 2022-01-17 10:02:04 +11:00
Gwendal Roué 95f1d83d78 The .strict table creation option
The .strict table creation option

The .strict table creation option
2022-01-09 17:01:37 +01:00
Gwendal Roué 76523db5b9 Removed undesired :nodoc: comment 2022-01-07 14:58:42 +01:00
Gwendal Roué c0305853bc Enhance fatal error message for reversed literal ordering terms 2022-01-07 14:43:57 +01:00
Gwendal Roué bdf54e80a9 Mention detached columns in the documentation of expression.forKey(_:) 2022-01-07 13:30:27 +01:00
Gwendal Roué e799c8534e ColumnExpression.detached 2022-01-07 10:07:15 +01:00
Gwendal Roué c945504a34 Addition and substraction are not bijective functions (due to floating point rounding errors) 2021-12-21 11:13:28 +01:00
Gwendal Roué 8217966215 Table creation methods accept throwing closures 2021-12-21 09:26:55 +01:00
Gwendal Roué 89421c92fb More support for inclusion checks with explicit collation
This commit addresses https://github.com/groue/GRDB.swift/issues/1094

The position of the `collating` method is now irrelevant in all those cases:

// name COLLATE NOCASE IN ('foo', 'bar')
["foo", "bar"].contains(Column("name")).collating(.nocase)
["foo", "bar"].contains(Column("name").collating(.nocase))

// name BETWEEN 'foo' AND 'bar' COLLATE NOCASE
("foo"..."bar").contains(Column("name")).collating(.nocase)
("foo"..."bar").contains(Column("name").collating(.nocase))

// (name >= 'foo' COLLATE NOCASE) AND (name < 'bar' COLLATE NOCASE)
("foo"..<"bar").contains(Column("name")).collating(.nocase)
("foo"..<"bar").contains(Column("name").collating(.nocase))
2021-12-14 12:45:50 +01:00
Gwendal Roué 7001b60cf7 More support for association existence check
New: support for associated tables WITHOUT ROWID with a compound primary key
New: support for associated views

Checking for the existence of associated CTEs is still not implemented (it fails with "table does not exist" error).
2021-12-12 16:43:40 +01:00
Gwendal Roué ae609cec3b Support for the TOTAL SQL aggregate function 2021-12-12 14:46:43 +01:00