|
50 | 50 | - [Custom Types](#custom-types) |
51 | 51 | - [Date-Time Values](#date-time-values) |
52 | 52 | - [Binary Data](#binary-data) |
53 | | - - [Custom Type Caveats](#custom-type-caveats) |
54 | 53 | - [Codable Types](#codable-types) |
55 | 54 | - [Other Operators](#other-operators) |
56 | 55 | - [Core SQLite Functions](#core-sqlite-functions) |
@@ -1410,9 +1409,6 @@ through before serialization and deserialization (see [Building Type-Safe SQL |
1410 | 1409 | > directly map SQLite types to Swift types. **Do _not_** conform custom types |
1411 | 1410 | > to the `Binding` protocol. |
1412 | 1411 |
|
1413 | | -Once extended, the type can be used [_almost_](#custom-type-caveats) wherever |
1414 | | -typed expressions can be. |
1415 | | - |
1416 | 1412 |
|
1417 | 1413 | ### Date-Time Values |
1418 | 1414 |
|
@@ -1458,49 +1454,6 @@ extension UIImage: Value { |
1458 | 1454 |
|
1459 | 1455 | [Archives and Serializations Programming Guide]: https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Archiving/Archiving.html |
1460 | 1456 |
|
1461 | | -### Custom Type Caveats |
1462 | | - |
1463 | | -Swift does _not_ currently support generic subscripting, which means we |
1464 | | -cannot, by default, subscript Expressions with custom types to: |
1465 | | - |
1466 | | - 1. **Namespace expressions**. Use the `namespace` function, instead: |
1467 | | - |
1468 | | - ```swift |
1469 | | - let avatar = Expression<UIImage?>("avatar") |
1470 | | - users[avatar] // fails to compile |
1471 | | - users.namespace(avatar) // "users"."avatar" |
1472 | | - ``` |
1473 | | - |
1474 | | - 2. **Access column data**. Use the `get` function, instead: |
1475 | | - |
1476 | | - ```swift |
1477 | | - let user = users.first! |
1478 | | - user[avatar] // fails to compile |
1479 | | - user.get(avatar) // UIImage? |
1480 | | - ``` |
1481 | | - |
1482 | | -We can, of course, write extensions, but they’re rather wordy. |
1483 | | - |
1484 | | -```swift |
1485 | | -extension Query { |
1486 | | - subscript(column: Expression<UIImage>) -> Expression<UIImage> { |
1487 | | - return namespace(column) |
1488 | | - } |
1489 | | - subscript(column: Expression<UIImage?>) -> Expression<UIImage?> { |
1490 | | - return namespace(column) |
1491 | | - } |
1492 | | -} |
1493 | | - |
1494 | | -extension Row { |
1495 | | - subscript(column: Expression<UIImage>) -> UIImage { |
1496 | | - return get(column) |
1497 | | - } |
1498 | | - subscript(column: Expression<UIImage?>) -> UIImage? { |
1499 | | - return get(column) |
1500 | | - } |
1501 | | -} |
1502 | | -``` |
1503 | | - |
1504 | 1457 | ## Codable Types |
1505 | 1458 |
|
1506 | 1459 | [Codable types][Encoding and Decoding Custom Types] were introduced as a part |
|
0 commit comments