Skip to content

v1.9.1

Latest
Compare
Choose a tag to compare
@fnc12 fnc12 released this 03 Feb 18:14
5f1a2ce
⭐ drop_table_if_exists, drop_index_if_exists, drop_trigger_if_exists
storage.drop_table_if_exists("users");
storage.drop_index_if_exists("id_index");
storage.drop_trigger_if_exists("update_everything");

The main difference from existing drop_X APIs is that existing APIs don't send IF EXISTS string part to SQLite statement. So if you have to call DROP ... IF EXISTS now you have your functions.

⭐ PRAGMA locking_mode
locking_mode value = storage.pragma.locking_mode();
storage.pragma.locking_mode(locking_mode::EXCLUSIVE);
// or
storage.pragma.locking_mode(locking_mode::NORMAL);
⭐ PRAGMA max_page_count API (thanks to @akrisfx)
auto value = storage.pragma.max_page_count();  // PRAGMA max_page_count;
value += 2;
storage.pragma.max_page_count(value);  // PRAGMA max_page_count = value
⭐ Additional FOREIGN KEY API for inheritance

If you have a superclass for mapped classes and you have foreign key which references inherited class field you can use new API foreign_key(&ReferencingClass::fieldA).references<Subclass>(&Subclass::fieldB)

    struct Person {
        int id;
        std::string name;
        int age;
    };

    // Define derived class Student
    struct Student : public Person {
        std::string school_name;

        Student(int id, std::string name, int age, std::string school_name) :
            Person{id, std::move(name), age}, school_name(std::move(school_name)) {}
    };

    // Define derived class Teacher
    struct Teacher : public Person {
        std::string subject;
        double salary;

        Teacher(int id, std::string name, int age, std::string subject, double salary) :
            Person{id, std::move(name), age}, subject(subject), salary(salary) {}
    };

    // Define Classroom class referencing Teacher and Student
    struct Classroom {
        int id;
        int teacher_id;  // Foreign key referencing Teacher
        int student_id;  // Foreign key referencing Student
        std::string room_name;
    };

    auto storage =
        make_storage("",

                     // Define the Person table as a base, though it is not used directly
                     make_table<Person>("persons",
                                        make_column("id", &Person::id, primary_key().autoincrement()),
                                        make_column("name", &Person::name),
                                        make_column("age", &Person::age)),

                     // Define the Student table with foreign key inheritance
                     make_table<Student>("students",
                                         make_column("id", &Student::id, primary_key()),
                                         make_column("name", &Student::name),
                                         make_column("age", &Student::age),
                                         make_column("school_name", &Student::school_name)),

                     // Define the Teacher table with foreign key inheritance
                     make_table<Teacher>("teachers",
                                         make_column("id", &Teacher::id, primary_key()),
                                         make_column("name", &Teacher::name),
                                         make_column("age", &Teacher::age),
                                         make_column("subject", &Teacher::subject),
                                         make_column("salary", &Teacher::salary)),

                     // Define the Classroom table with foreign keys to Teacher and Student
                     make_table<Classroom>("classrooms",
                                           make_column("id", &Classroom::id, primary_key().autoincrement()),
                                           make_column("teacher_id", &Classroom::teacher_id),
                                           make_column("student_id", &Classroom::student_id),
                                           make_column("room_name", &Classroom::room_name),
                                           foreign_key(&Classroom::teacher_id).references<Teacher>(&Teacher::id),   //  <=== here it is
                                           foreign_key(&Classroom::student_id).references<Student>(&Student::id)));   //  <=== here it is
  • ⭐ Common Table Expressions for CRUD operations.
  • ⭐ Added C++ operator equivalents for bitwise operator expressions.
  • ⭐ Added the possibility of using unary minus expressions.
⚙️ Brand new std::any binding example

This new example shows you how powerful SQLite with sqlite_orm can be.

⚙️ VSCode integration

Now you can use VSCode tasks to make your developer experience easier when you contribute to sqlite_orm.
When you have sqlite_orm folder opened in VSCode hit Ctrl/CMD+Shift+P to show actions palette, select 'Run task' and select Run amalgamate script to call amalgamate script without interacting with terminal, Run clang-format to format all the repo and Run unit_tests to run unit_tests binary if you have at already compiled (expected that you've already configured and built the project using cmake)

  • ⚙️ Improved serializing logical and bitwise "not" expressions - less parentheses.
  • ⚙️ Placed constexpr strings used for serialization into the read-only segment, which makes resulting executable binaries smaller.
🐞List of bug fixes
  • #1353 (thanks to @uuiid)
  • #1354
  • Corrected serializing result set deduplicators DISTINCT and ALL.
  • Build script: Updated UCM CMake macros, got rid of a CMake deprecation warning. [https://github.com//issues/1266]
📝Regressions from v1.9:
  • The possibility to use rowset deduplication with struct was missing. [https://github.com//issues/1341]
  • Circumvented Clang's buggy pack indexing expression evaluation. [https://github.com//issues/1358]
  • Fixed regression of iterating mapped objects [Cudos to @stevenwdv]. [https://github.com//issues/1346]