diff options
Diffstat (limited to 'Godeps/_workspace/src/github.com/go-sql-driver/mysql/driver_test.go')
-rw-r--r-- | Godeps/_workspace/src/github.com/go-sql-driver/mysql/driver_test.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/driver_test.go b/Godeps/_workspace/src/github.com/go-sql-driver/mysql/driver_test.go index cb0d5f5ec..f9da416ec 100644 --- a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/driver_test.go +++ b/Godeps/_workspace/src/github.com/go-sql-driver/mysql/driver_test.go @@ -1246,6 +1246,30 @@ func TestCollation(t *testing.T) { } } +func TestColumnsWithAlias(t *testing.T) { + runTests(t, dsn+"&columnsWithAlias=true", func(dbt *DBTest) { + rows := dbt.mustQuery("SELECT 1 AS A") + defer rows.Close() + cols, _ := rows.Columns() + if len(cols) != 1 { + t.Fatalf("expected 1 column, got %d", len(cols)) + } + if cols[0] != "A" { + t.Fatalf("expected column name \"A\", got \"%s\"", cols[0]) + } + rows.Close() + + rows = dbt.mustQuery("SELECT * FROM (SELECT 1 AS one) AS A") + cols, _ = rows.Columns() + if len(cols) != 1 { + t.Fatalf("expected 1 column, got %d", len(cols)) + } + if cols[0] != "A.one" { + t.Fatalf("expected column name \"A.one\", got \"%s\"", cols[0]) + } + }) +} + func TestRawBytesResultExceedsBuffer(t *testing.T) { runTests(t, dsn, func(dbt *DBTest) { // defaultBufSize from buffer.go |