On 1/21/19 3:41 PM, Justin Pryzby wrote:
> -- There are two columns here:
>>>> pg.DB('ts').query('SELECT x.b, y.a AS b FROM (SELECT 1 AS b )x JOIN 
>>>> (SELECT 1 AS a)y ON true').getresult()
> [(1, 1)]
> 
> -- But here they're silently "collapsed" into one key:
>>>> pg.DB('ts').query('SELECT x.b, y.a AS b FROM (SELECT 1 AS b )x JOIN 
>>>> (SELECT 2 AS a)y ON true').dictresult()
> [{'b': 2}]
> 
> ..which is scary to me since nobody knows what they're going to get, or that
> same value is being used for two different things instead of different 
> values..
> 
> If this is agreed to be a problem, maybe write warning to stderr in 5.0 and
> fail harder in 5.1+ ?

I absolutely depend on the current behaviour.  I commonly do things like
this:

  SELECT * FROM x, y where x,x_id = y.X_id

The point is that x_id is the same object.  It's the primary key in x
and a reference to x in y.  I hope I don't have to constantly name every
variable in each table.

I also do this which is a shorthand way to do the above:

  date = db.get('y', x_id)
  db.get('x', data)
  db.get('z', data)

Here the entry from 'y' also has a reference to 'z', e.g. z_id.

-- 
D'Arcy J.M. Cain
PyGreSQL Development Group
http://www.PyGreSQL.org IM:da...@vex.net
_______________________________________________
PyGreSQL mailing list
PyGreSQL@Vex.Net
https://mail.vex.net/mailman/listinfo/pygresql

Reply via email to