In the script below ``delete-tuples`` in line 8 from the end 
throws an error although the id 2 is not pointed to by any tree entry.

If I remove ``{ +foreign-id+ node "ID" }`` all works fine.

Do I understand ``+foreign-id+`` wrong ?

Georg
----------------------------------------------------------
USING:
    accessors
    db db.sqlite db.tuples db.types
    kernel libc prettyprint sequences
    ;
IN: test-script

TUPLE: node
    id
    ;
node "NODE" {
    { "id"      "ID"    INTEGER +db-assigned-id+ }
    } define-persistent

TUPLE: tree
    id node
    ;
tree "TREE" {
    { "id"      "ID"    INTEGER +db-assigned-id+ }
    ! { "node"    "NODE"  INTEGER }
    { "node"    "NODE"  INTEGER { +foreign-id+ node "ID" } }
    } define-persistent

: .db ( -- )
    node tree [ new select-tuples [ . ] each ] bi@
    ;
: main ( -- )

    node new [ insert-tuple ] [ id>> ] bi
    tree new swap >>node insert-tuple

    node new insert-tuple

    .db

    node new 2 >>id delete-tuples

    .db
    ;
"test.db"
[ "rm " prepend system drop ]
[ <sqlite-db> [ { node tree } ensure-tables main ] with-db ]
bi

------------------------------------------------------------------------------
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to