[Mono-dev] IIF Bug in Mono.Data.SqlExpressions/Parser.jay

A Nagappan anagappan at novell.com
Thu Sep 27 06:30:20 EDT 2007


Hi JR,

I suggest not to break existing test-cases, when adding new code :) If
you could fix the issues that you face, it will be really cool !!!

I too like your first approach than the second.

Thanks
Nagappan
-- 

--
Nagappan A <anagappan at novell.com>
Linux Desktop Testing Project - http://ldtp.freedesktop.org
http://nagappanal.blogspot.com

Novell, Inc.
SUSE* Linux Enterprise 10
Your Linux is ready*
http://www.novell.com/linux




>>> On 9/25/2007 at 8:04 AM, in message
<20070925023445.GA14676 at localdomain>, Joel
Reed <joelwreed at gmail.com> wrote:
> The following code works on MS.NET but not mono svn head (as of
9/24/07):
> 
>   DataTable dt = new DataTable();
>   dt.Columns.Add("SurveyImage", Type.GetType("System.String"), 
> 	  "IIF(LMSurvey, 'g1.gif', 'g2.gif')");
> 
> 
> 1) The attached file "Iif.testcase.diff" adds a test case for
> this. OK to apply?
> 
> 
> 2) I first tried fixing this by adding this code to "BoolExpr"
> 
> Index: class/System.Data/Mono.Data.SqlExpressions/Parser.jay
> ===================================================================
> ---
class/System.Data/Mono.Data.SqlExpressions/Parser.jay	(revision
86284)
> +++ class/System.Data/Mono.Data.SqlExpressions/Parser.jay	(working
copy)
> @@ -118,6 +118,10 @@
>  		$$ = new Negation ((IExpression)$2);
>  	}
>  	| Predicate
> +	| SingleColumnValue
> +	{
> +		$$ = new BoolOperation(Operation.EQ, (IExpression)$1,
new Literal (true));
> +	}
>  	;
>  
>  Predicate
> 
> 
> But this broke alot of test cases (about 8). I think Parser.jay needs
more 
> surgery to fix
> these test cases. For example, this line in "CalcFunction"
> 
>   SUBSTRING PAROPEN Expr COMMA NumberLiteral COMMA NumberLiteral
PARCLOSE
> 
> Doesn't seem correct. Expr is defined as "BoolExpr | ArithExpr". But

> SUBSTRING
> doesn't work on a BoolOperation or ArithmeticOperation afaik. It
works now 
> because
> ArithExpr can also be a "Value". Come to think of it, shouldn't 
> NumberLiteral actually
> be ArithExpr? I'll have to try that on MS.NET...
> 
> Anyway, not wanting to make lots of changes to this file without
checking in 
> here first,
> I instead made this change:
> 
> Index: class/System.Data/Mono.Data.SqlExpressions/Parser.jay
> ===================================================================
> ---
class/System.Data/Mono.Data.SqlExpressions/Parser.jay	(revision
86284)
> +++ class/System.Data/Mono.Data.SqlExpressions/Parser.jay	(working
copy)
> @@ -269,11 +269,19 @@
>  	| VAR		{ $$ = AggregationFunction.Var; }
>  	;
>  
> -CalcFunction
> +IifFunction
>  	: IIF PAROPEN BoolExpr COMMA Expr COMMA Expr PARCLOSE
>  	{
>  		$$ = new IifFunction ((IExpression)$3, (IExpression)$5,
(IExpression)$7);
>  	}
> +	| IIF PAROPEN SingleColumnValue COMMA Expr COMMA Expr PARCLOSE
> +	{
> +		$$ = new IifFunction (new BoolOperation(Operation.EQ,
(IExpression)$3, new 
> Literal (true)), (IExpression)$5, (IExpression)$7);
> +	}
> +	;
> +
> +CalcFunction
> +	: IifFunction
>  	| SUBSTRING PAROPEN Expr COMMA NumberLiteral COMMA NumberLiteral
PARCLOSE
>  	{
>  		long arg1 = (long) $5;
> 
> 
> Which does the job - but seems rather ugly to me. Any comments?
Anyone 
> interested in 
> this quick fix or me taking the first route & fixing up the rest of
this 
> file?
> 
> jr



More information about the Mono-devel-list mailing list