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
This commit is contained in:
Wilfred Asomani 2023-05-15 14:47:20 +00:00 committed by Wilfred Asomani
parent e90612c285
commit 81b2b067e6
2 changed files with 27 additions and 168 deletions

View File

@ -50,6 +50,8 @@ func main() {
"*sql.Tx", "tagsql.Tx", "*sql.Tx", "tagsql.Tx",
"*sql.Rows", "tagsql.Rows", "*sql.Rows", "tagsql.Rows",
`_ "github.com/jackc/pgx/v4/stdlib"`, `"storj.io/private/tagsql"`, `_ "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", "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)", "db = &DB{\n\t\tDB: sql_db", "db = &DB{\n\t\tDB: tagsql.Wrap(sql_db)",
) )

View File

@ -11517,6 +11517,7 @@ type __sqlbundle_SQL interface {
} }
type __sqlbundle_Dialect interface { type __sqlbundle_Dialect interface {
// Rebind gives the opportunity to rewrite provided SQL into a SQL dialect.
Rebind(sql string) string Rebind(sql string) string
} }
@ -11601,6 +11602,30 @@ func __sqlbundle_flattenSQL(x string) string {
return x 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 // this type is specially named to match up with the name returned by the
// dialect impl in the sql package. // dialect impl in the sql package.
type __sqlbundle_postgres struct{} type __sqlbundle_postgres struct{}
@ -11665,174 +11690,6 @@ func (s __sqlbundle_sqlite3) Rebind(sql string) string {
return sql 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 type __sqlbundle_Literal string
func (__sqlbundle_Literal) private() {} func (__sqlbundle_Literal) private() {}