Closed GoogleCodeExporter closed 9 years ago
Note that it works if I remove the `columnName := "DOCUM"` line and use the
following code for the query :
_, errQuery := db.Query(`SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name = 'DOCUM'
ORDER BY schema_name, table_name;`)
if errQuery != nil {
panic(errQuery.Error())
}
Original comment by bigras.b...@gmail.com
on 21 Aug 2013 at 8:43
I have added this test
diff --git a/mssql_test.go b/mssql_test.go
--- a/mssql_test.go
+++ b/mssql_test.go
@@ -862,3 +862,37 @@
exec(t, db, "drop table dbo.temp")
}
+
+func TestMSSQLALEX(t *testing.T) {
+ db, sc, err := mssqlConnect()
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer closeDB(t, db, sc, sc)
+
+ columnName := "id"
+ rows, err := db.Query(`SELECT t.name AS table_name,
+ SCHEMA_NAME(schema_id) AS schema_name,
+ c.name AS column_name
+ FROM sys.tables AS t
+ INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
+ WHERE c.name = ?
+ ORDER BY schema_name, table_name;`, columnName)
+ if err != nil {
+ t.Fatalf("db.Query failed: %v", err)
+ }
+ defer rows.Close()
+
+ for rows.Next() {
+ var table_name, schema_name, column_name string
+ err = rows.Scan(&table_name, &schema_name, &column_name)
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Logf("table_name=%v schema_name=%v column_name=%v", table_name,
schema_name, column_name)
+ }
+ err = rows.Err()
+ if err != nil {
+ t.Fatal(err)
+ }
+}
that is similar to your sample. And that prints all columns named id in my
database with no problem on both Windows XP 32 bit and Linux-386 (I use
freetds-0.91 and unixODBC-2.3.1).
Maybe you should try and update your linux drivers. Not sure if I can help you
more.
Alex
Original comment by alex.bra...@gmail.com
on 23 Aug 2013 at 2:11
I got rid of the problem by upgrading to freetds 0.91.
Original comment by bigras.b...@gmail.com
on 23 Aug 2013 at 6:49
Sounds good.
Alex
Original comment by alex.bra...@gmail.com
on 25 Aug 2013 at 8:52
Original issue reported on code.google.com by
bigras.b...@gmail.com
on 21 Aug 2013 at 8:41