Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change transaction "SET CONSTRAINTS"? #702

Closed
olalonde opened this issue Apr 19, 2015 · 4 comments
Closed

Change transaction "SET CONSTRAINTS"? #702

olalonde opened this issue Apr 19, 2015 · 4 comments

Comments

@olalonde
Copy link

Is it possible to modify the SET CONSTRAINTS of a transaction?

I have a transaction which inserts a book and then inserts a paragraph which references the book. The transaction is failing because I assume the paragraph is inserted before the book was committed. I would therefore need to set the transaction to SET CONSTRAINTS DEFERRED.

@olalonde
Copy link
Author

Oops, I was mistaken, I forgot to add the { transacting: t } option to the paragraph insert. That being said, I'm still wondering about how to set constraints on a transaction. Can I pass the transaction to .raw?

@rhys-vdw
Copy link
Contributor

There is no built in API for this currently, but you can pass it to raw.

bookshelf.transaction(function(trx) {
  trx.raw('set constraints deferred')
  .then(function() {
    // ...
  });
});

@rhys-vdw
Copy link
Contributor

Relevant issue is being tracked for knex: knex/knex#581

@crunchtime-ali
Copy link
Member

The project leadership of Bookshelf recently changed. In an effort to advance the project we close all issues older than one year.

If you think this issue needs to be re-evaluated please post a comment on why this is still important and we will re-open it.

We also started an open discussion about the future of Bookshelf.js here #1600. Feel free to drop by and give us your opinion.
Let's make Bookshelf great again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants