You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-18Lines changed: 16 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -113,28 +113,26 @@ let database = try DB(config: config)
113
113
```
114
114
115
115
## Types
116
-
SQLite is a unique SQL database engine in that it is fairly lawless when it comes to typing. SQLite will allow you create a column with an `INTEGER` and gladly insert a `TEXT` into it. It will even let you make up your own type names and will take them. Otter only supports the core types/affinities SQLite recognizes:
117
-
```
118
-
INTEGER -> Int
119
-
REAL -> Double
120
-
TEXT -> String
121
-
BLOB -> Data
122
-
ANY -> SQLAny
123
-
```
124
-
125
-
> SQLite is the Javascript of SQL databases
126
-
>
127
-
> Richard Hipp, creator of SQLite
128
-
129
-
#### Aliasing & Custom Types
130
-
SQLite's core affinity types are few, but with aliasing types we can represent more complex types in Swift like `Date` or `UUID`.
116
+
SQLite is a unique SQL database engine in that it is fairly lawless when it comes to typing. SQLite will allow you create a column with an `INTEGER` and gladly insert a `TEXT` into it. It will even let you make up your own type names and will take them. Otter will not allow this and tends to operate more strictly like the table option `STRICT`. Only the core types that SQLite recognizes are usable for the column type.
117
+
| SQLite | Swift |
118
+
|---------|--------|
119
+
| INTEGER | Int |
120
+
| REAL | Double |
121
+
| TEXT | String |
122
+
| BLOB | Data |
123
+
| ANY | SQLAny |
124
+
125
+
#### Custom Types
126
+
While your column only can be one of the core SQLite types, what type that ends up as in Swift can be different. Using the `AS` keyword you can specify the Swift type to decode it to. Think of the column type as the storage type while the type in the `AS` will be the type actually in the interface.
131
127
132
128
Using the `AS` keyword you can specify the type to use in `Swift`
133
129
```sql
134
-
TEXTas UUID
135
-
130
+
-- UUID stored as a string
131
+
TEXTAS UUID
132
+
-- UUID stored as it's raw bytes
133
+
BLOB AS UUID
136
134
-- If the type has `.` in it, put the name in quotes to escape it.
0 commit comments