#5 Unnecessarily-verbose deletion SQL

Ouvert
Créé il y a 8 mois par kestrel · 0 commentaires
kestrel a commenté il y a 8 mois

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()); } ```
Connectez-vous pour rejoindre cette conversation.
Pas d'étiquette
Aucun jalon
Pas d'assignataire
1 Participants
Chargement…
Annuler
Enregistrer
Il n'existe pas encore de contenu.