-
-
Notifications
You must be signed in to change notification settings - Fork 8
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 a property to the tracker history for all queries #33
Conversation
Thank you for the PR. |
The difference is that For example: tracker.on.insert('table_name').responseOnce(1);
tracker.on.update('table_name').responseOnce(1);
await knex.insert({id: 1, value: 1}).into('table_name').on_conflict('merge');
await knex.update({value: knex.raw('"value" + 1')}).from('table_name').where('id', 1);
// Contains only the insert
console.log(tracker.history.insert);
// Contains only the update
console.log(tracker.history.update);
// This one is empty
console.log(tracker.history.any);
// How to ensure that the update happened after the upsert? |
For these places which you want to check order of exec, use the any matcher... Is it not enough? |
Well... sure: tracker.on.insert('table_name').responseOnce(1);
tracker.on.update('table_name').responseOnce(1);
// Could be replaced with
tracker.on.any(query => query.method === 'insert' && query.sql.includes('table_name')).responseOnce(1);
tracker.on.any(query => query.method === 'delete' && query.sql.includes('table_name')).responseOnce(1); But this seems unnecessarily verbose. |
Ok, You've convinced me, @aryehb let's fix the small things that I've mentioned, and we will merge it :] |
@felixmosh Can you clarify what you want me to change? |
Rebase master |
Ok, I'll work on those. |
a90ea00
to
17d3a13
Compare
@felixmosh I rebased and added the |
Thank you for this PR 🙏🏼 |
Closes #32