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

Set configuration parameters not working in Knex 0.6.x (postgres) #351

Closed
naturalethic opened this issue Jul 2, 2014 · 2 comments
Closed
Labels

Comments

@naturalethic
Copy link

I use a configuration parameter in my transactions that triggers reference during row mutation, for the purpose of keeping a journal on who made changes to the database. I had this working fine in Knex 0.5.x but it fails in Knex 0.6.x -- the configuration parameter is not available to the trigger.

Knex 0.5.x example (working):

knex.transaction (t) ->
  t.connection.query "SET LOCAL app.session = '#{req.token}'"
  knex 'session'
  .transacting t
  .insert!

Knex 0.6.x example (not working):

knex.transaction (t) ->
  t.raw "SET LOCAL app.session = '#{req.token}'"
  .then ->
    t 'session'
    .insert!

Knex 0.6.x alternative example (not working either):

knex.transaction (t) ->
  t.raw "SET LOCAL app.session = '#{req.token}'"
  .then ->
    knex 'session'
    .transacting t
    .insert!
@naturalethic
Copy link
Author

You are a gentleman and a scholar.

@tgriesser
Copy link
Member

Still need to cut the patch release, but that one line should fix it for the time being. I was looking to add some tests and realized I need to do a bit more work internally to ensure events are handled within transactions properly. I'll try to get a patch release out by the end of the day regardless.

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

No branches or pull requests

2 participants