#5 Unnecessarily-verbose deletion SQL

Open
opened 8 months ago by kestrel · 0 comments
kestrel commented 8 months ago

The deletion support added in 9fece07a2b is unfortunately not generating particularly good SQL, though it is functional. The following is an example from one of the test cases, reformatted for clarity:

DELETE FROM `person`
WHERE `id` = (
    SELECT DISTINCT
        `person`.`id`
    FROM `person`
    WHERE `person`.`id` = ?
)

this was generated from the following test:

    #[test]
    fn delete_test() {
        let db = PeopleDB::open_path(":memory:").expect("couldn't open test db");

        let id = db
            .people
            .insert(Person {
                name: "person_name".to_string(),
                roles: Default::default(),
            })
            .expect("couldn't insert test person");
        assert!(db.people.by_id(id).expect("couldn't query db").is_some());

        db.people.with(id, &id).delete();

        assert!(db.people.by_id(id).expect("couldn't query db").is_none());
    }
The deletion support added in 9fece07a2b9c68782 is unfortunately not generating particularly good SQL, though it is functional. The following is an example from one of the test cases, reformatted for clarity: ```sql DELETE FROM `person` WHERE `id` = ( SELECT DISTINCT `person`.`id` FROM `person` WHERE `person`.`id` = ? ) ``` this was generated from the following test: ```rust #[test] fn delete_test() { let db = PeopleDB::open_path(":memory:").expect("couldn't open test db"); let id = db .people .insert(Person { name: "person_name".to_string(), roles: Default::default(), }) .expect("couldn't insert test person"); assert!(db.people.by_id(id).expect("couldn't query db").is_some()); db.people.with(id, &id).delete(); assert!(db.people.by_id(id).expect("couldn't query db").is_none()); } ```
Sign in to join this conversation.
No Label
No Milestone
No assignee
1 Participants
Loading...
Cancel
Save
There is no content yet.