Rename Object to FileUpload; use native Postgres $n placeholders.
This commit is contained in:
@@ -4,34 +4,12 @@ import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
_ "github.com/jackc/pgx/v5/stdlib"
|
||||
)
|
||||
|
||||
// rebind converts ? placeholders to Postgres $1, $2, ... form.
|
||||
func rebind(query string) string {
|
||||
n := 0
|
||||
var b strings.Builder
|
||||
for i := 0; i < len(query); i++ {
|
||||
if query[i] == '?' {
|
||||
n++
|
||||
b.WriteByte('$')
|
||||
b.WriteString(strconv.Itoa(n))
|
||||
continue
|
||||
}
|
||||
b.WriteByte(query[i])
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// q rebinds SQL placeholders for Postgres.
|
||||
func (s *Store) q(query string) string {
|
||||
return rebind(query)
|
||||
}
|
||||
|
||||
// applySchema runs semicolon-separated DDL statements, skipping PRAGMA lines.
|
||||
func applySchema(db *sql.DB, schema string) error {
|
||||
for _, stmt := range strings.Split(schema, ";") {
|
||||
|
||||
Reference in New Issue
Block a user