#5 Unnecessarily-verbose deletion SQL

Aperto
aperto 8 mesi fa da kestrel · 0 commenti
kestrel ha commentato 8 mesi fa

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.
Nessuna etichetta
Nessuna milestone
Nessun assegnatario
1 Partecipanti
Caricamento...
Annulla
Salva
Non ci sono ancora contenuti.