#5 Unnecessarily-verbose deletion SQL

Mở
%! (template.HTML=8 tháng trước cách đây)đang mở bởi kestrel · 0 ý kiến

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()); } ```
Đăng nhập để tham gia bình luận.
Không có nhãn
Không có Milestone
Không có người được phân công
1 tham gia
Đang tải...
Hủy bỏ
Lưu
Ở đây vẫn chưa có nội dung nào.