Both SQLX and JavaScript now support a database()
function, which returns the (prefixed, as applicable) name of "this" action's database. (Contrived) examples:
publish("table", ctx => `select "${ctx.database()}" as col1`);
config { type: "table" }
select "${database()}" as col1
Assuming dataform.config
contains "defaultDatabase": "foo"
, these both generate a table action whose SQL is select "foo" as col1
. This is likely most useful in type: "operations"
scripts.
Note: For warehouses without databases such as Redshift, this will add an error to the compilationErrors
property.
Bugfix: The similar name()
function has been fixed to properly attach any prefix as appropriate.