Fork me on GitHub
#hugsql
<
2020-10-30
>
clumsyjedi00:10:16

any ideas on how I can prefix a table name? eg. for tables big_widgets and small_widgets I want to re-use the same queries.sql

clumsyjedi00:10:50

SELECT * FROM :sql:prefixwidgets;

clumsyjedi00:10:09

{:prefix "big_"}

clumsyjedi00:10:30

was hoping to get that translated to

SELECT * FROM big_widgets;

clumsyjedi00:10:58

I tried

SELECT * FROM :sql:prefix\widgets;

clumsyjedi00:10:12

but unfortunately the \ is left in the query

curtis.summers10:10:50

You can work around the HugSQL parser not knowing when to end your parameter and start the SQL by jumping into a Clojure Expression:

select * from /*~ ":sql:prefix" ~*/widgets

🙏 3
👍 3