#5 Unnecessarily-verbose deletion SQL

Otwarty
otworzone 8 miesięcy temu przez kestrel · 0 komentarzy
kestrel skomentował 8 miesięcy temu

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()); } ```
Zaloguj się, aby dołączyć do tej rozmowy.
Brak etykiety
Brak kamienia milowego
Brak przypisania
1 uczestników
Ładowanie...
Anuluj
Zapisz
Nie ma jeszcze treści.