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

Query Event 8.6 not triggering like before #855

Closed
wubzz opened this issue Jun 1, 2015 · 5 comments
Closed

Query Event 8.6 not triggering like before #855

wubzz opened this issue Jun 1, 2015 · 5 comments

Comments

@wubzz
Copy link
Member

wubzz commented Jun 1, 2015

Hey.

Updated my knex package from 7.6 -> 8.6 (big leap, I know). By doing so, it appears the Query Event is not being triggered as it used to. Is this something you're aware of?

Example code:

knexDb.on('query', function() {
var debugVariable = ''; //Never get here, not triggering
});

Everything is run through transactions (if that matters?). We're very dependant on this event as we append SchemaName (Postgres) to the queries.

I couldn't find anything relating to this in the changelog, but please do correct me if I missed it.

Thanks in advance.

@wubzz
Copy link
Member Author

wubzz commented Jun 1, 2015

It seems to have broken between 0.7.6 -> 0.8.0

@tgriesser
Copy link
Member

Ah, yep transactions got a big internal overhaul and I think I forgot to proxy the events on the "transaction" client back through to the original client.

Also, are you saying that you're using the event to mutate the object passed to the event, modifying the sql before it goes into the query? If so I might need to change else to support this behavior.

@wubzz
Copy link
Member Author

wubzz commented Jun 1, 2015

@tgriesser Ah, I see, thanks for the quick reply. I'll stay 7.6 for now and wait for fix. :)

And yes, that's what's being done. The sql property of the data object gets manipulated by adding the SchemaName to all relevant places of the query through a regex. This is done because I saw no other (or better) way of doing it.

Example:

db('Year').select().toString()
select * from "Year"

<--- Event --->

select * from "MySchema"."Year"

@tgriesser
Copy link
Member

In that case you should be able to do db('MySchema.Year').select().toString(), no?

@wubzz
Copy link
Member Author

wubzz commented Jun 1, 2015

Surprisingly, that did work.. I recall having tried that before and received "MySchema.Year" instead of "MySchema"."Year" which is the original cause opting for the query event.

I'll keep that in mind, might make life easier.

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

No branches or pull requests

2 participants