Skip Menu |

This queue is for tickets about the SQL-Statement CPAN distribution.

Report information
The Basics
Id: 124133
Status: resolved
Priority: 0/
Queue: SQL-Statement

People
Owner: Nobody in particular
Requestors: skoypidiara [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: an't call method "name" on unblessed reference in printf "Columns %s\n",join( ',', map {$_->name} $stmt->column_defs() );
Date: Fri, 19 Jan 2018 17:09:55 +0200
To: bug-SQL-Statement [...] rt.cpan.org
From: Kanenas Polifimos <skoypidiara [...] gmail.com>
Hello, I am sorry for bothering you but trying to execute the paradigm of SQL::Statement::Structure on a Strawberry perl v5.21.1 I had the following error. Can't call method "name" on unblessed reference The code is the following: use SQL::Statement; use Data::Dumper; my $sql = "SELECT a,aa FROM b JOIN c WHERE c=? AND e=7 ORDER BY f DESC LIMIT 5,2"; my $parser = SQL::Parser->new(); $parser->{RaiseError}=1; $parser->{PrintError}=0; # $parser->parse("LOAD 'MyLib::MySyntax' "); my $stmt = SQL::Statement->new($sql,$parser); printf "Command %s\n",$stmt->command; printf "Num of Placeholders %s\n",scalar $stmt->params; printf "Tables %s\n",join( ',', map {$_->name} $stmt->tables() ); printf "Where operator %s\n",join( ',', $stmt->where->op() ); printf "Limit %s\n",$stmt->limit(); printf "Offset %s\n",$stmt->offset(); printf "Columns %s\n",join( ',', map {$_->name} $stmt->column_defs() ); Can you please help? Thank you Lalakis Oeisagwmenos
On Fri Jan 19 10:10:35 2018, skoypidiara@gmail.com wrote: Show quoted text
> Hello, > I am sorry for bothering you but trying to execute the paradigm of > SQL::Statement::Structure on a Strawberry perl v5.21.1 I had the following > error. > > > Can't call method "name" on unblessed reference > The code is the following: > use SQL::Statement; > use Data::Dumper; > my $sql = "SELECT a,aa FROM b JOIN c WHERE c=? AND e=7 ORDER BY f DESC > LIMIT 5,2"; > my $parser = SQL::Parser->new(); > $parser->{RaiseError}=1; > $parser->{PrintError}=0; > # $parser->parse("LOAD 'MyLib::MySyntax' "); > my $stmt = SQL::Statement->new($sql,$parser); > printf "Command %s\n",$stmt->command; > printf "Num of Placeholders %s\n",scalar $stmt->params; > > printf "Tables %s\n",join( ',', map {$_->name} $stmt->tables() ); > printf "Where operator %s\n",join( ',', $stmt->where->op() ); > printf "Limit %s\n",$stmt->limit(); > printf "Offset %s\n",$stmt->offset(); > > printf "Columns %s\n",join( ',', map {$_->name} $stmt->column_defs() ); > > Can you please help? > Thank you > Lalakis Oeisagwmenos
column_defs are created by buildColumnObjects at the end of open_tables. This is done that late, because there is no dictionary (yet) and so no one knows what a "select *" could mean. Cheers, Jens
CC: Dan [...] dwright.org
Subject: Re: [rt.cpan.org #124133] an't call method "name" on unblessed reference in printf "Columns %s\n",join( ',', map {$_->name} $stmt->column_defs() );
Date: Mon, 22 Jan 2018 11:40:13 +0200
To: bug-SQL-Statement [...] rt.cpan.org
From: Kanenas Polifimos <skoypidiara [...] gmail.com>
OK, I agree that it is created buildColumnObjects at the end of open_tables. I've read the code but I have the following questions. 1) The query has distinct columns a and aa and not *, so the dialect is parsable. 2) It seems that the column objects are not created (not blessed shelfs) and that's the reason for the error. 3) How could we take the columns of the query? How could this example work? On Fri, Jan 19, 2018 at 6:06 PM, Jens Rehsack via RT < bug-SQL-Statement@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=124133 > > > On Fri Jan 19 10:10:35 2018, skoypidiara@gmail.com wrote:
> > Hello, > > I am sorry for bothering you but trying to execute the paradigm of > > SQL::Statement::Structure on a Strawberry perl v5.21.1 I had the
> following
> > error. > > > > > > Can't call method "name" on unblessed reference > > The code is the following: > > use SQL::Statement; > > use Data::Dumper; > > my $sql = "SELECT a,aa FROM b JOIN c WHERE c=? AND e=7 ORDER BY f DESC > > LIMIT 5,2"; > > my $parser = SQL::Parser->new(); > > $parser->{RaiseError}=1; > > $parser->{PrintError}=0; > > # $parser->parse("LOAD 'MyLib::MySyntax' "); > > my $stmt = SQL::Statement->new($sql,$parser); > > printf "Command %s\n",$stmt->command; > > printf "Num of Placeholders %s\n",scalar $stmt->params; > > > > printf "Tables %s\n",join( ',', map {$_->name} $stmt->tables() ); > > printf "Where operator %s\n",join( ',', $stmt->where->op() ); > > printf "Limit %s\n",$stmt->limit(); > > printf "Offset %s\n",$stmt->offset(); > > > > printf "Columns %s\n",join( ',', map {$_->name} $stmt->column_defs() ); > > > > Can you please help? > > Thank you > > Lalakis Oeisagwmenos
> > column_defs are created by buildColumnObjects at the end of open_tables. > This is done that late, because there is no dictionary (yet) and so no one > knows what a "select *" could mean. > > Cheers, > Jens > >
On Mon Jan 22 04:41:03 2018, skoypidiara@gmail.com wrote: Show quoted text
> OK, I agree that it is created buildColumnObjects at the end of > open_tables.
Thank you very much. I appreciate this. Show quoted text
> I've read the code but I have the following questions. > 1) The query has distinct columns a and aa and not *, so the dialect is > parsable.
And? Show quoted text
> 2) It seems that the column objects are not created (not blessed shelfs) > and that's the reason for the error.
When? In your example? You never invoked the column_defs build routine! Show quoted text
> 3) How could we take the columns of the query? How could this example work?
Perform an execute on the $stmt before querying the columns. This will fail for other reasons - but this is (sorry for that): an example you should use to debug on your own. Show quoted text
> On Fri, Jan 19, 2018 at 6:06 PM, Jens Rehsack via RT < > bug-SQL-Statement@rt.cpan.org> wrote: >
> > <URL: https://rt.cpan.org/Ticket/Display.html?id=124133 > > > > > On Fri Jan 19 10:10:35 2018, skoypidiara@gmail.com wrote:
> > > Hello, > > > I am sorry for bothering you but trying to execute the paradigm of > > > SQL::Statement::Structure on a Strawberry perl v5.21.1 I had the
> > following
> > > error. > > > > > > > > > Can't call method "name" on unblessed reference > > > The code is the following: > > > use SQL::Statement; > > > use Data::Dumper; > > > my $sql = "SELECT a,aa FROM b JOIN c WHERE c=? AND e=7 ORDER BY f DESC > > > LIMIT 5,2"; > > > my $parser = SQL::Parser->new(); > > > $parser->{RaiseError}=1; > > > $parser->{PrintError}=0; > > > # $parser->parse("LOAD 'MyLib::MySyntax' "); > > > my $stmt = SQL::Statement->new($sql,$parser); > > > printf "Command %s\n",$stmt->command; > > > printf "Num of Placeholders %s\n",scalar $stmt->params; > > > > > > printf "Tables %s\n",join( ',', map {$_->name} $stmt->tables() ); > > > printf "Where operator %s\n",join( ',', $stmt->where->op() ); > > > printf "Limit %s\n",$stmt->limit(); > > > printf "Offset %s\n",$stmt->offset(); > > > > > > printf "Columns %s\n",join( ',', map {$_->name} $stmt->column_defs() ); > > > > > > Can you please help? > > > Thank you > > > Lalakis Oeisagwmenos
> > > > column_defs are created by buildColumnObjects at the end of open_tables. > > This is done that late, because there is no dictionary (yet) and so no one > > knows what a "select *" could mean. > > > > Cheers, > > Jens > > > >