Fixed multi-index bug.
[didex.git] / didex / index.py
index 5b5a5bc..0608318 100644 (file)
@@ -2,7 +2,7 @@ import struct, contextlib, math
 from . import db, lib
 from .db import bd, txnfun, dloopfun
 
-__all__ = ["maybe", "t_int", "t_uint", "t_dbid", "t_float", "t_str", "t_casestr", "ordered"]
+__all__ = ["maybe", "t_bool", "t_int", "t_uint", "t_dbid", "t_float", "t_str", "t_casestr", "ordered"]
 
 deadlock = bd.DBLockDeadlockError
 notfound = bd.DBNotFoundError
@@ -140,6 +140,7 @@ def floatcmp(a, b):
     else:
         return 0
 
+t_bool = simpletype((lambda ob: b"\x01" if ob else b"\x00"), (lambda dat: False if dat == b"x\00" else True))
 t_int = simpletype.struct(">q")
 t_uint = simpletype.struct(">Q")
 t_dbid = t_uint
@@ -309,7 +310,7 @@ class ordered(index, lib.closable):
             if not done:
                 cur.close()
 
-    @txnfun(lambda self: self.db.env.env)
+    @txnfun(lambda self: self.db.env)
     def put(self, key, id, *, tx):
         obid = struct.pack(">Q", id)
         if not self.db.ob.has_key(obid, txn=tx.tx):
@@ -320,7 +321,7 @@ class ordered(index, lib.closable):
             return False
         return True
 
-    @txnfun(lambda self: self.db.env.env)
+    @txnfun(lambda self: self.db.env)
     def remove(self, key, id, *, tx):
         obid = struct.pack(">Q", id)
         if not self.db.ob.has_key(obid, txn=tx.tx):