Replies: 1 comment 5 replies
-
Some syntax highlighters recognize variables. Here, for example, is how VS Code formats a Otherwise, it can be helpful to use the quoted syntax for I just started to type up wish for the use of (https://www.postgresql.org/docs/current/functions-string.html#FUNCTIONS-STRING-FORMAT) for functions; I was not aware of the CREATE SCHEMA :"schema";
SET search_path = :"schema";
CREATE FUNCTION foo() RETURNS TEXT LANGUAGE SQL AS $$
SELECT current_setting('search_path')
$$ ;
\df foo
SELECT foo(); If I run it with the
|
Beta Was this translation helpful? Give feedback.
-
I'd like to replace some strings when deploying migrations. This could be handy for schema qualifiers in PostgreSQL, as an example.
Let's say, I want to deploy the migration
However, I'd like to create the
users
table in the schemamy_app
, in order to separate it from other tables inpublic
, that I don't want to share with some application or user.I know, that I can use
psql
variables for this, and that is what I am currently doing. However, there are some shortcomings with this approach:psql
specific syntax like:VAR
,\set
,\if
and so on (I'd love to use DataGrip by JetBrains)psql
variables in stored procedures, because the body of stored procedures is basically a string.In order to replace the
public
within$body$
, I'd have to do something like this:This is the same as above, but replaces
public
with the content of thepsql
variable:'app_schema'
. Unfortunately, the code is much less readable, and obviously, there is no longer IDE support for such things, even syntax highlighting is mostly broken.Therefore, I'd love to see configurable string replacements, e.g. a file
Beta Was this translation helpful? Give feedback.
All reactions