Skip to content

Commit

Permalink
chore: NewSchemaTableRef
Browse files Browse the repository at this point in the history
  • Loading branch information
atzoum committed Mar 8, 2024
1 parent 2de65e6 commit 9b259dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sqlconnect/internal/base/dialect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
}
5 changes: 5 additions & 0 deletions sqlconnect/relationref.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit 9b259dc

Please sign in to comment.