qustavo / sqlhooks

Attach hooks to any database/sql driver
MIT License
652 stars 44 forks source link

SQL commands inside hook methods #31

Open fadc80 opened 4 years ago

fadc80 commented 4 years ago

I would like to execute SQL commands inside the hook methods. These commands must be on the same transaction of the original command. I mean the one triggered by the programmer using the database/sql API. I have to do this transparently. Do you think it is feseable and straightforward to implement? I guess I would have to add extra parameters to the hook methods' signatures. However, I am wondering how I could append these extra comands to the ongoing transaction.

qustavo commented 4 years ago

I'm not sure if sqlhooks can attach to transactions, but if that's the case, I think you could use the context to save a reference to the tx and then retrieve it. Again, I'm not sure about this.