]> gitweb.factorcode.org Git - factor.git/commitdiff
revised tuple oid handling
authorSascha Matzke <sascha.matzke@didolo.org>
Sat, 5 Jun 2010 10:59:50 +0000 (12:59 +0200)
committerSascha Matzke <sascha.matzke@didolo.org>
Sat, 5 Jun 2010 10:59:50 +0000 (12:59 +0200)
extra/mongodb/tuple/persistent/persistent.factor
extra/mongodb/tuple/tuple.factor

index bc6a6c0f8012cac13f690ca40e4a7338b0ac387c..d24e88f90e3e334ded95eb4348dcfbef3400f4aa 100644 (file)
@@ -78,9 +78,6 @@ CONSTRUCTOR: cond-value ( value quot -- cond-value ) ;
 : prepare-assoc ( tuple -- assoc mirror tuple assoc )
    H{ } clone swap [ <mirror> ] keep pick ; inline
 
-: ensure-mdb-info ( tuple -- tuple )    
-   dup id>> [ <oid> >>id ] unless ; inline
-
 : with-object-map ( quot: ( -- ) -- store-assoc )
    [ H{ } clone dup object-map ] dip with-variable ; inline
 
@@ -92,11 +89,14 @@ PRIVATE>
 
 GENERIC: tuple>storable ( tuple -- storable )
 
+: ensure-oid ( tuple -- tuple )
+   dup id>> [ <oid> >>id ] unless ; inline
+
 M: mdb-persistent tuple>storable ( mdb-persistent -- object-map )
    '[ _ [ tuple>assoc ] write-mdb-persistent drop ] with-object-map ; inline
 
 M: mdb-persistent tuple>assoc ( tuple -- assoc )
-   ensure-mdb-info (tuple>assoc) ;
+   ensure-oid (tuple>assoc) ;
 
 M: tuple tuple>assoc ( tuple -- assoc )
    (tuple>assoc) ;
index df5a541f6659fde655e4bc1a1050f5b828093d69..2f235f74a0a9c47c925318b6cd8c49e2bcac1fbb 100644 (file)
@@ -61,7 +61,7 @@ PRIVATE>
  
 : update-tuple ( tuple -- )
     [ tuple-collection name>> ]
-    [ id-selector ]
+    [ ensure-oid id-selector ]
     [ tuple>assoc ] tri
     <update> >upsert update ;