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

add forUpdate expression #84

Closed
khomyakov42 opened this issue Oct 1, 2013 · 7 comments
Closed

add forUpdate expression #84

khomyakov42 opened this issue Oct 1, 2013 · 7 comments

Comments

@khomyakov42
Copy link

SELECT * FROM tableName WHERE ... LIMIT .. FOR UPDATE

@tgriesser
Copy link
Member

So since forUpdate would only be applicable in the context of a transaction, would it make sense that this method (and potentially others relating to transactions forShare) be dynamically made available after calling the .transacting(trx) on the query builder chain?

@khomyakov42
Copy link
Author

Yes

@tgriesser
Copy link
Member

@glasscube42 - take a look, should be added & documented now.

@gx0r
Copy link
Contributor

gx0r commented Feb 27, 2014

I seem to be having trouble with forUpdate against postgresql with knex 0.5.7. Code is..

knex.transaction(function(t) {
    return knex('users')
      .transacting(t)
      .forUpdate()
      .then(function (s) {
        console.log(s);
        return s;
      });
})
.then(function(resp) {
  console.log('TX complete! ' + JSON.stringify(resp));
  return resp;
})
.catch(function(err) {
    console.log('TX error! ' + err.message);
});

Outputs: 'TX error! Cannot call method 'then' of undefined'

@tgriesser
Copy link
Member

Fixing now.

tgriesser added a commit that referenced this issue Feb 27, 2014
@tgriesser
Copy link
Member

@llambda thanks for pointing this out... should be fixed, let me know if it's not working for you.

@gx0r
Copy link
Contributor

gx0r commented Feb 27, 2014

@tgriesser Works good now. Thank you for fixing that.

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