Giter Site home page Giter Site logo

SQLite3 constraints about dm-constraints HOT 6 OPEN

datamapper avatar datamapper commented on August 25, 2024
SQLite3 constraints

from dm-constraints.

Comments (6)

solnic avatar solnic commented on August 25, 2024

Yes, I would really like to see something like that. Ideally I’d like to see it if it didn’t result in any failing specs.

The current idea with dm-constraints is we set up software level constraints, that if working perfectly should catch all attempts to destroy a resource when it has dependents. The DB level constraints are more of a safety net, as well as communicating intent, and also providing a backup for if (when) the DB becomes an integration point.

by Dan Kubb (dkubb)

from dm-constraints.

solnic avatar solnic commented on August 25, 2024

I’d just like to say that I would love to see this functionality merged into dm-constraints. I believe newer versions of SQLite 3 even support FK constraints too.

If some of this functionality included CHECK constraints I would be doubly excited to see it merged in :)

by Dan Kubb (dkubb)

from dm-constraints.

r3n4ud avatar r3n4ud commented on August 25, 2024

@solnic and @dkubb : any news or plans on the sqlite3 constraints support? I would really to get this functionality working since I would like to port an ugly sqlite3 generation scripts to datamapper but I really need the db-level constraints since the db is used in an un-ruby ecosystem…

I could help to get the things done.

from dm-constraints.

dkubb avatar dkubb commented on August 25, 2024

@nibua-r if you wanted to take a stab at it, there's a good chance it might represent a few minutes to make the code changes, and perhaps an hour or two of testing for someone sufficiently motivated.

The basic approach would be to modify the SQLite adapter within dm-constraints so it returns true for versions of SQlite3 that provide FK constraint support. See dm-migrations for the methods we have built-in for getting the DB version.

from dm-constraints.

r3n4ud avatar r3n4ud commented on August 25, 2024

@dkubb I have delayed my response to take (a little) time to check the code and I'm sorry for that.
I'll report here as soon as I can take some time to get a first version.

from dm-constraints.

r3n4ud avatar r3n4ud commented on August 25, 2024

@dkubb Wow, I forgot about that issue… Now, the need is back again!
After a quick glance on the dm-constraints source code (i.e. DataObjectsAdapter), all I could say is that the basic approach would fail. SQLite doesn't support ALTER TABLE … ADD CONSTRAINT (SQL Features That SQLite Does Not Implement) and as a consequence, it is not possible to add the constraints after the table creation, thus to use the actual methods.

Is there a way to append the relationship constraints to the CREATE TABLE statement?

cc @solnic @snusnu

from dm-constraints.

Related Issues (7)

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.