H.Merijn Brand
Thu, 28 Jan 2010 09:58:11 -0800
On Thu, 28 Jan 2010 12:40:00 -0500, Erik Aronesty <e...@q32.com> wrote:
> The fact that count(*) shows up as "count" in the field name isn't driven by
> DBI - it's driver dependent.
DBD::Pg - "count"
DBD::Oracle - "count(*)"
DBD::Unify - "count(*)"
DBD::CSV - "count(*)"
DBD::SQLite - "count(*)"
So IMHO a bug in DBD::Pg.
> Sybase has it as an "unnamed column" (or at least it used to) ... only way
> to get at it would be with an arrayref!
I don't have DBD::Sybase, but I'd opt for a similar change too
> You shouldn't rely on unnamed derived expression columns having a particular
> name ... and it should not be documented as behaving in a particular way by
> DBI, since drivers might change.
Sure, but this is "dbi-dev" - the *developers* list, where I can stir
the pot and hope to get to some standardisation.
> If you use count(*) ... instead use count(*) as the_count
> .... being explicit will avoid problems.
Unless the DBD (or underlying database) does not support field aliases
My personal point of view is almost always from a portability
standpoint.
For performance reasons, I almost always use bind_columns () and seldom
use fetchrow_hashref ().
> On Thu, Jan 28, 2010 at 12:12 PM, H.Merijn Brand <h.m.br...@xs4all.nl>wrote:
>
> > On Thu, 28 Jan 2010 11:59:16 -0500, Erik Aronesty <earone...@gmail.com>
> > wrote:
> >
> > > Just use the *_arrayref versions for multiple fields with the same name
> > > instead of hashref or slice{}
> >
> > That is what I've shown. Bind_columns () or aliasing also works.
> >
> > > You can't reliably refer to fields by name if they overlap.
> >
> > indeed, which is what I have shown.
> > I'm not complaining here or filing a bug report. I'm probing for
> > opinions in how to document this.
> >
> > I *do* think that count, count (*) mapping to count, count /is/ a bug.
--
H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/
using & porting perl 5.6.2, 5.8.x, 5.10.x, 5.11.x on HP-UX 10.20, 11.00,
11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/
http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/