Skip to content

Commit

Permalink
doc_update/updating-doc-related-to-dsnexec-commnds-for-DDL-queries (#188
Browse files Browse the repository at this point in the history
)
  • Loading branch information
abodhekar authored Sep 28, 2023
1 parent afe25c3 commit 0188a39
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion dsnexec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ Commands:

args: An array of arguments to the SQL command. The args are parsed with
the golang text/template package with the sources map as the
template context.
template context.
(Note - If you intent to fire DDL queries, then put full go template expressions in the command.
As unlike for DML queries, underlying prepare statement does not consider arguments passed when the query is DDL.)

10 changes: 8 additions & 2 deletions dsnexec/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ configs:
driver: hotload
dsn: fsnotify://postgres/path/to/myfile.txt
commands:
- command: ALTER SERVER myserver OPTIONS (SET host=?);
- command: INSERT INTO table1 values ($1, $2);
args:
- '{{ index . "test/source.json" "host" }}'
- '{{ index . "test/source.json" "host" }}'
- '{{ index . "test/source.json" "port" }}'

# As the below query is DDL, unlike insert (DML) written above, we can not pass arguments here.
# We need to put full go template expressions in the command itself
- command: ALTER SERVER myserver OPTIONS (SET host '{{ index . "test/source.json" "host" }}' );
args: []

0 comments on commit 0188a39

Please sign in to comment.