Skip to content

String concatenation within the query doesn't work #194

@Thorium

Description

@Thorium

I try to do this:

let query = 
    query {
        for cust in dc.Main.Customers do
        select (cust.CompanyName + " " + cust.CompanyName)
    }

It worked on the NuGet version but doesn't work with the GitHub version.
GitHub version fails with:

The binary operator Add is not defined for the types 'System.String' and 'System.String'.","T":"   
   at System.Linq.Expressions.Expression.GetUserDefinedBinaryOperatorOrThrow(ExpressionType binaryType, String name, Expression left, Expression right, Boolean liftToNull)
   at System.Linq.Expressions.Expression.Add(Expression left, Expression right, MethodInfo method)
   at FSharp.Data.Sql.QueryExpression.QueryExpressionTransformer.transform@49(List`1 tupleIndex, ParameterExpression resultParam, FSharpMap`2 aliasEntityDict, Dictionary`2 projectionMap, FSharpOption`1 en, Expression e) in C:\\git\\SQLProvider\\src\\SQLProvider\\SqlRuntime.QueryExpression.fs:line 64
   at FSharp.Data.Sql.QueryExpression.QueryExpressionTransformer.transform@49(List`1 tupleIndex, ParameterExpression resultParam, FSharpMap`2 aliasEntityDict, Dictionary`2 projectionMap, FSharpOption`1 en, Expression e) in C:\\git\\SQLProvider\\src\\SQLProvider\\SqlRuntime.QueryExpression.fs:line 64
   at FSharp.Data.Sql.QueryExpression.QueryExpressionTransformer.transform@49(List`1 tupleIndex, ParameterExpression resultParam, FSharpMap`2 aliasEntityDict, Dictionary`2 projectionMap, FSharpOption`1 en, Expression e) in C:\\git\\SQLProvider\\src\\SQLProvider\\SqlRuntime.QueryExpression.fs:line 64
   at FSharp.Data.Sql.QueryExpression.QueryExpressionTransformer.transform@49(List`1 tupleIndex, ParameterExpression resultParam, FSharpMap`2 aliasEntityDict, Dictionary`2 projectionMap, FSharpOption`1 en, Expression e) in C:\\git\\SQLProvider\\src\\SQLProvider\\SqlRuntime.QueryExpression.fs:line 64
   at FSharp.Data.Sql.QueryExpression.QueryExpressionTransformer.transform@118-8.Invoke(Expression a) in C:\\git\\SQLProvider\\src\\SQLProvider\\SqlRuntime.QueryExpression.fs:line 118
   at Microsoft.FSharp.Collections.IEnumerator.map@107.DoMoveNext(b& )
   at Microsoft.FSharp.Collections.IEnumerator.MapEnumerator`1.System-Collections-IEnumerator-MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Dynamic.Utils.CollectionExtensions.ToReadOnly[T](IEnumerable`1 enumerable)
   at System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, IEnumerable`1 arguments)
   at FSharp.Data.Sql.QueryExpression.QueryExpressionTransformer.transform@49(List`1 tupleIndex, ParameterExpression resultParam, FSharpMap`2 aliasEntityDict, Dictionary`2 projectionMap, FSharpOption`1 en, Expression e) in C:\\git\\SQLProvider\\src\\SQLProvider\\SqlRuntime.QueryExpression.fs:line 118
   at FSharp.Data.Sql.QueryExpression.QueryExpressionTransformer.transform@49(List`1 tupleIndex, ParameterExpression resultParam, FSharpMap`2 aliasEntityDict, Dictionary`2 projectionMap, FSharpOption`1 en, Expression e) in C:\\git\\SQLProvider\\src\\SQLProvider\\SqlRuntime.QueryExpression.fs:line 123
(...cutted some loop here, expression tree recursion I suppose...)
FSharp.Data.Sql.QueryExpression.QueryExpressionTransformer.transform[a](Expression projection, List`1 tupleIndex, ParameterExpression resultParam, a baseTableAlias, FSharpMap`2 aliasEntityDict) in C:\\git\\SQLProvider\\src\\SQLProvider\\SqlRuntime.QueryExpression.fs:line 146
   at FSharp.Data.Sql.QueryExpression.QueryExpressionTransformer.convertExpression(SqlExp exp, List`1 entityIndex, IDbConnection con, ISqlProvider provider) in C:\\git\\SQLProvider\\src\\SQLProvider\\SqlRuntime.QueryExpression.fs:line 169
   at FSharp.Data.Sql.Runtime.QueryImplementation.executeQuery(ISqlDataContext dc, ISqlProvider provider, SqlExp sqlExp, List`1 ti) in C:\\git\\SQLProvider\\src\\SQLProvider\\SqlRuntime.Linq.fs:line 36
   at FSharp.Data.Sql.Runtime.QueryImplementation.SqlQueryable`1.System-Collections-Generic-IEnumerable`1-GetEnumerator() in C:\\git\\SQLProvider\\src\\SQLProvider\\SqlRuntime.Linq.fs:line 77
   at Microsoft.FSharp.Collections.SeqModule.ToArray[T](IEnumerable`1 source)
(...and this is the query evaluation...)

But to be able to really investigate this it would be nice if the unit tests would work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions