hugsql

2020-10-30T00:57:16.011800Z

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

2020-10-30T00:57:50.012400Z

SELECT * FROM :sql:prefixwidgets;

2020-10-30T00:58:09.012800Z

{:prefix "big_"}

2020-10-30T00:58:30.013200Z

was hoping to get that translated to

SELECT * FROM big_widgets;

2020-10-30T00:58:58.013700Z

I tried

SELECT * FROM :sql:prefix\widgets;

2020-10-30T00:59:12.014100Z

but unfortunately the \ is left in the query

curtis.summers 2020-10-30T10:22:50.016100Z

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

👍 1
🙏 1