Git Product home page Git Product logo

Comments (5)

tamimattafi avatar tamimattafi commented on July 18, 2024

According to this answer and many others, we need to make these changes:

  1. Make all constraints DEFERRED inside one transaction
  2. Adjust insert order for compounds and lists and call notifyQuery only after all SQL operations
  3. Wrap database operations such as create, migrate, clear and drop inside a transaction and turn off foreign keys using PRAGMA

from kabin.

tamimattafi avatar tamimattafi commented on July 18, 2024
  1. Make all constraints DEFERRED inside one transaction

In order to make the first point work correctly, all foreign keys should be created as DEFERRABLE INITIALLY IMMEDIATE by default, and DEFERRABLE INITIALLY DEFERRED

Changed here: 022636f

This means that projects adopting these changes, should update their database version

from kabin.

tamimattafi avatar tamimattafi commented on July 18, 2024
  1. Make all constraints DEFERRED inside one transaction

Some deeper research showed that room uses PRAGMA syntax to make foreign keys DEFERRED inside a transaction, which seems like a better option than SET CONSTRAINTS ALL DEFERRED since it's rolled back once the transaction ends, and you don't have to do it manually.

More info: https://sqlite.org/pragma.html#pragma_defer_foreign_keys

from kabin.

tamimattafi avatar tamimattafi commented on July 18, 2024

1- Make all constraints DEFERRED inside one transaction
3- Wrap database operations such as create, migrate, clear and drop inside a transaction and turn off foreign keys using PRAGMA

In order to achieve this type of control over foreign keys, KabinDatabaseConfiguration had to be changed to include more flags. configuration is now passed to Database, Scheme and Dao, which means this commit might introduce breaking changes for some projects.

Changed here: 132af15

from kabin.

tamimattafi avatar tamimattafi commented on July 18, 2024
  1. Adjust insert order for compounds and lists and call notifyQuery only after all SQL operations

Further research showed that notifyQuery inside one transaction delays triggers until the transaction is successful, therefore, these changes were postponed until future refactoring of the compiler and processor modules.

from kabin.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.