RussellEngland / php-sql-parser

Automatically exported from code.google.com/p/php-sql-parser
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Creator fails on group by pos #86

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Attempt to create an SQL string with a source that has
    [GROUP] => Array
        (
            [0] => Array
                (
                    [expr_type] => pos
                    [base_expr] => 1
                )

        )

What is the expected output? What do you see instead?
Expected output is an SQL query.
What I see is:
PHP Fatal error:  Uncaught exception 'UnableToCreateSQLException' with message 
'unknown expr_type in GROUP[0] pos' in 
/path/PHP-SQL-Parser/php-sql-creator.php:182
Stack trace:
#0 /path/PHP-SQL-Parser/php-sql-creator.php(77): 
PHPSQLCreator->processGROUP(Array)
#1 /path/PHP-SQL-Parser/php-sql-creator.php(53): 
PHPSQLCreator->processSelectStatement(Array)
#2 /path/PHP-SQL-Parser/php-sql-creator.php(40): PHPSQLCreator->create(Array)
#3 /path/class.php(177): PHPSQLCreator->__construct(Array)
#4 /path/class.php(91): cache->refreshData()
#5 /path/script.php(84): cache->__construct(Object(defaults), 'select 
`ID`,...', 0, 120, '`stop`')
#6 {main}
  thrown in /path/PHP-SQL-Parser/php-sql-creator.php on line 182

What version of the product are you using? On what operating system?
php-sql-parser-20120822.zip, Debian

Please provide any additional information below.
Changing line 584 from 
            if ($parsed['expr_type'] !== 'colref') {
to
            if ($parsed['expr_type'] !== 'colref' && $parsed['expr_type'] !== 'pos') {
fixed the issue, but I'm not familiar with the code enough to know if that will 
break other cases.  Another thought was adding an argument to processColRef(), 
$context, to allow for selectively allowing expr_type to be colref, pos, or 
both based on where in the SQL statement it is.

Original issue reported on code.google.com by swe...@gmail.com on 4 Jan 2013 at 1:45

GoogleCodeExporter commented 8 years ago
I have added some code to the repository which handles the "pos" expression 
type.

Original comment by pho...@gmx.de on 23 Oct 2013 at 8:57