column aliases in PyDO

"Jacob Smullyan" <[email protected]> Wed, 2 Aug 2006 12:22:26 -0400
Newsgroups gmane.comp.web.skunkweb
Message-ID <[email protected]>
--===============0051184556==
Content-Type: multipart/alternative; 
	boundary="----=_Part_5739_12763439.1154535746379"

------=_Part_5739_12763439.1154535746379
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hello, PyDO2 users (especially Faber!):

A long time ago now, Faber undertook to persuade me that the ability to use
project() to add aggregate columns was a feature.  I was very resistant; I
hadn't intended it and it scared me.  (What can I say, I used to program in
Java and still haven't entirely gotten over it.)

Anyway, after letting the idea sink in for a while I accepted it.  But there
was still a problem -- PyDO didn't support column aliases (e.g., "count(*)
as count") so attribute access to the aggregate fields didn't work.  (dict
access did, because the keys are determined by the columns in the result
set.)

I just checked in changes to make this work, with 1 test.  Usage would be
like so:

  >>> p=myObj.project(Field('count(*)', asname='count'))
  >>> o=p.getSome()[0]
  >>>o.count
  44

I'll also soon make it possible to accomplish the same by:

  myObj.project('count(*) as count')

Aliases have other use cases as well, of course  -- when you have a column
called "class", for instance.

Cheers,

js

ps.  I am using gmail while my usual mail server is being repaired.

-- 
Jacob Smullyan

------=_Part_5739_12763439.1154535746379
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hello, PyDO2 users (especially Faber!):<br><br>A long time ago now, Faber undertook to persuade me that the ability to use project() to add aggregate columns was a feature.&nbsp; I was very resistant; I hadn't intended it and it scared me.&nbsp; (What can I say, I used to program in Java and still haven't entirely gotten over it.)
<br><br>Anyway, after letting the idea sink in for a while I accepted it.&nbsp; But there was still a problem -- PyDO didn't support column aliases (e.g., &quot;count(*) as count&quot;) so attribute access to the aggregate fields didn't work.&nbsp; (dict access did, because the keys are determined by the columns in the result set.)&nbsp;&nbsp; 
<br><br>I just checked in changes to make this work, with 1 test.&nbsp; Usage would be like so:<br><br>&nbsp; &gt;&gt;&gt; p=myObj.project(Field('count(*)', asname='count'))<br>&nbsp; &gt;&gt;&gt; o=p.getSome()[0]<br>&nbsp; &gt;&gt;&gt;o.count
<br>&nbsp; 44<br><br>I'll also soon make it possible to accomplish the same by:<br><br>&nbsp; myObj.project('count(*) as count')<br><br>Aliases have other use cases as well, of course&nbsp; -- when you have a column called &quot;class&quot;, for instance.
<br><br>Cheers,<br><br>js<br><br>ps.&nbsp; I am using gmail while my usual mail server is being repaired.<br clear="all"><br>-- <br>Jacob Smullyan<br><br>

------=_Part_5739_12763439.1154535746379--


--===============0051184556==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
--===============0051184556==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Skunkweb-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skunkweb-list

--===============0051184556==--