sqltemplate, dbimpl: Remove single-method function types (#107525)

* Remove dbProviderFunc function.

This removes one extra indirection that made the code bit more difficult to navigate.

* Remove indirection function types implementing single-method interfaces.

This streamlines the code and makes it bit easier to navigate.

* Update pkg/storage/unified/sql/sqltemplate/dialect_mysql.go

Co-authored-by: Mustafa Sencer Özcan <32759850+mustafasencer@users.noreply.github.com>

---------

Co-authored-by: Mustafa Sencer Özcan <32759850+mustafasencer@users.noreply.github.com>
This commit is contained in:
Peter Štibraný
2025-07-03 10:38:12 +02:00
committed by GitHub
co-authored by Mustafa Sencer Özcan
parent a68f8107df
commit e076c74869
7 changed files with 69 additions and 127 deletions
@@ -6,6 +6,10 @@ import (
"testing"
)
var _ Dialect = MySQL
var _ Dialect = SQLite
var _ Dialect = PostgreSQL
func TestSelectForOption_Valid(t *testing.T) {
t.Parallel()
@@ -133,7 +137,7 @@ func TestStandardIdent_Ident(t *testing.T) {
}
for i, tc := range testCases {
gotOutput, gotErr := standardIdent{}.Ident(tc.input)
gotOutput, gotErr := standardIdent(tc.input)
if !errors.Is(gotErr, tc.err) {
t.Fatalf("unexpected error %v in test case %d", gotErr, i)
}
@@ -142,43 +146,3 @@ func TestStandardIdent_Ident(t *testing.T) {
}
}
}
func TestArgPlaceholderFunc(t *testing.T) {
t.Parallel()
testCases := []struct {
input int
valuePositional string
}{
{
input: 1,
valuePositional: "$1",
},
{
input: 16,
valuePositional: "$16",
},
}
for i, tc := range testCases {
got := argFmtSQL92(tc.input)
if got != "?" {
t.Fatalf("[argFmtSQL92] unexpected value %q in test case %d", got, i)
}
got = argFmtPositional(tc.input)
if got != tc.valuePositional {
t.Fatalf("[argFmtPositional] unexpected value %q in test case %d", got, i)
}
}
}
func TestName_Name(t *testing.T) {
t.Parallel()
const v = "some dialect name"
n := name(v)
if n.DialectName() != v {
t.Fatalf("unexpected dialect name %q", n.DialectName())
}
}