Query regexp

A place to discuss development of the Xataface core.

Query regexp

Postby Jean » Mon Jul 06, 2009 11:58 pm

Hi Steve,
I tried with your new SQL lib from the SVN

My query is
Code: Select all
select * from annuaire_enligne WHERE nom NOT REGEXP '([0-9]{4})' ORDER BY nom


It may come from the line 1465 in the Parser.php in lib/SQL/.
But even without the parenthesis, the error still is displayed.

Code: Select all
while ($this->token == 'ident' or $this->token == '(') {
           if ( $this->token == 'ident' ){
              $tableType = 'ident';
              $this->all_tables[] = $tree['table_names'][] = $tableName = $this->tokText;
           } else {
               //must be a subselect.
            $this->getTok();
            if ( $this->token != 'select' ){
               return $this->raiseError('Expected "select" on line '.__LINE__.' of file '.__FILE__);
            }


And the error is

Warning: Cannot use a scalar value as an array in /var/www/html/xataface-1.1.5r2/lib/SQL/Parser.php on line 1693

Warning: Cannot use a scalar value as an array in /var/www/html/xataface-1.1.5r2/Dataface/Table.php on line 1971

Warning: Invalid argument supplied for foreach() in /var/www/html/xataface-1.1.5r2/Dataface/Table.php on line 1971


I tried
Code: Select all
__sql__="select * from annuaire_enligne WHERE CAST(nom as SIGNED INT)NOT BETWEEN 2000 AND 8000  ORDER BY nom"


but the result is the same.

Although an error is displayed, it seems that the query is still working.

I hope it helps.
Thank you
Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Postby shannah » Tue Jul 07, 2009 6:22 am

Are you sure it's using the SVN version? When I go to line 1693 of SQL/Parser.php it has:
Code: Select all
if ( PEAR::isError($ret) ){


Which could not be causing the error listed as it isn't referencing anything as an array.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Jean » Tue Jul 07, 2009 7:20 am

Steve,
I don't understand, I've checked up, I downloaded the file from
http://weblite.ca/svn/dataface/core/trunk/lib/SQL/
and replace it into /var/www/html/xataface-1.1.5r2/lib/SQL/
Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Postby shannah » Tue Jul 07, 2009 10:28 am

Sorry. Seems I had forgotten to check in the latest version. If you download SQL/Parser.php from svn now, it will be the latest version. However, this version will still fail - ... but it will give a more descriptive error showing what it doesn't like about the SQL query.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Jean » Tue Jul 07, 2009 10:37 am

Fine, thank you again, Steve, I'll tell you.
Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Postby Jean » Tue Jul 07, 2009 11:49 pm

Yes, Steve, the message is a bit more explicit
Fatal error: Failed parsing SQL query on select: Fatal error: Failed parsing SQL query on select: select * from annuaire_enligne WHERE nom NOT REGEXP '[0-9]{4}' ORDER BY nom in /var/www/html/xataface-1.1.5r2/lib/SQL/Parser.php on line 1694

for one and the other
Fatal error: Failed parsing SQL query on select: select * from annuaire_enligne WHERE CAST(nom as SIGNED INT) NOT BETWEEN 2000 AND 8000 ORDER BY nom in /var/www/html/xataface-1.1.5r2/lib/SQL/Parser.php on line 1694

I managed to use an other request that works.
Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Postby shannah » Thu Jul 09, 2009 6:59 am

I have fixed the SQL parser to handle this case. (See issue http://bugs.weblite.ca/view.php?id=517).

Try out the latest from SVN at http://weblite.ca/svn/dataface/core/trunk/lib/SQL

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Jean » Thu Jul 09, 2009 11:51 pm

Thank you Steve, yes it works now.
For your information, the second one didn't.
kind regards
Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France


Return to Xataface Developers

Who is online

Users browsing this forum: No registered users and 18 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved