jenseng/hair_trigger

Ability to add MySQL DECLARE statements

Opened this issue · 1 comments

Hi there - thanks for the great gem.

I'm currently unable to use MySQL DECLARE statements to declare local variables in conjunction with the conditional of from the gem, since they appear after the opening IF THEN that is generated. MySQL requires any declared variables to be immediately after the BEFORE statement.

Is this something you'd consider adding support for? I'm unsure if MySQL's declare is the same as Postgres's. If so, I'd be happy to open a PR with MySQL support. If not, would you be open to adding an option for code to run immediately after the opening BEGIN?

Hi @alexdunae, I'd happily accept a PR for this. Note that the declare syntax is a little different between MySQL and Postgres, and it occurs in different spots (before the BEGIN in Postgres, after it in MySQL).

Regardless, it seems like Hairtrigger's declare could be reworked so that it does the right thing for MySQL (whether or not you're using of)