aboutsummaryrefslogtreecommitdiff
path: root/lib/sql/row_example_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sql/row_example_test.go')
-rw-r--r--lib/sql/row_example_test.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/sql/row_example_test.go b/lib/sql/row_example_test.go
index d7cd0918..e22524a4 100644
--- a/lib/sql/row_example_test.go
+++ b/lib/sql/row_example_test.go
@@ -11,17 +11,23 @@ func ExampleRow_ExtractSQLFields() {
"col_2": 1,
"col_1": true,
}
- names, holders, values := row.ExtractSQLFields(DefaultPlaceHolder)
+ names, holders, values := row.ExtractSQLFields("?")
fnames := strings.Join(names, ",")
fholders := strings.Join(holders, ",")
-
q := `INSERT INTO table (` + fnames + `) VALUES (` + fholders + `)`
- fmt.Println(q)
+ fmt.Printf("Query: %s\n", q)
+
+ names, holders, values = row.ExtractSQLFields("postgres")
+ fnames = strings.Join(names, ",")
+ fholders = strings.Join(holders, ",")
+ q = `INSERT INTO table (` + fnames + `) VALUES (` + fholders + `)`
+ fmt.Printf("Query for PostgreSQL: %s\n", q)
// err := db.Exec(q, values...)
fmt.Println(values)
- //Output:
- //INSERT INTO table (col_1,col_2,col_3) VALUES (?,?,?)
- //[true 1 'update']
+ // Output:
+ // Query: INSERT INTO table (col_1,col_2,col_3) VALUES (?,?,?)
+ // Query for PostgreSQL: INSERT INTO table (col_1,col_2,col_3) VALUES ($1,$2,$3)
+ // [true 1 'update']
}