Permalink
Browse files

[fix] database, dropbox: fix after rebase for new DbAst and new binar…

…y type
  • Loading branch information...
1 parent e489263 commit 6d5e19c8ccc88267e9dca3edeabd895d3f6a8d96 @cedricss cedricss committed Sep 24, 2012
@@ -52,7 +52,7 @@ module Generator = struct
| DbAst.SFlds fields ->
List.find_map
(fun (fields, u) -> match fields with
- | [t] when t = field ->
+ | [`string t] when t = field ->
Some (if u = DbAst.SNil then DbAst.SStar else u)
| [_t] -> None
| _t::_q -> assert false
@@ -70,7 +70,7 @@ module Generator = struct
| DbAst.UFlds fields ->
List.find_map
(fun (fields, u) -> match fields with
- | t::q when t = field -> Some (annotmap, DbAst.UFlds [q, u])
+ | `string t::q when t = field -> Some (annotmap, DbAst.UFlds [q, u])
| _ -> None)
fields
| _ -> None
@@ -194,6 +194,7 @@ module Generator = struct
let annotmap, path =
let rpath = List.map (fun s -> `string s ) rpath in
expr_of_path gamma annotmap (`string dbname::rpath) in
+ let partial = List.map (fun s -> `string s) partial in
let annotmap, uexpr =
update_to_expr gamma annotmap dataty (DbAst.UFlds [partial, u])
in
@@ -99,7 +99,7 @@ DbDropbox = {{
notice(s) = Log.notice("DbGen/Dropbox", s)
uri_to_string(path) = Uri.to_string(~{path fragment=none query=[] is_directory=false is_from_root=false})
build_path(path) =
- path = DbCommon.path_to_id(path)
+ path = uri_to_string(path)
"/{path}.json"
build_folder_path(path) =
path = uri_to_string(path)
@@ -216,7 +216,7 @@ DbDropbox = {{
@package @server read_record(db:DbDropbox.t, creds, path:string, ty):option('data) =
match D(db).Files(db.root, path).get(none, creds) with
| { success = file } -> (
- value : DbDropbox.value = file.content
+ value : DbDropbox.value = string_of_binary(file.content)
match Json.deserialize(value) with
| { some = json } -> (
s = OpaSerialize.Json.unserialize_with_ty(json, ty)
@@ -246,7 +246,7 @@ DbDropbox = {{
@package @server gen_write(db:DbDropbox.t, path, data:string) =
match User(db).get_status() with
| {authenticated = creds} -> (
- json_value : DbDropbox.value = data
+ json_value : binary = binary_of_string(data : DbDropbox.value)
match D(db).Files(db.root, build_path(path)).put("application/json", json_value, true, none, creds) with
| { success = _ } -> true
| { failure = failure } -> do error("Impossible to write to {path}: {failure}") false )
@@ -415,4 +415,5 @@ DbDropbox = {{
@opacapi DbDropbox_read = DbDropbox.read
@opacapi DbDropbox_write = DbDropbox.write
@opacapi DbDropbox_option = DbDropbox.option
+@opacapi DbDropbox_expr_to_field = magicToString
@@ -283,7 +283,6 @@ DbMongo = {{
db = db.get()
ns = defaultns(db)
rid = DbCommon.path_to_id(rpath)
- vpath = build_vpath_sub(db, path, default, rpath, partial)
selector = [{name = "_id"; value = {String = rid}}]
tags = Bitwise.lor(0, MongoCommon.UpsertBit)
field = List.to_string_using("", "", ".", partial)
@@ -1032,7 +1031,6 @@ DbMongoSet = {{
read_map:DbMongoSet.engine('a) -> option('b),
write_map:'b -> list(Bson.document),
embed:option(string)):DbMongo.private.ref_path('b) =
- write_map:'b -> list(Bson.document)):DbMongo.private.ref_path('b) =
id = path_to_id(path)
vpath = build_vpath(db, path, selector, default, skip, limit, filter, read_map)
db0 = db.get()
@@ -1103,6 +1101,5 @@ DbMongoSet = {{
@opacapi DbMongoSet_build_rpath = DbMongoSet.build_rpath
@opacapi DbMongoSet_build_rpath_collection = DbMongoSet.build_rpath_collection
@opacapi DbMongoSet_default = Option.default
-@opacapi DbMongoSet_empty = {empty}
@opacapi DbMongo_expr_to_field(x) = Bson.encode_field(OpaSerialize.serialize(x))

0 comments on commit 6d5e19c

Please sign in to comment.