Problem demonstrated below: violating a unique constraint in sqlite3 seems
to leave things in an inconsistent state.

Also, tangentially, I discovered this while trying to maintain my own id on
a table because my app is serving json objects over a rest api, and I need
some sort of unique id for clients to be able to send updates to existing
objects. If there were a way to have the autogenerated sql __id__ column be
a record field, that would be extremely useful.

martin

$ cat db.ml
type item = {
  id: int;
} with orm (
  unique: item<id>
)

let db_name = "test.db"

$ cat init_db.ml
open Db

let _ =
  let db = item_init Db.db_name in
  let item = {
    id = 1;
  } in
  item_save db item


$ ./init_db.native
$ ./init_db.native
Fatal error: exception Sqlite3.Error("CONSTRAINT")

$ sqlite3 test.db
sqlite> select * from item;
__id__      id
----------  ----------
1           1
2
sqlite> delete from item;
Error: no such function: SYNC_CACHE_item
_______________________________________________
MirageOS-devel mailing list
[email protected]
http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel

Reply via email to