Skip to content

Test & fix for NH-3917 #520

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

Merged
merged 1 commit into from
Nov 20, 2016
Merged
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
20 changes: 20 additions & 0 deletions src/NHibernate.Test/DialectTest/SQLiteDialectFixture.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Collections.Generic;
using NHibernate.Dialect.Function;
using NHibernate.Mapping;

namespace NHibernate.Test.DialectTest
Expand All @@ -10,11 +12,13 @@ namespace NHibernate.Test.DialectTest
public class SQLiteDialectFixture
{
private SQLiteDialect dialect;
private SQLFunctionRegistry registry;

[SetUp]
public void SetUp()
{
dialect = new SQLiteDialect();
registry = new SQLFunctionRegistry(dialect, new Dictionary<string, ISQLFunction>());
}

[Test]
Expand All @@ -23,6 +27,22 @@ public void SupportsSubSelect()
Assert.IsTrue(dialect.SupportsSubSelects);
}

[TestCase("int"), TestCase("integer"), TestCase("tinyint"), TestCase("smallint"), TestCase("bigint")]
[TestCase("numeric"), TestCase("decimal"), TestCase("bit"), TestCase("money"), TestCase("smallmoney")]
[TestCase("float"), TestCase("real"), TestCase("date"), TestCase("datetime"), TestCase("smalldatetime")]
[TestCase("char"), TestCase("varchar"), TestCase("text"), TestCase("nvarchar"), TestCase("ntext")]
[TestCase("binary"), TestCase("varbinary"), TestCase("image")]
[TestCase("cursor"), TestCase("timestamp"), TestCase("uniqueidentifier"), TestCase("sql_variant")]
public void WhereStringTemplate(string type)
{
if (!type.EndsWith(")"))
WhereStringTemplate(type + "(1)");

const string value = "1";
string sql = "(CAST(" + value + " AS " + type + "))";
Assert.AreEqual(sql, Template.RenderWhereStringTemplate(sql, dialect, registry));
}

[Test]
public void UseLimit()
{
Expand Down
26 changes: 26 additions & 0 deletions src/NHibernate/Dialect/SQLiteDialect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,32 @@ protected virtual void RegisterFunctions()
protected virtual void RegisterKeywords()
{
RegisterKeyword("int"); // Used in our function templates.
RegisterKeyword("integer"); // a commonly-used alias for 'int'
RegisterKeyword("tinyint");
RegisterKeyword("smallint");
RegisterKeyword("bigint");
RegisterKeyword("numeric");
RegisterKeyword("decimal");
RegisterKeyword("bit");
RegisterKeyword("money");
RegisterKeyword("smallmoney");
RegisterKeyword("float");
RegisterKeyword("real");
RegisterKeyword("datetime");
RegisterKeyword("smalldatetime");
RegisterKeyword("char");
RegisterKeyword("varchar");
RegisterKeyword("text");
RegisterKeyword("nchar");
RegisterKeyword("nvarchar");
RegisterKeyword("ntext");
RegisterKeyword("binary");
RegisterKeyword("varbinary");
RegisterKeyword("image");
RegisterKeyword("cursor");
RegisterKeyword("timestamp");
RegisterKeyword("uniqueidentifier");
RegisterKeyword("sql_variant");
}

protected virtual void RegisterDefaultProperties()
Expand Down