perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Terrence Brannon <metap...@urth.org>
Subject DBIx::Recordset - nonsense query formation
Date Tue, 25 Nov 2003 20:11:33 GMT
Before applying any of the patches that have been emailed to the embperl 
list,
I thought I would first make sure that the test suite passed.

I could not use Angus Lees' "patches" for the test suite because most of 
them
simply skipped the test when $Driver eg 'Pg'.

This is a rather difficult thing to discuss, so I will simply state the 
facts
as I see them and ask questions when appropriate:

[ fact one ]: the recordset docs document what happens when a series of 
fields
is joined by a "|" and prefixed with a "+":

    '+name|text' => 'abc' will expand to name='abc' or text='abc'

[ fact two ]: the docs do _not_ state what happens when the value (e.g. 
"abc"
in the above) is not a simple scalar. However, test.pl and EXAMPLES 
section of
the docs have such a case:

        printlogf "Search \$compconj";
        print LOG "\n--------------------\n" ;

        $set6 -> Search ({"+$t0\lid|$t0\laddon"     =>  "6\tit",
                          "$t0\lname"          =>  'Fourth Name',
                          "\*$t0\lid"           =>  '>',
                          "\*$t0\laddon"        =>  '<>',
                          "\*$t0\lname"         =>  '=',
                          '$compconj'     =>  'and',
                          '$conj'         =>  'or' }) or die "not ok 
($DBI::errstr)" ;


The SELECT query generated by this:

      DB:  'SELECT id, name, txt FROM dbixrs1, dbixrs3 WHERE 
(dbixrs1.value1=dbixrs3.value1) and (  (  (  id > ? and addon <> ?)  or  
(  id > ? and addon <> ?)) or (  (name = ?)))      ' bind_values=<6 6 it 
it Fourth Name> bind_types=<4 1 4 1 1>

does not make sense because the SQL attempts to do this comparison:

    id > it

...that's right, it attempts to compare a numerical field to the string "it"
which rightly yields an error under Postgres.

I'm going to go ahead and fix this, but thought I would report this as
something I perceive as needing to be fixed.

Here is test.log for this particular Search():

Search $compconj...                   
--------------------
DB:  SelectWhere <*addon>=<<>> type = *
DB:  SelectWhere <*id>=<>> type = *
DB:  SelectWhere <+id|addon>=<6    it> type = +
DB:  Composite Field +id|addon
DB:  Composite Field processing id
DB:  Composite Field get   id > ?
DB:  Composite Field processing addon
DB:  Composite Field get   id > ? and addon <> ?
DB:  Key +id|addon gives   (  id > ? and addon <> ?)  or  (  id > ? and 
addon <> ?) bind_values = <6 6 it it> bind_types=<4 1 4 1>
DB:  expr is   (  (  id > ? and addon <> ?)  or  (  id > ? and addon <>
?))
DB:  SelectWhere <$conj>=<or> type = $
DB:  SelectWhere <*name>=<=> type = *
DB:  SelectWhere <name>=<Fourth Name> type = n
DB:  Single Field name
DB:  Single Field gives name = ?
DB:  Key name gives   (name = ?) bind_values = <6 6 it it Fourth Name> 
bind_types=<4 1 4 1 1>
DB:  expr is   (  (  id > ? and addon <> ?)  or  (  id > ? and addon <>

?)) or (  (name = ?))
DB:  SelectWhere <$compconj>=<and> type = $
DB:  FLUSH Recordset id = 12  DBIx::Recordset=HASH(0x1054af98)
DB:  Row::DESTROY
DB:  Row::DESTROY
DB:  Row::DESTROY
DB:  Row::DESTROY
DB:  Row::DESTROY
DB:  Row::DESTROY
DB:  Row::DESTROY
DB:  Row::DESTROY
DB:  Row::DESTROY
DB:  Row::DESTROY
DB:  Row::DESTROY
DB:  'SELECT id, name, txt FROM dbixrs1, dbixrs3 WHERE 
(dbixrs1.value1=dbixrs3.value1) and (  (  (  id > ? and addon <> ?)  or  
(  id > ? and addon <> ?)) or (  (name = ?)))      ' bind_values=<6 6 it 
it Fourth Name> bind_types=<4 1 4 1 1>
WARN: DBD::Pg::st execute failed: ERROR:  pg_atoi: error in "it": can't 
parse "it" at blib/lib/DBIx/Recordset.pm line 1366.

DB:  ERROR ERROR:  pg_atoi: error in "it": can't parse "it"
not ok (ERROR:  pg_atoi: error in "it": can't parse "it") at test.pl 
line 1453.
DB:  Row::DESTROY
DB:  Row::DESTROY
DB:  FLUSH Recordset id = 12  DBIx::Recordset=HASH(0x1054af98)
DB:  Disconnect (id=12, numOpen = 1)
DB:  DESTROY (id=12, numOpen = 1)



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message