Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Fix concat function definition for SybaseSQLAnywhere10Dialect #2982

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down
9 changes: 1 addition & 8 deletions src/NHibernate.Test/Async/Criteria/ProjectionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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())
{
Expand Down
19 changes: 19 additions & 0 deletions src/NHibernate.Test/Async/Hql/HQLFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>());
Assert.That(lresult[0], Is.EqualTo("abcdef"));
}
}

[Test]
public async Task HourMinuteSecondAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down
9 changes: 1 addition & 8 deletions src/NHibernate.Test/Criteria/ProjectionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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())
{
Expand Down
19 changes: 19 additions & 0 deletions src/NHibernate.Test/Hql/HQLFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>();
Assert.That(lresult[0], Is.EqualTo("abcdef"));
}
}

[Test]
public void HourMinuteSecond()
Expand Down
10 changes: 4 additions & 6 deletions src/NHibernate.Test/TestDialects/SapSQLAnywhere17TestDialect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ public SapSQLAnywhere17TestDialect(Dialect.Dialect dialect)

/// <inheritdoc />
/// <remarks>
/// SQL Anywhere treats string parameters concatenation as yielding <c>numeric</c> and fails casting
/// the actual string value if it is not castable to a number. Likewise, in <c>case when</c>
/// statement, it treats them as yielding <c>integer</c> if all case yields parameter values, whatever
/// the actual type of the parameters. And in case of <c>numeric</c> computations with a <c>numeric</c>
/// parameter, the result is treated as a fractional digit lossy <c>double<c> instead of being kept
/// <c>numeric</c>. See https://stackoverflow.com/q/52558715/1178314.
/// SQL Anywhere treats parameters in <c>case when</c> statement as yielding <c>integer</c> if all case yields
/// parameter values, whatever the actual type of the parameters. And in case of <c>numeric</c> computations
/// with a <c>numeric</c> parameter, the result is treated as a fractional digit lossy <c>double<c> instead of
/// being kept <c>numeric</c>. See https://stackoverflow.com/q/52558715/1178314.
/// </remarks>
public override bool HasBrokenTypeInferenceOnSelectedParameters => true;

Expand Down
1 change: 0 additions & 1 deletion src/NHibernate/Dialect/SybaseSQLAnywhere10Dialect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(", ",", ")"));
Expand Down