add inheritance support for db.tuples

db4
Doug Coleman 2008-05-28 17:02:58 -05:00
parent f47ee3ef18
commit 8f06c94ee8
2 changed files with 20 additions and 1 deletions

View File

@ -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

View File

@ -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 ;