@@ -143,14 +143,19 @@ generated when writing queries will correctly use `"is_completed"`.
143
143
144
144
### Custom data types
145
145
146
- There are many data types that do not have native support in SQLite. For these data types you must
147
- define a conformance to ``QueryBindable`` in order to translate values to a format that SQLite does
148
- understand. The library comes with conformances to aid in representing dates, UUIDs, and JSON, and
149
- you can define your own conformances for your own custom data types.
146
+ StructuredQueries provides support for many basic Swift data types out of the box, like strings,
147
+ integers, doubles, bytes, and booleans, but you may want to represent custom, domain specific types
148
+ with your table's columns, instead. For these data types you must either define a conformance to
149
+ ``QueryBindable`` to translate values to a format that the library does understand, or provide a
150
+ ``QueryRepresentable`` type that wraps your domain type.
151
+
152
+ The library comes with several `QueryRepresentable` conformances to aid in representing dates,
153
+ UUIDs, and JSON, and you can define your own conformances for your own custom data types.
150
154
151
155
#### Dates
152
156
153
- SQLite does not have a native date type, and instead has 3 different ways to represent dates:
157
+ While some relational databases, like MySQL and Postgres, have native support for dates, SQLite
158
+ does _not_. Instead, it has 3 different ways to represent dates:
154
159
155
160
* Text column interpreted as ISO-8601-formatted string.
156
161
* Int column interpreted as number of seconds since Unix epoch.
@@ -203,6 +208,14 @@ And StructuredQueries will take care of formatting the value for the database:
203
208
}
204
209
}
205
210
211
+ When querying against a date column with a Swift date, you will need to explicitly bundle up the
212
+ Swift date into the appropriate representation to use various query helpers. This can be done using
213
+ the `#bind` macro:
214
+
215
+ ```swift
216
+ Reminder.where { $0.created > #bind(startDate) }
217
+ ```
218
+
206
219
#### UUID
207
220
208
221
SQLite also does not have native support for UUIDs. If you try to use a UUID in your tables you
@@ -238,6 +251,14 @@ translate the UUID to text:
238
251
}
239
252
```
240
253
254
+ When querying against a UUID column with a Swift UUID, you will need to explicitly bundle up the
255
+ Swift UUID into the appropriate representation to use various query helpers. This can be done using
256
+ the `#bind` macro:
257
+
258
+ ```swift
259
+ Reminder.where { $0.id != #bind(reminder.id) }
260
+ ```
261
+
241
262
#### RawRepresentable
242
263
243
264
Simple data types, in particular ones conforming to `RawRepresentable` whose `RawValue` is a string
0 commit comments