Joined Column Names are Ambiguous

Currently writing a open source ORM/DBAL in Go that follows an active record pattern. Just got around to trying to add in functionality for just a LEFT JOIN.

I noticed that I can’t just throw column values into a map.

My tables:

root@:26257/integrationtestdb> select * from t1;
                 t1_id                 |      name       
+--------------------------------------+----------------+
  0f8c7cd1-0c2a-4efa-9669-82b6ff786cce | item name here  
(1 row)

Time: 1.06976ms

root@:26257/integrationtestdb> select * from t2;                                                                                                                                                          t2_id                 |                t1_id                 |      name       
+--------------------------------------+--------------------------------------+----------------+
  0f52f693-b05a-4808-b6c2-7f81bc5ed422 | 0f8c7cd1-0c2a-4efa-9669-82b6ff786cce | item type here  
(1 row)

Time: 978.208µs

root@:26257/integrationtestdb> select * from t1 join t2 on t1.t1_id = t2.t1_id where t1.t1_id = '0f8c7cd1-0c2a-4efa-9669-82b6ff786cce';                                                                   t1_id                 |      name      |                t2_id                 |                t1_id                 |      name       
+--------------------------------------+----------------+--------------------------------------+--------------------------------------+----------------+
  0f8c7cd1-0c2a-4efa-9669-82b6ff786cce | item name here | 0f52f693-b05a-4808-b6c2-7f81bc5ed422 | 0f8c7cd1-0c2a-4efa-9669-82b6ff786cce | item type here  
(1 row)

Time: 1.478252ms

In Go, when I do cols, err := rows.Columns() the array of column names look like this:

[]string{"t1_id", "name", "t2_id", "t1_id", "name"}

So building a map with that wouldn’t work. Is there some way to let Cockroach know that I want table_name.column_name in the table returned?

For some reason I have it in the back of my head that MySQL for example, just does this. Not sure if this is a bug or something that hasn’t been thought of.

Hello,

Are you interested in table_name.column_name in the sql shell or in your client application?

Does this help?

Thanks,
Matt