CHANGELOG

This commit is contained in:
Gwendal Roué committed 2018-02-23 13:10:40 +01:00
1 parent b9af7e6a25
commit f2d9f50930
3 files changed
+41 -6

No files matched your search

+24 -1
View File
@@ -7,6 +7,8 @@ Release Notes
- `Record.updateChanges(_:)` now returns whether the record had unsaved changes, or not.
- `Database.columns(in:)` returns information about the columns of a table.
- Improved support for joined queries: check the new [Joined Queries Support](https://github.com/groue/GRDB.swift/blob/master/README.md#joined-queries-support) documentation chapter.
- `Request.adapted(_:)` is no longer experimental.
### API diff
@@ -24,12 +26,33 @@ Release Notes
func columnCount(in tableName: String) throws -> Int
+ func columns(in tableName: String) throws -> [ColumnInfo]
}
class Record {
- final func updateChanges(_ db: Database) throws
+ @discardableResult
+ final func updateChanges(_ db: Database) throws -> Bool
}
class Row {
+ var unscoped: Row
+ var containsNonNullValue: Bool
+ func hasNull(atIndex index: Int) -> Bool
+ subscript<Record: RowConvertible>(_ scope: String) -> Record
+ subscript<Record: RowConvertible>(_ scope: String) -> Record?
}
extension TableMapping {
+ static func selectionSQL(alias: String? = nil) -> String
+ static func numberOfSelectedColumns(_ db: Database) throws -> Int
}
+struct EmptyRowAdapter: RowAdapter { }
struct ScopeAdapter {
+ init(base: RowAdapter, scopes: [String: RowAdapter])
}
+func splittingRowAdapters(columnCounts: [Int]) -> [RowAdapter]
```
-2
View File
@@ -83,8 +83,6 @@ extension Request {
return AnyTypedRequest(self)
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// Returns an adapted request.
public func adapted(_ adapter: @escaping (Database) throws -> RowAdapter) -> AdaptedRequest<Self> {
return AdaptedRequest(self, adapter)
+17 -3
View File
@@ -1698,6 +1698,19 @@ let adapter = RangeRowAdapter(1..<2)
let row = try Row.fetchOne(db, "SELECT 0 AS a, 1 AS b, 2 AS c", adapter: adapter)!
```
### EmptyRowAdapter
`EmptyRowAdapter` hides all rows.
```swift
let adapter = EmptyRowAdapter()
let row = try Row.fetchOne(db, "SELECT 0 AS a, 1 AS b, 2 AS c", adapter: adapter)!
row.isEmpty // true
```
This limit adapter may turn out useful in some narrow use cases. You'll be happy to find it when you need it.
### ScopeAdapter
`ScopeAdapter` defines *row scopes*:
@@ -1709,7 +1722,7 @@ let adapter = ScopeAdapter([
let row = try Row.fetchOne(db, "SELECT 0 AS a, 1 AS b, 2 AS c, 3 AS d", adapter: adapter)!
```
ScopeAdapter does not change the columns and values of the fetched row. Instead, it defines *scopes*, which you access with the `scoped(on:)` method. It returns an optional Row, which is nil if the scope is missing.
ScopeAdapter does not change the columns and values of the fetched row. Instead, it defines *scopes*, which you access with the `Row.scoped(on:)` method. This method returns an optional Row, which is nil if the scope is missing.
```swift
row // <Row a:0 b:1 c:2 d:3>
@@ -1743,8 +1756,9 @@ rightRow.scoped(on: "right") // <Row d:3>
Any adapter can be extended with scopes:
```swift
let adapter = RangeRowAdapter(0..<2)
.addingScopes(["remainder": SuffixRowAdapter(fromIndex: 2)])
let baseAdapter = RangeRowAdapter(0..<2)
let adapter = ScopeAdapter(base: baseAdapter, scopes: [
"remainder": SuffixRowAdapter(fromIndex: 2)])
let row = try Row.fetchOne(db, "SELECT 0 AS a, 1 AS b, 2 AS c, 3 AS d", adapter: adapter)!
row // <Row a:0 b:1>