Fwd: Simple query makes SQL::Abstract puke

4 messages Options
Embed this post
Permalink
Ido Perlmuter

Fwd: Simple query makes SQL::Abstract puke

Reply Threaded More More options
Print post
Permalink


---------- Forwarded message ----------
From: Ido Perlmuter <[hidden email]>
Date: Wed, Oct 7, 2009 at 6:40 PM
Subject: Simple query makes SQL::Abstract puke
To: [hidden email]


Hi.

For some reason, the following query has been constantly causing an SQL::Abstract error message.

Query: $c->model('DB::Stuff')->single({ stage_id => $stage->id, num => 0, foreign_id => $foreign->id, type => 0 });

Error: "can't quote an empty label".

This happens inside SQL::Abstract's _quote subroutine, which, for some reason, gets an undefined label for quoting, which is weird, 'cause the \%where hashref I'm giving the single method has nothing wrong with it. Or does it?

Any help appreciated,
Ido.


_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Moritz Onken

Re: Fwd: Simple query makes SQL::Abstract puke

Reply Threaded More More options
Print post
Permalink

Am 08.10.2009 um 14:18 schrieb Ido Perlmuter:

>
>
> ---------- Forwarded message ----------
> From: Ido Perlmuter <[hidden email]>
> Date: Wed, Oct 7, 2009 at 6:40 PM
> Subject: Simple query makes SQL::Abstract puke
> To: [hidden email]
>
>
> Hi.
>
> For some reason, the following query has been constantly causing an  
> SQL::Abstract error message.
>
> Query: $c->model('DB::Stuff')->single({ stage_id => $stage->id, num  
> => 0, foreign_id => $foreign->id, type => 0 });

Can you post the output of
use Data::Dumper; print Dumper { stage_id => $stage->id, num => 0,  
foreign_id => $foreign->id, type => 0 };

cheers, moritz

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Quinn Fazigu

Re: Fwd: Simple query makes SQL::Abstract puke

Reply Threaded More More options
Print post
Permalink
In reply to this post by Ido Perlmuter





On Thu, Oct 8, 2009 at 8:18 AM, Ido Perlmuter <[hidden email]> wrote:
For some reason, the following query has been constantly causing an SQL::Abstract error message.

Query: $c->model('DB::Stuff')->single({ stage_id => $stage->id, num => 0, foreign_id => $foreign->id, type => 0 });

Error: "can't quote an empty label".

Just a wild guess:

Are $stage->id() or $foreign->id() returning an array and/or undef, perhaps, and that's causing a hashref key that is an "empty" label?  Do you see the "Odd number of elements" or "uninitialized value" errors?

$ perl -Mwarnings -Mstrict -MData::Dumper -e 'my $stage = sub { return qw( a b ) }; my $foreign = sub { return undef }; my $query_hr = { stage_id => $stage->(), num => 0, foreign_id => $foreign->(), type => 0 }; print Dumper($query_hr);'
Use of uninitialized value in anonymous hash ({}) at -e line 1.
Odd number of elements in anonymous hash at -e line 1.
$VAR1 = {
          '' => 'type',
          '0' => undef,
          'b' => 'num',
          'stage_id' => 'a'
        };

 

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Ido Perlmuter

Re: Fwd: Simple query makes SQL::Abstract puke

Reply Threaded More More options
Print post
Permalink
Yep, that was my stupid mistake. $stage->id was OK, it was $foreign->id that made the problem... I forgot I missed a many_to_many connection, so $foreign->id actually returned an array instead of the unique row I really wanted. Don't know why I didn't think about using Dumper to check the hash-ref, as I do use it a lot.

Well, never mind, all is well now, thanks a lot everyone.

Ido.

On Thu, Oct 8, 2009 at 2:38 PM, Quinn Fazigu <[hidden email]> wrote:





On Thu, Oct 8, 2009 at 8:18 AM, Ido Perlmuter <[hidden email]> wrote:
For some reason, the following query has been constantly causing an SQL::Abstract error message.

Query: $c->model('DB::Stuff')->single({ stage_id => $stage->id, num => 0, foreign_id => $foreign->id, type => 0 });

Error: "can't quote an empty label".

Just a wild guess:

Are $stage->id() or $foreign->id() returning an array and/or undef, perhaps, and that's causing a hashref key that is an "empty" label?  Do you see the "Odd number of elements" or "uninitialized value" errors?

$ perl -Mwarnings -Mstrict -MData::Dumper -e 'my $stage = sub { return qw( a b ) }; my $foreign = sub { return undef }; my $query_hr = { stage_id => $stage->(), num => 0, foreign_id => $foreign->(), type => 0 }; print Dumper($query_hr);'
Use of uninitialized value in anonymous hash ({}) at -e line 1.
Odd number of elements in anonymous hash at -e line 1.
$VAR1 = {
          '' => 'type',
          '0' => undef,
          'b' => 'num',
          'stage_id' => 'a'
        };

 

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...


_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...