From c4f45e3f74687bf705143a39fd0e861ed7d81dba Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Thu, 12 Feb 2009 17:13:01 -0600 Subject: [PATCH] Fixing bug in db (don't use unparse!), adding still-failing unit test --- basis/db/queries/queries.factor | 2 +- basis/db/sqlite/sqlite-tests.factor | 23 +++++++++++++++++++++++ basis/db/types/types.factor | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/basis/db/queries/queries.factor b/basis/db/queries/queries.factor index 495c25ea68..c714f43687 100755 --- a/basis/db/queries/queries.factor +++ b/basis/db/queries/queries.factor @@ -48,7 +48,7 @@ M: retryable execute-statement* ( statement type -- ) : query-make ( class quot -- statements ) #! query, input, outputs, secondary queries - over unparse "table" set + over db-table "table" set [ sql-props ] dip [ 0 sql-counter rot with-variable ] curry { "" { } { } { } } nmake diff --git a/basis/db/sqlite/sqlite-tests.factor b/basis/db/sqlite/sqlite-tests.factor index 69d5f1dd43..657415c048 100644 --- a/basis/db/sqlite/sqlite-tests.factor +++ b/basis/db/sqlite/sqlite-tests.factor @@ -95,3 +95,26 @@ things "THINGS" { things drop-table ] with-db ] unit-test + +! Tables can have different names than the name of the tuple +TUPLE: foo slot ; +C: foo +foo "BAR" { { "slot" "SOMETHING" INTEGER +not-null+ } } define-persistent + +TUPLE: hi bye ; +C: hi +hi "HELLO" +{ { "bye" "BUHBYE" INTEGER { +foreign-id+ foo "SOMETHING" } } } define-persistent + +[ T{ foo { slot 1 } } T{ hi { bye 1 } } ] [ + test.db [ + foo create-table + hi create-table + 1 insert-tuple + f select-tuple + 1 insert-tuple + f select-tuple + hi drop-table + foo drop-table + ] with-db +] unit-test diff --git a/basis/db/types/types.factor b/basis/db/types/types.factor index b5a7db987a..51e4b42bdc 100755 --- a/basis/db/types/types.factor +++ b/basis/db/types/types.factor @@ -165,7 +165,7 @@ ERROR: no-column column ; : >reference-string ( string pair -- string ) first2 - [ [ unparse " " glue ] [ db-columns ] bi ] dip + [ [ db-table " " glue ] [ db-columns ] bi ] dip swap [ column-name>> = ] with find nip [ no-column ] unless* column-name>> "(" ")" surround append ;