From 81b2b067e62b6fab5a5a1eb5c6acf86bd0374407 Mon Sep 17 00:00:00 2001 From: Wilfred Asomani Date: Mon, 15 May 2023 14:47:20 +0000 Subject: [PATCH] satellite/satellitedb/dbx/gen: update to work with updated dbx This change updates the replacer in satellite/satellitedb/dbx/gen/main.go to work with an updated dbx. Change-Id: I08e89d6d27e6f1d435416105fe5f622009add7ad --- satellite/satellitedb/dbx/gen/main.go | 2 + satellite/satellitedb/dbx/satellitedb.dbx.go | 193 +++---------------- 2 files changed, 27 insertions(+), 168 deletions(-) diff --git a/satellite/satellitedb/dbx/gen/main.go b/satellite/satellitedb/dbx/gen/main.go index c00cd4c5a..aa9e1e2cc 100644 --- a/satellite/satellitedb/dbx/gen/main.go +++ b/satellite/satellitedb/dbx/gen/main.go @@ -50,6 +50,8 @@ func main() { "*sql.Tx", "tagsql.Tx", "*sql.Rows", "tagsql.Rows", `_ "github.com/jackc/pgx/v4/stdlib"`, `"storj.io/private/tagsql"`, + `_ "github.com/jackc/pgx/v5/stdlib"`, `"storj.io/private/tagsql"`, + `"github.com/jackc/pgx/v5/pgconn"`, `"github.com/jackc/pgconn"`, "type DB struct {\n\t*sql.DB", "type DB struct {\n\ttagsql.DB", "db = &DB{\n\t\tDB: sql_db", "db = &DB{\n\t\tDB: tagsql.Wrap(sql_db)", ) diff --git a/satellite/satellitedb/dbx/satellitedb.dbx.go b/satellite/satellitedb/dbx/satellitedb.dbx.go index dd0ed1d2c..92370cb73 100644 --- a/satellite/satellitedb/dbx/satellitedb.dbx.go +++ b/satellite/satellitedb/dbx/satellitedb.dbx.go @@ -11517,6 +11517,7 @@ type __sqlbundle_SQL interface { } type __sqlbundle_Dialect interface { + // Rebind gives the opportunity to rewrite provided SQL into a SQL dialect. Rebind(sql string) string } @@ -11601,6 +11602,30 @@ func __sqlbundle_flattenSQL(x string) string { return x } +// this type is specially named to match up with the name returned by the +// dialect impl in the sql package. +type __sqlbundle_cockroach struct{} + +func (p __sqlbundle_cockroach) Rebind(sql string) string { + return __sqlbundle_postgres{}.Rebind(sql) +} + +// this type is specially named to match up with the name returned by the +// dialect impl in the sql package. +type __sqlbundle_pgx struct{} + +func (p __sqlbundle_pgx) Rebind(sql string) string { + return __sqlbundle_postgres{}.Rebind(sql) +} + +// this type is specially named to match up with the name returned by the +// dialect impl in the sql package. +type __sqlbundle_pgxcockroach struct{} + +func (p __sqlbundle_pgxcockroach) Rebind(sql string) string { + return __sqlbundle_postgres{}.Rebind(sql) +} + // this type is specially named to match up with the name returned by the // dialect impl in the sql package. type __sqlbundle_postgres struct{} @@ -11665,174 +11690,6 @@ func (s __sqlbundle_sqlite3) Rebind(sql string) string { return sql } -// this type is specially named to match up with the name returned by the -// dialect impl in the sql package. -type __sqlbundle_cockroach struct{} - -func (p __sqlbundle_cockroach) Rebind(sql string) string { - type sqlParseState int - const ( - sqlParseStart sqlParseState = iota - sqlParseInStringLiteral - sqlParseInQuotedIdentifier - sqlParseInComment - ) - - out := make([]byte, 0, len(sql)+10) - - j := 1 - state := sqlParseStart - for i := 0; i < len(sql); i++ { - ch := sql[i] - switch state { - case sqlParseStart: - switch ch { - case '?': - out = append(out, '$') - out = append(out, strconv.Itoa(j)...) - state = sqlParseStart - j++ - continue - case '-': - if i+1 < len(sql) && sql[i+1] == '-' { - state = sqlParseInComment - } - case '"': - state = sqlParseInQuotedIdentifier - case '\'': - state = sqlParseInStringLiteral - } - case sqlParseInStringLiteral: - if ch == '\'' { - state = sqlParseStart - } - case sqlParseInQuotedIdentifier: - if ch == '"' { - state = sqlParseStart - } - case sqlParseInComment: - if ch == '\n' { - state = sqlParseStart - } - } - out = append(out, ch) - } - - return string(out) -} - -// this type is specially named to match up with the name returned by the -// dialect impl in the sql package. -type __sqlbundle_pgx struct{} - -func (p __sqlbundle_pgx) Rebind(sql string) string { - type sqlParseState int - const ( - sqlParseStart sqlParseState = iota - sqlParseInStringLiteral - sqlParseInQuotedIdentifier - sqlParseInComment - ) - - out := make([]byte, 0, len(sql)+10) - - j := 1 - state := sqlParseStart - for i := 0; i < len(sql); i++ { - ch := sql[i] - switch state { - case sqlParseStart: - switch ch { - case '?': - out = append(out, '$') - out = append(out, strconv.Itoa(j)...) - state = sqlParseStart - j++ - continue - case '-': - if i+1 < len(sql) && sql[i+1] == '-' { - state = sqlParseInComment - } - case '"': - state = sqlParseInQuotedIdentifier - case '\'': - state = sqlParseInStringLiteral - } - case sqlParseInStringLiteral: - if ch == '\'' { - state = sqlParseStart - } - case sqlParseInQuotedIdentifier: - if ch == '"' { - state = sqlParseStart - } - case sqlParseInComment: - if ch == '\n' { - state = sqlParseStart - } - } - out = append(out, ch) - } - - return string(out) -} - -// this type is specially named to match up with the name returned by the -// dialect impl in the sql package. -type __sqlbundle_pgxcockroach struct{} - -func (p __sqlbundle_pgxcockroach) Rebind(sql string) string { - type sqlParseState int - const ( - sqlParseStart sqlParseState = iota - sqlParseInStringLiteral - sqlParseInQuotedIdentifier - sqlParseInComment - ) - - out := make([]byte, 0, len(sql)+10) - - j := 1 - state := sqlParseStart - for i := 0; i < len(sql); i++ { - ch := sql[i] - switch state { - case sqlParseStart: - switch ch { - case '?': - out = append(out, '$') - out = append(out, strconv.Itoa(j)...) - state = sqlParseStart - j++ - continue - case '-': - if i+1 < len(sql) && sql[i+1] == '-' { - state = sqlParseInComment - } - case '"': - state = sqlParseInQuotedIdentifier - case '\'': - state = sqlParseInStringLiteral - } - case sqlParseInStringLiteral: - if ch == '\'' { - state = sqlParseStart - } - case sqlParseInQuotedIdentifier: - if ch == '"' { - state = sqlParseStart - } - case sqlParseInComment: - if ch == '\n' { - state = sqlParseStart - } - } - out = append(out, ch) - } - - return string(out) -} - type __sqlbundle_Literal string func (__sqlbundle_Literal) private() {}