Skip to content

Commit 04c78bb

Browse files
committed
columnsWithAlias: Add test
1 parent 03a543a commit 04c78bb

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

driver_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,30 @@ func TestCollation(t *testing.T) {
12461246
}
12471247
}
12481248

1249+
func TestColumnsWithAlias(t *testing.T) {
1250+
runTests(t, dsn+"&columnsWithAlias=true", func(dbt *DBTest) {
1251+
rows := dbt.mustQuery("SELECT 1 AS A")
1252+
defer rows.Close()
1253+
cols, _ := rows.Columns()
1254+
if len(cols) != 1 {
1255+
t.Fatalf("expected 1 column, got %d", len(cols))
1256+
}
1257+
if cols[0] != "A" {
1258+
t.Fatalf("expected column name \"A\", got \"%s\"", cols[0])
1259+
}
1260+
rows.Close()
1261+
1262+
rows = dbt.mustQuery("SELECT * FROM (SELECT 1 AS one) AS A")
1263+
cols, _ = rows.Columns()
1264+
if len(cols) != 1 {
1265+
t.Fatalf("expected 1 column, got %d", len(cols))
1266+
}
1267+
if cols[0] != "A.one" {
1268+
t.Fatalf("expected column name \"A.one\", got \"%s\"", cols[0])
1269+
}
1270+
})
1271+
}
1272+
12491273
func TestRawBytesResultExceedsBuffer(t *testing.T) {
12501274
runTests(t, dsn, func(dbt *DBTest) {
12511275
// defaultBufSize from buffer.go

0 commit comments

Comments
 (0)