|
From: <aye...@us...> - 2010-01-27 15:58:58
|
Revision: 4940
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4940&view=rev
Author: ayenderahien
Date: 2010-01-27 15:58:40 +0000 (Wed, 27 Jan 2010)
Log Message:
-----------
NH-2074 - supporting unicode values in formula fields for SQL 2000 & up
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs
trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs
trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Model.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2010-01-27 15:19:39 UTC (rev 4939)
+++ trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2010-01-27 15:58:40 UTC (rev 4940)
@@ -17,7 +17,7 @@
using NHibernate.SqlTypes;
using NHibernate.Type;
using NHibernate.Util;
-using Environment=NHibernate.Cfg.Environment;
+using Environment = NHibernate.Cfg.Environment;
namespace NHibernate.Dialect
{
@@ -67,8 +67,8 @@
{
standardAggregateFunctions["count"] = new CountQueryFunctionInfo();
standardAggregateFunctions["avg"] = new AvgQueryFunctionInfo();
- standardAggregateFunctions["max"] = new ClassicAggregateFunction("max",false);
- standardAggregateFunctions["min"] = new ClassicAggregateFunction("min",false);
+ standardAggregateFunctions["max"] = new ClassicAggregateFunction("max", false);
+ standardAggregateFunctions["min"] = new ClassicAggregateFunction("min", false);
standardAggregateFunctions["sum"] = new SumQueryFunctionInfo();
Extracter = new NoOpViolatedConstraintNameExtracter();
@@ -151,7 +151,7 @@
{
dialectName = Environment.Properties[Environment.Dialect];
}
- catch(Exception e)
+ catch (Exception e)
{
throw new HibernateException("The dialect was not set. Set the property 'dialect'.", e);
}
@@ -171,7 +171,7 @@
throw new ArgumentNullException("props");
string dialectName;
if (props.TryGetValue(Environment.Dialect, out dialectName) == false)
- throw new InvalidOperationException("Could not find the dialect in the configuration");
+ throw new InvalidOperationException("Could not find the dialect in the configuration");
if (dialectName == null)
{
return GetDialect();
@@ -184,7 +184,7 @@
{
try
{
- return (Dialect) Environment.BytecodeProvider.ObjectsFactory.CreateInstance(ReflectHelper.ClassForName(dialectName));
+ return (Dialect)Environment.BytecodeProvider.ObjectsFactory.CreateInstance(ReflectHelper.ClassForName(dialectName));
}
catch (Exception e)
{
@@ -270,7 +270,7 @@
/// <returns> The appropriate command. </returns>
public virtual string SelectGUIDString
{
- get{throw new NotSupportedException("dialect does not support server side GUIDs generation.");}
+ get { throw new NotSupportedException("dialect does not support server side GUIDs generation."); }
}
/// <summary> Command used to create a table. </summary>
@@ -307,7 +307,7 @@
/// </summary>
public virtual string CreateTemporaryTablePostfix
{
- get{return string.Empty;}
+ get { return string.Empty; }
}
/// <summary>
@@ -397,13 +397,13 @@
get { return String.Empty; }
}
- /// <summary>
- /// The keyword used to create a primary key constraint
- /// </summary>
- public virtual string PrimaryKeyString
- {
- get { return "primary key"; }
- }
+ /// <summary>
+ /// The keyword used to create a primary key constraint
+ /// </summary>
+ public virtual string PrimaryKeyString
+ {
+ get { return "primary key"; }
+ }
#region database type mapping support
@@ -415,7 +415,7 @@
/// <returns>The database type name used by ddl.</returns>
public virtual string GetTypeName(SqlType sqlType)
{
- if (sqlType.LengthDefined || sqlType.PrecisionDefined)
+ if (sqlType.LengthDefined || sqlType.PrecisionDefined)
{
string resultWithLength = typeNames.Get(sqlType.DbType, sqlType.Length, sqlType.Precision, sqlType.Scale);
if (resultWithLength != null) return resultWithLength;
@@ -1473,7 +1473,7 @@
return (name[0] == OpenQuote && name[name.Length - 1] == CloseQuote);
}
- public virtual string Qualify(string catalog, string schema, string table)
+ public virtual string Qualify(string catalog, string schema, string table)
{
StringBuilder qualifiedName = new StringBuilder();
@@ -1533,8 +1533,8 @@
public virtual string QuoteForAliasName(string aliasName)
{
return IsQuoted(aliasName) ?
- aliasName :
- Quote(aliasName);
+ aliasName :
+ Quote(aliasName);
}
/// <summary>
@@ -1554,8 +1554,8 @@
public virtual string QuoteForColumnName(string columnName)
{
return IsQuoted(columnName) ?
- columnName :
- Quote(columnName);
+ columnName :
+ Quote(columnName);
}
/// <summary>
@@ -1574,8 +1574,8 @@
public virtual string QuoteForTableName(string tableName)
{
return IsQuoted(tableName) ?
- tableName :
- Quote(tableName);
+ tableName :
+ Quote(tableName);
}
/// <summary>
@@ -1594,8 +1594,8 @@
public virtual string QuoteForSchemaName(string schemaName)
{
return IsQuoted(schemaName) ?
- schemaName :
- Quote(schemaName);
+ schemaName :
+ Quote(schemaName);
}
/// <summary>
@@ -1963,7 +1963,8 @@
[Serializable]
protected class CountQueryFunctionInfo : ClassicAggregateFunction
{
- public CountQueryFunctionInfo() : base("count",true)
+ public CountQueryFunctionInfo()
+ : base("count", true)
{
}
@@ -1975,7 +1976,8 @@
[Serializable]
protected class AvgQueryFunctionInfo : ClassicAggregateFunction
{
- public AvgQueryFunctionInfo() : base("avg",false)
+ public AvgQueryFunctionInfo()
+ : base("avg", false)
{
}
@@ -2002,11 +2004,12 @@
return NHibernateUtil.Double;
}
}
-
+
[Serializable]
protected class SumQueryFunctionInfo : ClassicAggregateFunction
{
- public SumQueryFunctionInfo() : base("sum",false)
+ public SumQueryFunctionInfo()
+ : base("sum", false)
{
}
@@ -2106,16 +2109,20 @@
}
#endregion
- /// <summary>
- /// Supports splitting batches using GO T-SQL command
- /// </summary>
- /// <remarks>
- /// Batches http://msdn.microsoft.com/en-us/library/ms175502.aspx
- /// </remarks>
- public virtual bool SupportsSqlBatches
- {
- get { return false; }
- }
+ /// <summary>
+ /// Supports splitting batches using GO T-SQL command
+ /// </summary>
+ /// <remarks>
+ /// Batches http://msdn.microsoft.com/en-us/library/ms175502.aspx
+ /// </remarks>
+ public virtual bool SupportsSqlBatches
+ {
+ get { return false; }
+ }
+ public virtual bool IsKnownToken(string currentToken, string nextToken)
+ {
+ return false;
+ }
}
}
Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2010-01-27 15:19:39 UTC (rev 4939)
+++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2010-01-27 15:58:40 UTC (rev 4940)
@@ -10,7 +10,7 @@
using NHibernate.SqlCommand;
using NHibernate.Type;
using NHibernate.Util;
-using Environment=NHibernate.Cfg.Environment;
+using Environment = NHibernate.Cfg.Environment;
namespace NHibernate.Dialect
{
@@ -106,7 +106,7 @@
RegisterFunction("left", new SQLFunctionTemplate(NHibernateUtil.String, "left(?1, ?2)"));
RegisterFunction("right", new SQLFunctionTemplate(NHibernateUtil.String, "right(?1, ?2)"));
- RegisterFunction("locate", new StandardSQLFunction("charindex", NHibernateUtil.Int32));
+ RegisterFunction("locate", new StandardSQLFunction("charindex", NHibernateUtil.Int32));
RegisterFunction("current_timestamp", new NoArgSQLFunction("getdate", NHibernateUtil.DateTime, true));
@@ -128,7 +128,7 @@
RegisterFunction("trim", new AnsiTrimEmulationFunction());
RegisterFunction("iif", new SQLFunctionTemplate(null, "case when ?1 then ?2 else ?3 end"));
- RegisterFunction("replace", new StandardSafeSQLFunction("replace",NHibernateUtil.String, 3));
+ RegisterFunction("replace", new StandardSafeSQLFunction("replace", NHibernateUtil.String, 3));
RegisterKeyword("top");
RegisterKeyword("integer");
@@ -496,12 +496,17 @@
get { return true; }
}
- public override bool SupportsSqlBatches
- {
- get
- {
- return true;
- }
- }
+ public override bool SupportsSqlBatches
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ public override bool IsKnownToken(string currentToken, string nextToken)
+ {
+ return currentToken == "n" && nextToken == "'"; // unicode character
+ }
}
}
Modified: trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs 2010-01-27 15:19:39 UTC (rev 4939)
+++ trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs 2010-01-27 15:58:40 UTC (rev 4940)
@@ -312,6 +312,7 @@
Keywords.Contains(lcToken) ||
functionRegistry.HasFunction(lcToken) ||
dialect.Keywords.Contains(lcToken) ||
+ dialect.IsKnownToken(lcToken, nextToken) ||
FunctionKeywords.Contains(lcToken);
}
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074
___________________________________________________________________
Added: bugtraq:url
+ http://jira.nhibernate.org/browse/%BUGID%
Added: bugtraq:logregex
+ NH-\d+
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Fixture.cs 2010-01-27 15:58:40 UTC (rev 4940)
@@ -0,0 +1,25 @@
+using NHibernate.Dialect;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH2074
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+
+ protected override bool AppliesTo(NHibernate.Dialect.Dialect dialect)
+ {
+ return dialect is MsSql2000Dialect;
+ }
+
+ [Test]
+ public void CanQueryOnPropertyUsingUnicodeToken()
+ {
+ using (var s = OpenSession())
+ {
+ s.CreateQuery("from Person").List();
+ }
+ }
+
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Mappings.hbm.xml 2010-01-27 15:58:40 UTC (rev 4940)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH2074">
+
+ <class name="Person">
+ <id name="Id">
+ <generator class="increment" />
+ </id>
+ <property name="Name"/>
+
+ <property name="CalculatedProperty" formula="(SELECT COUNT(*) FROM Person t WHERE t.Name = N'VALUE')" />
+
+ </class>
+
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Model.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Model.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Model.cs 2010-01-27 15:58:40 UTC (rev 4940)
@@ -0,0 +1,12 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Test.NHSpecificTest.NH2074
+{
+ public class Person
+ {
+ public virtual int Id { get; set; }
+ public virtual string Name { get; set; }
+ public virtual int CalculatedProperty { get; set; }
+ }
+
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-01-27 15:19:39 UTC (rev 4939)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-01-27 15:58:40 UTC (rev 4940)
@@ -700,6 +700,8 @@
<Compile Include="NHSpecificTest\NH2030\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2065\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2065\Model.cs" />
+ <Compile Include="NHSpecificTest\NH2074\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH2074\Model.cs" />
<Compile Include="NHSpecificTest\NH2077\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2077\Model.cs" />
<Compile Include="NHSpecificTest\NH473\Child.cs" />
@@ -2119,6 +2121,7 @@
<EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" />
<EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH2074\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2077\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2020\Mappings.hbm.xml" />
<EmbeddedResource Include="GhostProperty\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|