Closed helje5 closed 2 years ago
Inserts for integer primary keys use SQLite to generate the actual key, e.g.
CREATE TABLE person ( person_id INTEGER PRIMARY KEY NOT NULL, name TEXT );
This is generated into:
struct Person { var id : Int var name : String? init(id: Int, name: String? = nil) {...} }
Which is a little inconvenient for inserts:
var person = Person(id: 0, name: "Donald") person = try db.insert(person)
(the return value of the insert will have copy of the record with the proper db assigned primary key).
Maybe this should be some, ideally unlikely, obscure default value, like:
init(id: Int = MyDB.defaultIntPrimaryKey, name: String? = nil) { ... } extension MyDB { static let MyDB.defaultIntPrimaryKey : Int = -0xDEADBEEF }
Not quite sure whether that is actually good or not, maybe it is OK as an optional generation option.
Implemented, using Int.min
Int.min
Inserts for integer primary keys use SQLite to generate the actual key, e.g.
This is generated into:
Which is a little inconvenient for inserts:
(the return value of the insert will have copy of the record with the proper db assigned primary key).
Maybe this should be some, ideally unlikely, obscure default value, like:
Not quite sure whether that is actually good or not, maybe it is OK as an optional generation option.