[Dbix-class] chaining search() and +select/+as

BUCHMULLER Norbert norbi.lists at nix.hu
Thu Oct 9 12:15:13 BST 2008


Hi,

it seems to be a bug, but maybe I just overlooked something: if I chain
two searches that contain '+select' (and/or '+as') attributes, then the
column list of the second search() overwrites the column list of the
first.

For example:

  # using the schema of the DBIC manual
  # (see attached file chaining_problem.tbz)
  $schema->resultset('Artist')->search(
    {
    },
    {
      '+select' => [ \'1' ],
      '+as' => [ 'one' ],
    }
  )->search(
    {
    },
    {
      '+select' => [ \'2' ],
      '+as' => [ 'two' ],
    }
  )->first;

This generates this SQL query:

  SELECT me.artistid, me.name, 2 FROM artist me

Instead of what I expected:

  SELECT me.artistid, me.name, 1, 2 FROM artist me


I tried to create at least a test for that (see the attached diff). In
fact there's another issue with 88result_set_column.t: for me it seems
that $psrs->get_column() returns a DBIx::Class::ResultSetColumn object
even if no column exists with that name, so all the '+select/+as' tests
are kind of useless.. :-( I added a test for that bug, too ('+select/+as
nonexistent_column'). Currently that other bug/feature masks the tests
for my original problem.

Can you confirm if it's really a bug? (Or what was that I overlooked?)


Perl: v5.8.8 built for i486-linux-gnu-thread-multi
DBIx::Class: 0.08010
SQL::Abstract: 1.21

norbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dbic_chained_test.diff
Type: text/x-patch
Size: 1034 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20081009/ef8393ce/dbic_chained_test.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: chaining_problem.tbz
Type: application/x-bzip-compressed-tar
Size: 971 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20081009/ef8393ce/chaining_problem.bin


More information about the DBIx-Class mailing list