FredyH / MySQLOO

MySQLOO
GNU Lesser General Public License v2.1
138 stars 55 forks source link

[Feature request] SQL returned in onSuccess #137

Closed blobles-dev closed 1 month ago

blobles-dev commented 3 months ago

Hi, sorry - me again.

I've been diving deep into mysqloo and just thinking of things that would be beneficial.

onError returns the SQL that failed, but it would be great if we could get it from the query object itself once it's set (so we could also grab it in onSuccess, or it could be added to the callback there instead!) this let's us log data for various reasons. (Yes this is possible if you just set a string as the query and then handle it however, but if it's in onError, why not onSuccess too?)

Currently, there's no way to retrieve a (prepared) query with its ? placeholders set to its respective values after it's been sent - I'm not sure of the possibility of this as I'm not too familiar with how prepared statements work, but it would be great to see the actual raw query that ended up running on the server. For example, instead of UPDATE my_table SET some_col = ?, other_col = ? WHERE id = ? we would be able to grab: UPDATE my_table SET some_col = 'hello', other_col = 'world' WHERE id = 45

This would be great for many reasons, it lets my monitor everything to ensure values are being set correctly and quickly spot issues during development.

FredyH commented 1 month ago

Sorry for the late reply, I completely missed this issue. As far as I understand, it is not trivial to render the string of what was actually executed on our side, it is probably easiest for you to write a library function in lua that prints the statement (with the question mark) and then separately prints the values for each parameter. This is also how a lot of other libraries/frameworks do it.