]> gitweb.factorcode.org Git - factor.git/commitdiff
add inheritance support for db.tuples
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 28 May 2008 22:02:58 +0000 (17:02 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 28 May 2008 22:02:58 +0000 (17:02 -0500)
extra/db/tuples/tuples-tests.factor
extra/db/tuples/tuples.factor

index 4da82d92d6a1167b75c3cce2a51e35af2480aa5c..b7c6fce933fa5ffe962a02c1c418284ca123ec76 100755 (executable)
@@ -414,6 +414,25 @@ TUPLE: does-not-persist ;
     [ class \ not-persistent = ] must-fail-with
 ] test-postgresql
 
+
+TUPLE: suparclass a ;
+
+suparclass f {
+    { "id" "ID" +db-assigned-id+ }
+    { "a" "A" INTEGER }
+} define-persistent
+
+TUPLE: subbclass < suparclass b ;
+
+subbclass "SUBCLASS" {
+    { "b" "B" TEXT }
+} define-persistent
+
+: test-db-inheritance ( -- )
+    [ ] [ subbclass ensure-table ] unit-test ;
+
+[ test-db-inheritance ] test-sqlite
+
 ! Don't comment these out. These words must infer
 \ bind-tuple must-infer
 \ insert-tuple must-infer
index c940d121bb7503ac9d0e5071b9c1e6ec355fcb01..0ffbd5bd47bd2f9d27a5a298fa5fadf408776ed9 100755 (executable)
@@ -19,7 +19,7 @@ ERROR: not-persistent ;
     "db-table" word-prop [ not-persistent ] unless* ;
 
 : db-columns ( class -- obj )
-    "db-columns" word-prop ;
+    superclasses [ "db-columns" word-prop ] map concat ;
 
 : db-relations ( class -- obj )
     "db-relations" word-prop ;