Bug 665 - DataColumn Expressions functions TRIM and SUBSTRING don't support calculated functions as argument
Summary: DataColumn Expressions functions TRIM and SUBSTRING don't support calculated ...
Status: CLOSED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data ()
Version: 2.10.x
Hardware: Macintosh Mac OS
: High critical
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-09-07 12:45 UTC by Dominique NORMAND
Modified: 2012-01-06 14:10 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
CLOSED FIXED

Description Dominique NORMAND 2011-09-07 12:45:03 UTC
The following expressions are not supported by System.Data:
SUBSTRING(ISNULL([columnName1] + ', ' + [columnName2], [columnName1]), 1, 200)
TRIM(ISNULL([columnName1] + ', ' + [columnName2], [columnName1]))


Reproducible: Always

Steps to Reproduce:
1. DataTable t = new DataTable() ;
2. DataColumn c1 = t.Columns.Add("c1");
3. DataColumn c2 = t.Columns.Add("c2");
4. c2.Expression = "TRIM(ISNULL(c1,' ')";
4. c2.Expression = "SUBSTRING(ISNULL(c1,' '), 1, 10)";
Actual Results:  
Unhandled Exception: System.Data.SyntaxErrorException: Expression
'TRIM(ISNULL(c1,''))' is invalid.
  at Mono.Data.SqlExpressions.Parser.Compile (System.String sqlExpr) [0x00041]
in
/private/tmp/monobuild/build/BUILD/mono-2.6.1/mcs/class/System.Data/Mono.Data.SqlExpressions/Mono.Data.SqlExpressions/Parser.jay:52 
  at System.Data.DataColumn.set_Expression (System.String value) [0x000a2] in
/private/tmp/monobuild/build/BUILD/mono-2.6.1/mcs/class/System.Data/System.Data/DataColumn.cs:499 
  at TestExpression.MainClass.Main (System.String[] args) [0x00054] in
/Users/dnormand/TEST/TestExpression/TestExpression/Main.cs:20 

Expected Results:  
No Exception and the expression should work.

This is due to the definition of TRIM and SUBSTRING in
Mono.Data.SqlExpressions/Parser.jay

TRIM And SUBSTRING are StringFunction and accept only StringExpr as argument.
StringExpr allows only SingleColumnValue, StringLiteral or StringFunction but
NOT CalcFunction. So we can't even use CONVERT(<value>, "System.String") as
argument of those functions.
Comment 1 Miguel de Icaza [MSFT] 2011-09-09 22:09:14 UTC
Fixed in mono/master and mono/mono-2-10

This needs to flow to mobile-master before it gets to MonoTouch
Comment 2 PJ 2012-01-06 14:09:34 UTC
Verified as fixed in
Mono 2.10.8
Monodevelop 2.8.5.1
MonoTouch 5.0.4
Mac 10.7.2
Comment 3 PJ 2012-01-06 14:10:12 UTC
Fix is in production. Closing.