mirror of
https://github.com/hanzoai/sqlbuilder.git
synced 2026-10-01 00:37:42 +00:00
update doc and test cases again
This commit is contained in:
@@ -269,13 +269,15 @@ fmt.Println(err)
|
||||
And a sample for PostgreSQL. Note that the dollar quote is supported.
|
||||
|
||||
```go
|
||||
// Only the last `$1` is interpolated.
|
||||
// Others are not interpolated as they are inside dollar quote (the `$$`).
|
||||
query, err := PostgreSQL.Interpolate(`
|
||||
CREATE FUNCTION dup(in int, out f1 int, out f2 text) AS $$
|
||||
SELECT $1, CAST($1 AS text) || ' is text'
|
||||
$$
|
||||
LANGUAGE SQL;
|
||||
|
||||
SELECT * FROM dup(42);`, []interface{}{42, 64})
|
||||
SELECT * FROM dup($1);`, []interface{}{42})
|
||||
|
||||
fmt.Println(query)
|
||||
fmt.Println(err)
|
||||
|
||||
+3
-1
@@ -148,13 +148,15 @@ func ExampleFlavor_Interpolate() {
|
||||
}
|
||||
|
||||
func ExampleFlavor_Interpolate_postgreSQL() {
|
||||
// Only the last `$1` is interpolated.
|
||||
// Others are not interpolated as they are inside dollar quote (the `$$`).
|
||||
query, err := PostgreSQL.Interpolate(`
|
||||
CREATE FUNCTION dup(in int, out f1 int, out f2 text) AS $$
|
||||
SELECT $1, CAST($1 AS text) || ' is text'
|
||||
$$
|
||||
LANGUAGE SQL;
|
||||
|
||||
SELECT * FROM dup(42);`, []interface{}{42, 64})
|
||||
SELECT * FROM dup($1);`, []interface{}{42})
|
||||
|
||||
fmt.Println(query)
|
||||
fmt.Println(err)
|
||||
|
||||
Reference in New Issue
Block a user