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

Comments

Projects
None yet
2 participants
@naturalethic
Copy link

naturalethic commented Jul 2, 2014

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!

@tgriesser tgriesser added the bug label Jul 4, 2014

@tgriesser tgriesser closed this in 0385eb5 Jul 8, 2014

@naturalethic

This comment has been minimized.

Copy link
Author

naturalethic commented Jul 8, 2014

You are a gentleman and a scholar.

@tgriesser

This comment has been minimized.

Copy link
Owner

tgriesser commented Jul 8, 2014

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
You can’t perform that action at this time.