diff --git a/sqlconnect/internal/base/dialect_test.go b/sqlconnect/internal/base/dialect_test.go index c9a97af..28f5205 100644 --- a/sqlconnect/internal/base/dialect_test.go +++ b/sqlconnect/internal/base/dialect_test.go @@ -24,7 +24,7 @@ func TestDialect(t *testing.T) { quoted := d.QuoteTable(sqlconnect.NewRelationRef("table")) require.Equal(t, `"table"`, quoted, "table name should be quoted with double quotes") - quoted = d.QuoteTable(sqlconnect.NewRelationRef("table", sqlconnect.WithSchema("schema"))) + quoted = d.QuoteTable(sqlconnect.NewSchemaTableRef("schema", "table")) require.Equal(t, `"schema"."table"`, quoted, "schema and table name should be quoted with double quotes") }) } diff --git a/sqlconnect/relationref.go b/sqlconnect/relationref.go index ec652cf..a3d0c5e 100644 --- a/sqlconnect/relationref.go +++ b/sqlconnect/relationref.go @@ -23,6 +23,11 @@ func NewRelationRef(name string, options ...Option) RelationRef { } } +// NewSchemaTableRef creates a new RelationRef with a schema and a table +func NewSchemaTableRef(schema, table string) RelationRef { + return NewRelationRef(table, WithSchema(schema)) +} + type RelationType string const (