Re: IN in WHERE-clause is not being parsed correctly using SQL::Statement

[email protected] ("Garry T. Williams") Wed, 13 May 2020 09:52:50 -0400
Newsgroups perl.dbi.users
Message-ID <11523607.O9o76ZdvQC@tfr>
On Tuesday, May 12, 2020 3:50:31 PM EDT Jens Rehsack wrote:
> > Am 12.05.2020 um 21:49 schrieb Provensal, Jerome <[email protected]>:
> > Hi Jens,
> > I was hoping that you could help me with an issue I’m having with
> > SQL::Statement.
> > 
> > My goal is to make transitioning from Sybase to MySQL a breeze by
> > converting Sybase-like SQL statements into MySQL statements.  For
> > that, I was planning on using SQL::Statement.
> > 
> > While evaluating the module, I ran into an issue with the “IN”
> > predicate.  I posted a “request for help” on SO:
> > https://stackoverflow.com/questions/61743167/in-in-where-clause-is-not-being-parsed-correctly-using-sqlstatement
> > <https://stackoverflow.com/questions/61743167/in-in-where-clause-is-not-being-parsed-correctly-using-sqlstatement>
> > but so far without much luck.  I was hoping that going to the
> > “source” (i.e. you) would help.

I don't know about the source -- this is the DBI mailing list.  But...

I cannot reproduce your error:

    garry@tfr$ perl -MSQL::Statement -MData::Dumper -wle '
    $p=SQL::Parser->new("ANSI");
    $p->{RaiseError}=1;
    $p->{PrintError}=0;
    print Dumper(SQL::Statement->new("SELECT c1,co12 AS c2, c3 FROM table1 t1, table2 t2 WHERE t1.c1 = t2.c2 AND t1.c1 IN (11111, 22222, 33333) GROUP BY t1.c1",$p)->where_hash());
    '
    $VAR1 = {
	      'neg' => 0,
	      'arg2' => {
			  'op' => 'IN',
			  'arg1' => {
				      'type' => 'column',
				      'value' => 'table1.c1',
				      'fullorg' => 't1.c1'
				    },
			  'nots' => {},
			  'arg2' => [
				      {
					'fullorg' => '11111',
					'type' => 'number',
					'value' => '11111'
				      },
				      {
					'value' => '22222',
					'type' => 'number',
					'fullorg' => '22222'
				      },
				      {
					'value' => '33333',
					'type' => 'number',
					'fullorg' => '33333'
				      }
				    ],
			  'neg' => 0
			},
	      'nots' => {},
	      'arg1' => {
			  'arg1' => {
				      'fullorg' => 't1.c1',
				      'value' => 'table1.c1',
				      'type' => 'column'
				    },
			  'op' => '=',
			  'arg2' => {
				      'type' => 'column',
				      'value' => 'table2.c2',
				      'fullorg' => 't2.c2'
				    },
			  'nots' => {},
			  'neg' => 0
			},
	      'op' => 'AND'
	    };

    garry@tfr$ perl -MSQL::Statement -wle 'print $SQL::Statement::VERSION'
    1.412
    garry@tfr$

-- 
Garry T. Williams