The following program returns '(#("demo" "j...@example.com")), whereas I
think it should return '(), because I expect deleting the row from "tUsers"
to delete the corresponding row in "tEmail". Is this a bug in the db
library (or elsewhere, or am I doing something wrong)?

#lang at-exp racket

(require db)

(define db
  (sqlite3-connect #:database 'memory))

(query-exec db
            @~a{
CREATE TABLE tUsers (
userUUID TEXT NOT NULL,
userName TEXT NOT NULL,
PRIMARY KEY (userUUID)
)
})

(query-exec db
            @~a{
CREATE TABLE tEmail (
userUUID TEXT NOT NULL,
userEmail TEXT NOT NULL,
PRIMARY KEY (userUUID,userEmail),
FOREIGN KEY (userUUID) REFERENCES tUsers
ON DELETE CASCADE ON UPDATE CASCADE
)
})

(query-exec db
            "INSERT INTO tUsers (userUUID,userName) VALUES (?,?)"
            "demo"
            "Jane Doe")

(query-exec db
            "INSERT INTO tEmail (userUUID,userEmail) VALUES (?,?)"
            "demo"
            "j...@example.com")

(query-exec db
            "DELETE FROM tUsers WHERE userUUID = ?"
            "demo")

(query-rows db "SELECT * FROM tEmail")

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to