Skip to content

Commit

Permalink
chore: add dialect test scenario for quoted table
Browse files Browse the repository at this point in the history
  • Loading branch information
atzoum committed Jul 22, 2024
1 parent 6b64477 commit d6e8b94
Showing 1 changed file with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,29 @@ func TestDatabaseScenarios(t *testing.T, warehouse string, configJSON json.RawMe
})

t.Run("dialect", func(t *testing.T) {
// Create an unquoted table
unquotedTable := "UnQuoted_TablE"
identifier := db.QuoteIdentifier(schema.Name) + "." + unquotedTable
_, err := db.Exec("CREATE TABLE " + identifier + " (c1 int)")
require.NoError(t, err, "it should be able to create an unquoted table")

table, err := db.ParseRelationRef(identifier)
require.NoError(t, err, "it should be able to parse an unquoted table")
exists, err := db.TableExists(ctx, table)
require.NoError(t, err, "it should be able to check if a table exists")
require.True(t, exists, "it should return true for a table that exists")
t.Run("with unquoted table", func(t *testing.T) {
identifier := db.QuoteIdentifier(schema.Name) + "." + "UnQuoted_TablE"
_, err := db.Exec("CREATE TABLE " + identifier + " (c1 int)")
require.NoError(t, err, "it should be able to create an unquoted table")

table, err := db.ParseRelationRef(identifier)
require.NoError(t, err, "it should be able to parse an unquoted table")
exists, err := db.TableExists(ctx, table)
require.NoErrorf(t, err, "it should be able to check if a table exists: %s", table)
require.Truef(t, exists, "it should return true for a table that exists: %s", table)
})

t.Run("with quoted table", func(t *testing.T) {
identifier := db.QuoteIdentifier(schema.Name) + "." + db.QuoteIdentifier("Quoted_TablE")
_, err := db.Exec("CREATE TABLE " + identifier + " (c1 int)")
require.NoError(t, err, "it should be able to create a quoted table")

table, err := db.ParseRelationRef(identifier)
require.NoError(t, err, "it should be able to parse a quoted table")
exists, err := db.TableExists(ctx, table)
require.NoErrorf(t, err, "it should be able to check if a table exists: %s", table)
require.Truef(t, exists, "it should return true for a table that exists: %s", table)
})
})

t.Run("table admin", func(t *testing.T) {
Expand Down

0 comments on commit d6e8b94

Please sign in to comment.