sasha-alias / sqltabs

Rich SQL client for Postgresql, MySQL, MS SQL, Amazon Redshift, Google Firebase (Firestore)
https://www.sqltabs.com
GNU General Public License v3.0
803 stars 57 forks source link

Macros on selection #60

Open yazun opened 8 years ago

yazun commented 8 years ago

It would be nice to have macros run on a selection/block, similarly as it's done in pgadmin.

sasha-alias commented 8 years ago

I actually never used pgAdmin longer than for 5 mins :) so really don't know what do you mean. Could you elaborate on this a bit? In SQL Tabs you can select a certain area of the script and run it. It always works so that if there is a selected area then it executes a selection, if no selection then executes a block or entire script, depending on what shortcut you pressed.

yazun commented 8 years ago

sure: http://www.pgadmin.org/docs/1.8/macros.html

$SELECTION$ is replaced by the selected block and one can put some sql to execute it, useful to do i.e. select * from ($SELECTION$) s limit 10; select * from ($SELECTION$) s tablesample bernoulli(5) limit 100 select runyourfunctiononselection($SELECTION$) explain $SELECTION$ explain analyze $SELECTION$ etc. each macro has a key assigned so it's a matter of a keystroke to rerun it.

In addition it would be nice to remove semicolon if it happens to be included in the selection by accident.

sasha-alias commented 8 years ago

OK, I see what you mean. I think this is related to Snippets https://github.com/sasha-alias/sqltabs/issues/13 If it will be like pgadmin macros or texteditor snippet depends on implementation once we get there.