Skip to content

Commit 648dd7a

Browse files
authored
Update README.md
1 parent 4461fd4 commit 648dd7a

1 file changed

Lines changed: 16 additions & 18 deletions

File tree

README.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -113,28 +113,26 @@ let database = try DB(config: config)
113113
```
114114

115115
## 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.
131127

132128
Using the `AS` keyword you can specify the type to use in `Swift`
133129
```sql
134-
TEXT as UUID
135-
130+
-- UUID stored as a string
131+
TEXT AS UUID
132+
-- UUID stored as it's raw bytes
133+
BLOB AS UUID
136134
-- If the type has `.` in it, put the name in quotes to escape it.
137-
TEXT as "Todo.ID"
135+
TEXT AS "Todo.ID"
138136
```
139137

140138
## Operators

0 commit comments

Comments
 (0)