diff --git a/src/NHibernate.Test/Async/Criteria/Lambda/FunctionsIntegrationFixture.cs b/src/NHibernate.Test/Async/Criteria/Lambda/FunctionsIntegrationFixture.cs index e21a2e3f6b2..91296d9f638 100644 --- a/src/NHibernate.Test/Async/Criteria/Lambda/FunctionsIntegrationFixture.cs +++ b/src/NHibernate.Test/Async/Criteria/Lambda/FunctionsIntegrationFixture.cs @@ -145,9 +145,6 @@ public async Task FunctionsToLowerToUpperAsync() [Test] public async Task ConcatAsync() { - if (TestDialect.HasBrokenTypeInferenceOnSelectedParameters) - Assert.Ignore("Current dialect does not support this test"); - using (var s = OpenSession()) using (s.BeginTransaction()) { diff --git a/src/NHibernate.Test/Async/Criteria/ProjectionsTest.cs b/src/NHibernate.Test/Async/Criteria/ProjectionsTest.cs index aca0e5d3660..28fd672ccab 100644 --- a/src/NHibernate.Test/Async/Criteria/ProjectionsTest.cs +++ b/src/NHibernate.Test/Async/Criteria/ProjectionsTest.cs @@ -69,9 +69,6 @@ protected override void OnTearDown() [Test] public async Task UsingSqlFunctions_ConcatAsync() { - if (TestDialect.HasBrokenTypeInferenceOnSelectedParameters) - Assert.Ignore("Current dialect does not support this test"); - using (ISession session = Sfi.OpenSession()) { string result = await (session.CreateCriteria(typeof(Student)) @@ -89,12 +86,8 @@ public async Task UsingSqlFunctions_ConcatAsync() [Test] public async Task UsingSqlFunctions_Concat_WithCastAsync() { - if(Dialect is Oracle8iDialect) - { + if (Dialect is Oracle8iDialect) Assert.Ignore("Not supported by the active dialect:{0}.", Dialect); - } - if (TestDialect.HasBrokenTypeInferenceOnSelectedParameters) - Assert.Ignore("Current dialect does not support this test"); using (ISession session = Sfi.OpenSession()) { diff --git a/src/NHibernate.Test/Async/Hql/HQLFunctions.cs b/src/NHibernate.Test/Async/Hql/HQLFunctions.cs index a9c304aaa66..5042515aa99 100644 --- a/src/NHibernate.Test/Async/Hql/HQLFunctions.cs +++ b/src/NHibernate.Test/Async/Hql/HQLFunctions.cs @@ -1142,6 +1142,25 @@ public async Task ConcatAsync() } } } + + [Test] + public async Task ConcatWithNullAsync() + { + AssumeFunctionSupported("concat"); + using (var s = OpenSession()) + { + var a1 = new Animal("abcdef", 1f); + await (s.SaveAsync(a1)); + await (s.FlushAsync()); + } + + using (var s = OpenSession()) + { + var hql = "select concat(a.Description,null) from Animal a"; + var lresult = await (s.CreateQuery(hql).ListAsync()); + Assert.That(lresult[0], Is.EqualTo("abcdef")); + } + } [Test] public async Task HourMinuteSecondAsync() diff --git a/src/NHibernate.Test/Criteria/Lambda/FunctionsIntegrationFixture.cs b/src/NHibernate.Test/Criteria/Lambda/FunctionsIntegrationFixture.cs index 7d5b7d014cf..202487c8f1f 100644 --- a/src/NHibernate.Test/Criteria/Lambda/FunctionsIntegrationFixture.cs +++ b/src/NHibernate.Test/Criteria/Lambda/FunctionsIntegrationFixture.cs @@ -134,9 +134,6 @@ public void FunctionsToLowerToUpper() [Test] public void Concat() { - if (TestDialect.HasBrokenTypeInferenceOnSelectedParameters) - Assert.Ignore("Current dialect does not support this test"); - using (var s = OpenSession()) using (s.BeginTransaction()) { diff --git a/src/NHibernate.Test/Criteria/ProjectionsTest.cs b/src/NHibernate.Test/Criteria/ProjectionsTest.cs index 0eb03b33a60..c53b0158639 100644 --- a/src/NHibernate.Test/Criteria/ProjectionsTest.cs +++ b/src/NHibernate.Test/Criteria/ProjectionsTest.cs @@ -58,9 +58,6 @@ protected override void OnTearDown() [Test] public void UsingSqlFunctions_Concat() { - if (TestDialect.HasBrokenTypeInferenceOnSelectedParameters) - Assert.Ignore("Current dialect does not support this test"); - using (ISession session = Sfi.OpenSession()) { string result = session.CreateCriteria(typeof(Student)) @@ -78,12 +75,8 @@ public void UsingSqlFunctions_Concat() [Test] public void UsingSqlFunctions_Concat_WithCast() { - if(Dialect is Oracle8iDialect) - { + if (Dialect is Oracle8iDialect) Assert.Ignore("Not supported by the active dialect:{0}.", Dialect); - } - if (TestDialect.HasBrokenTypeInferenceOnSelectedParameters) - Assert.Ignore("Current dialect does not support this test"); using (ISession session = Sfi.OpenSession()) { diff --git a/src/NHibernate.Test/Hql/HQLFunctions.cs b/src/NHibernate.Test/Hql/HQLFunctions.cs index 1a2b80b0efd..0a23dc1e675 100644 --- a/src/NHibernate.Test/Hql/HQLFunctions.cs +++ b/src/NHibernate.Test/Hql/HQLFunctions.cs @@ -1131,6 +1131,25 @@ public void Concat() } } } + + [Test] + public void ConcatWithNull() + { + AssumeFunctionSupported("concat"); + using (var s = OpenSession()) + { + var a1 = new Animal("abcdef", 1f); + s.Save(a1); + s.Flush(); + } + + using (var s = OpenSession()) + { + var hql = "select concat(a.Description,null) from Animal a"; + var lresult = s.CreateQuery(hql).List(); + Assert.That(lresult[0], Is.EqualTo("abcdef")); + } + } [Test] public void HourMinuteSecond() diff --git a/src/NHibernate.Test/TestDialects/SapSQLAnywhere17TestDialect.cs b/src/NHibernate.Test/TestDialects/SapSQLAnywhere17TestDialect.cs index 35a35092ce3..a6b4c0718b2 100644 --- a/src/NHibernate.Test/TestDialects/SapSQLAnywhere17TestDialect.cs +++ b/src/NHibernate.Test/TestDialects/SapSQLAnywhere17TestDialect.cs @@ -30,12 +30,10 @@ public SapSQLAnywhere17TestDialect(Dialect.Dialect dialect) /// /// - /// SQL Anywhere treats string parameters concatenation as yielding numeric and fails casting - /// the actual string value if it is not castable to a number. Likewise, in case when - /// statement, it treats them as yielding integer if all case yields parameter values, whatever - /// the actual type of the parameters. And in case of numeric computations with a numeric - /// parameter, the result is treated as a fractional digit lossy double instead of being kept - /// numeric. See https://stackoverflow.com/q/52558715/1178314. + /// SQL Anywhere treats parameters in case when statement as yielding integer if all case yields + /// parameter values, whatever the actual type of the parameters. And in case of numeric computations + /// with a numeric parameter, the result is treated as a fractional digit lossy double instead of + /// being kept numeric. See https://stackoverflow.com/q/52558715/1178314. /// public override bool HasBrokenTypeInferenceOnSelectedParameters => true; diff --git a/src/NHibernate/Dialect/SybaseSQLAnywhere10Dialect.cs b/src/NHibernate/Dialect/SybaseSQLAnywhere10Dialect.cs index 290e626671f..4b7b1cf4c48 100644 --- a/src/NHibernate/Dialect/SybaseSQLAnywhere10Dialect.cs +++ b/src/NHibernate/Dialect/SybaseSQLAnywhere10Dialect.cs @@ -257,7 +257,6 @@ protected virtual void RegisterStringFunctions() RegisterFunction("char_length", new StandardSQLFunction("char_length", NHibernateUtil.Int32)); RegisterFunction("compare", new VarArgsSQLFunction(NHibernateUtil.Int32, "compare(", ",", ")")); RegisterFunction("compress", new VarArgsSQLFunction(NHibernateUtil.BinaryBlob, "compress(", ",", ")")); - RegisterFunction("concat", new VarArgsSQLFunction(NHibernateUtil.String, "(", "+", ")")); RegisterFunction("csconvert", new VarArgsSQLFunction(NHibernateUtil.StringClob, "csconvert(", ",", ")")); RegisterFunction("decompress", new VarArgsSQLFunction(NHibernateUtil.BinaryBlob, "decompress(", ",", ")")); RegisterFunction("decrypt", new VarArgsSQLFunction(NHibernateUtil.BinaryBlob, "decrypt(", ",", ")"));