Skip to content

Linq failure on null parameter value #2833

Closed
@micmerchant

Description

@micmerchant

Hello!

First, thank you for fixing our issue #2805 in your develop branch. But as it was difficult to identify further regression bugs, due to the major problems we had with the solved issue, we decided to give the develop branch a try.

I'm not sure if it is okay to create an issue for an unreleased version ... simply because it is work in progress .. but there is one that is causing troubles in our application (at least in our unit tests). But I guess, the sooner you know about potential problems, the better.

So, I've added an unit test, which fails with the following exception in the dev branch, but not in the current stable release (5.3.8):

NHibernate.Test.Linq.LinqQuerySamples.ReplaceFunctionWithNullArgument

System.ArgumentNullException : A type specific Set(name, val) should be called because the Type can not be guessed from a null value.
Parameter name: val
   at NHibernate.Impl.AbstractQueryImpl.SetParameter(String name, Object val) in C:\git\Repositories\Tools\NHibernate\Default\Core\src\NHibernate\Impl\AbstractQueryImpl.cs:line 307
   at NHibernate.Linq.DefaultQueryProvider.SetParameters(IQuery query, IDictionary`2 parameters) in C:\git\Repositories\Tools\NHibernate\Default\Core\src\NHibernate\Linq\DefaultQueryProvider.cs:line 268
   at NHibernate.Linq.DefaultQueryProvider.PrepareQuery(Expression expression, IQuery& query) in C:\git\Repositories\Tools\NHibernate\Default\Core\src\NHibernate\Linq\DefaultQueryProvider.cs:line 215
   at NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression) in C:\git\Repositories\Tools\NHibernate\Default\Core\src\NHibernate\Linq\DefaultQueryProvider.cs:line 94
   at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression expression) in C:\git\Repositories\Tools\NHibernate\Default\Core\src\NHibernate\Linq\DefaultQueryProvider.cs:line 101
   at System.Linq.Queryable.First[TSource](IQueryable`1 source)
   at NHibernate.Test.Linq.LinqQuerySamples.ReplaceFunctionWithNullArgument() in C:\git\Repositories\Tools\NHibernate\Default\Core\src\NHibernate.Test\Linq\LinqQuerySamples.cs:line 1967



-----

One or more child tests had errors
  Exception doesn't have a stacktrace

LinqQuerySamples:

[Test]
public void ReplaceFunctionWithNullArgument()
{
	var query = from e in db.Employees
				select e.FirstName.Replace(e.LastName, null);
	var result = query.First();
	Assert.That(result, Is.Null, "Expected REPLACE(FirstName, LastName, NULL) to be null");
}

Thanks in advance,
best regards
Michael

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions