Skip to content

Commit 4e07595

Browse files
authored
Merge pull request #587 from hazzik/NH-3973
NH-3973 - Remove enabledFilter parameter from IProjection.ToSqlString and ICriterion.ToSqlString methods
2 parents 6370f3d + 2a58e6e commit 4e07595

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+299
-236
lines changed

src/NHibernate.Test/Criteria/AddNumberProjection.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Linq;
43
using NHibernate.Engine;
54
using NHibernate.Criterion;
@@ -26,7 +25,7 @@ public override bool IsAggregate
2625
get { return false; }
2726
}
2827

29-
public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
28+
public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery)
3029
{
3130
string[] projection = criteriaQuery.GetColumnsUsingProjection(criteria, propertyName);
3231

@@ -56,7 +55,7 @@ public override bool IsGrouped
5655
get { return false; }
5756
}
5857

59-
public override SqlString ToGroupSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
58+
public override SqlString ToGroupSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery)
6059
{
6160
throw new InvalidOperationException("not a grouping projection");
6261
}

src/NHibernate.Test/ExpressionTest/BetweenExpressionFixture.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using NHibernate.DomainModel;
22
using NHibernate.Criterion;
33
using NHibernate.SqlCommand;
4-
using NHibernate.Util;
54
using NUnit.Framework;
65

76
namespace NHibernate.Test.ExpressionTest
@@ -16,7 +15,7 @@ public void BetweenSqlStringTest()
1615

1716
CreateObjects(typeof(Simple), session);
1817
ICriterion betweenExpression = Expression.Between("Count", 5, 10);
19-
SqlString sqlString = betweenExpression.ToSqlString(criteria, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
18+
SqlString sqlString = betweenExpression.ToSqlString(criteria, criteriaQuery);
2019

2120
string expectedSql = "sql_alias.count_ between ? and ?";
2221
CompareSqlStrings(sqlString, expectedSql, 2);

src/NHibernate.Test/ExpressionTest/InExpressionFixture.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using NHibernate.DomainModel;
33
using NHibernate.Criterion;
44
using NHibernate.SqlCommand;
5-
using NHibernate.Util;
65
using NUnit.Framework;
76
using System.Linq;
87

@@ -22,7 +21,7 @@ public void InSqlStringTest()
2221
ICriterion inExpression = Expression.In("Count", new int[] { 3, 4, 5 });
2322

2423
CreateObjects(typeof(Simple), session);
25-
SqlString sqlString = inExpression.ToSqlString(criteria, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
24+
SqlString sqlString = inExpression.ToSqlString(criteria, criteriaQuery);
2625

2726
string expectedSql = "sql_alias.count_ in (?, ?, ?)";
2827

@@ -37,7 +36,7 @@ public void InEmptyList()
3736
ISession session = factory.OpenSession();
3837
InExpression expression = new InExpression("Count", new object[0]);
3938
CreateObjects(typeof(Simple), session);
40-
SqlString sql = expression.ToSqlString(criteria, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
39+
SqlString sql = expression.ToSqlString(criteria, criteriaQuery);
4140
Assert.AreEqual("1=0", sql.ToString());
4241
session.Close();
4342
}
@@ -56,7 +55,7 @@ public void InSqlFunctionTest()
5655
Projections.Constant(1),
5756
Projections.Constant(1)),
5857
new object[] { "A", "B" });
59-
var sql = inExpression.ToSqlString(criteria, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
58+
var sql = inExpression.ToSqlString(criteria, criteriaQuery);
6059

6160
// Allow some dialectal differences in function name and parameter style.
6261
Assert.That(sql.ToString(),

src/NHibernate.Test/ExpressionTest/InsensitiveLikeExpressionFixture.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using NHibernate.Engine;
55
using NHibernate.Criterion;
66
using NHibernate.SqlCommand;
7-
using NHibernate.Util;
87
using NUnit.Framework;
98

109
namespace NHibernate.Test.ExpressionTest
@@ -23,7 +22,7 @@ public void InsentitiveLikeSqlStringTest()
2322
ICriterion expression = Expression.InsensitiveLike("Address", "12 Adress");
2423

2524
CreateObjects(typeof(Simple), session);
26-
SqlString sqlString = expression.ToSqlString(criteria, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
25+
SqlString sqlString = expression.ToSqlString(criteria, criteriaQuery);
2726

2827
string expectedSql = "lower(sql_alias.address) like ?";
2928
if ((factory as ISessionFactoryImplementor).Dialect is PostgreSQLDialect)

src/NHibernate.Test/ExpressionTest/JunctionFixture.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using NHibernate.Engine;
33
using NHibernate.Criterion;
44
using NHibernate.SqlCommand;
5-
using NHibernate.Util;
65
using NUnit.Framework;
76

87
namespace NHibernate.Test.ExpressionTest
@@ -35,7 +34,7 @@ public void SqlString()
3534
using (ISession session = factory.OpenSession())
3635
{
3736
CreateObjects(typeof(Simple), session);
38-
sqlString = _conjunction.ToSqlString(criteria, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
37+
sqlString = _conjunction.ToSqlString(criteria, criteriaQuery);
3938
}
4039

4140
string expectedSql = "(sql_alias.address is null and sql_alias.count_ between ? and ?)";

src/NHibernate.Test/ExpressionTest/LogicalExpressionFixture.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using NHibernate.DomainModel;
33
using NHibernate.Criterion;
44
using NHibernate.SqlCommand;
5-
using NHibernate.Util;
65
using NUnit.Framework;
76

87
namespace NHibernate.Test.ExpressionTest
@@ -26,7 +25,7 @@ public void LogicalSqlStringTest()
2625
Expression.Or(Expression.IsNull("Address"), Expression.Between("Count", 5, 10));
2726

2827
CreateObjects(typeof(Simple), session);
29-
SqlString sqlString = orExpression.ToSqlString(criteria, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
28+
SqlString sqlString = orExpression.ToSqlString(criteria, criteriaQuery);
3029

3130
string expectedSql = "(sql_alias.address is null or sql_alias.count_ between ? and ?)";
3231

src/NHibernate.Test/ExpressionTest/NotExpressionFixture.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using NHibernate.DomainModel;
33
using NHibernate.Criterion;
44
using NHibernate.SqlCommand;
5-
using NHibernate.Util;
65
using NUnit.Framework;
76

87
namespace NHibernate.Test.ExpressionTest
@@ -21,7 +20,7 @@ public void NotSqlStringTest()
2120
ICriterion notExpression = Expression.Not(Expression.Eq("Address", "12 Adress"));
2221

2322
CreateObjects(typeof(Simple), session);
24-
SqlString sqlString = notExpression.ToSqlString(criteria, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
23+
SqlString sqlString = notExpression.ToSqlString(criteria, criteriaQuery);
2524

2625
string expectedSql = "not (sql_alias.address = ?)";
2726
CompareSqlStrings(sqlString, expectedSql, 1);

src/NHibernate.Test/ExpressionTest/NotNullExpressionFixture.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using NHibernate.DomainModel;
22
using NHibernate.Criterion;
33
using NHibernate.SqlCommand;
4-
using NHibernate.Util;
54
using NUnit.Framework;
65

76
namespace NHibernate.Test.ExpressionTest
@@ -20,7 +19,7 @@ public void NotNullSqlStringTest()
2019
ICriterion notNullExpression = Expression.IsNotNull("Address");
2120

2221
CreateObjects(typeof(Simple), session);
23-
SqlString sqlString = notNullExpression.ToSqlString(criteria, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
22+
SqlString sqlString = notNullExpression.ToSqlString(criteria, criteriaQuery);
2423

2524
string expectedSql = "sql_alias.address is not null";
2625
CompareSqlStrings(sqlString, expectedSql, 0);

src/NHibernate.Test/ExpressionTest/NullExpressionFixture.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using NHibernate.DomainModel;
33
using NHibernate.Criterion;
44
using NHibernate.SqlCommand;
5-
using NHibernate.Util;
65
using NUnit.Framework;
76

87
namespace NHibernate.Test.ExpressionTest
@@ -21,7 +20,7 @@ public void NullSqlStringTest()
2120
ICriterion expression = Expression.IsNull("Address");
2221

2322
CreateObjects(typeof(Simple), session);
24-
SqlString sqlString = expression.ToSqlString(criteria, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
23+
SqlString sqlString = expression.ToSqlString(criteria, criteriaQuery);
2524

2625
string expectedSql = "sql_alias.address is null";
2726
CompareSqlStrings(sqlString, expectedSql, 0);

src/NHibernate.Test/ExpressionTest/Projection/ProjectionFixture.cs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
namespace NHibernate.Test.ExpressionTest.Projection
99
{
10-
using Util;
11-
using NHibernate.Dialect.Function;
10+
using NHibernate.Dialect.Function;
1211

1312
[TestFixture]
1413
public class ProjectionFixture : BaseExpressionFixture
@@ -19,7 +18,7 @@ public void RowCountTest()
1918
ISession session = factory.OpenSession();
2019
IProjection expression = Projections.RowCount();
2120
CreateObjects(typeof(Simple), session);
22-
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery, new CollectionHelper.EmptyMapClass<string,IFilter>());
21+
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery);
2322
string expectedSql = "count(*) as y0_";
2423
CompareSqlStrings(sqlString, expectedSql, 0);
2524
session.Close();
@@ -34,7 +33,7 @@ public void AvgTest()
3433
IType nhType = NHibernateUtil.GuessType(typeof (double));
3534
SqlType[] sqlTypes = nhType.SqlTypes(this.factoryImpl);
3635
string sqlTypeString = factoryImpl.Dialect.GetCastTypeName(sqlTypes[0]);
37-
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
36+
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery);
3837
string expectedSql = string.Format("avg(cast(sql_alias.Pay as {0})) as y0_",sqlTypeString);
3938
CompareSqlStrings(sqlString, expectedSql, 0);
4039
session.Close();
@@ -46,7 +45,7 @@ public void MaxTest()
4645
ISession session = factory.OpenSession();
4746
IProjection expression = Projections.Max("Pay");
4847
CreateObjects(typeof(Simple), session);
49-
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
48+
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery);
5049
string expectedSql = "max(sql_alias.Pay) as y0_";
5150
CompareSqlStrings(sqlString, expectedSql, 0);
5251
session.Close();
@@ -58,7 +57,7 @@ public void MinTest()
5857
ISession session = factory.OpenSession();
5958
IProjection expression = Projections.Min("Pay");
6059
CreateObjects(typeof(Simple), session);
61-
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
60+
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery);
6261
string expectedSql = "min(sql_alias.Pay) as y0_";
6362
CompareSqlStrings(sqlString, expectedSql, 0);
6463
session.Close();
@@ -70,7 +69,7 @@ public void CountTest()
7069
ISession session = factory.OpenSession();
7170
IProjection expression = Projections.Count("Pay");
7271
CreateObjects(typeof(Simple), session);
73-
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
72+
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery);
7473
string expectedSql = "count(sql_alias.Pay) as y0_";
7574
CompareSqlStrings(sqlString, expectedSql, 0);
7675
session.Close();
@@ -82,7 +81,7 @@ public void CountDistinctTest()
8281
ISession session = factory.OpenSession();
8382
IProjection expression = Projections.CountDistinct("Pay");
8483
CreateObjects(typeof(Simple), session);
85-
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
84+
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery);
8685
string expectedSql = "count(distinct sql_alias.Pay) as y0_";
8786
CompareSqlStrings(sqlString, expectedSql, 0);
8887
session.Close();
@@ -95,7 +94,7 @@ public void NvlTest()
9594
IProjection expression = Projections.SqlFunction(new NvlFunction(),
9695
NHibernateUtil.String, Projections.Property("Name"), Projections.Property("Address"));
9796
CreateObjects(typeof (Simple), session);
98-
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
97+
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery);
9998
string expectedSql = "nvl(sql_alias.Name, sql_alias.address) as y0_";
10099
CompareSqlStrings(sqlString, expectedSql, 0);
101100
session.Close();
@@ -107,7 +106,7 @@ public void DistinctTest()
107106
ISession session = factory.OpenSession();
108107
IProjection expression = Projections.Distinct(Projections.Property("Pay"));
109108
CreateObjects(typeof(Simple), session);
110-
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
109+
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery);
111110
string expectedSql = "distinct sql_alias.Pay as y0_";
112111
CompareSqlStrings(sqlString, expectedSql, 0);
113112
session.Close();
@@ -119,10 +118,10 @@ public void GroupPropertyTest()
119118
ISession session = factory.OpenSession();
120119
IProjection expression = Projections.GroupProperty("Pay");
121120
CreateObjects(typeof(Simple), session);
122-
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
121+
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery);
123122
string expectedSql = "sql_alias.Pay as y0_";
124123
CompareSqlStrings(sqlString, expectedSql, 0);
125-
SqlString groupSql = expression.ToGroupSqlString(criteria, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
124+
SqlString groupSql = expression.ToGroupSqlString(criteria, criteriaQuery);
126125
string expectedGroupSql = "sql_alias.Pay";
127126
CompareSqlStrings(groupSql, expectedGroupSql);
128127
session.Close();
@@ -134,7 +133,7 @@ public void IdTest()
134133
ISession session = factory.OpenSession();
135134
IProjection expression = Projections.Id();
136135
CreateObjects(typeof(Simple), session);
137-
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
136+
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery);
138137
string expectedSql = "sql_alias.id_ as y0_";
139138
CompareSqlStrings(sqlString, expectedSql, 0);
140139
session.Close();
@@ -146,7 +145,7 @@ public void PropertyTest()
146145
ISession session = factory.OpenSession();
147146
IProjection expression = Projections.Property("Pay");
148147
CreateObjects(typeof(Simple), session);
149-
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
148+
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery);
150149
string expectedSql = "sql_alias.Pay as y0_";
151150
CompareSqlStrings(sqlString, expectedSql, 0);
152151
session.Close();
@@ -161,7 +160,7 @@ public void SqlGroupProjectionTest()
161160
new IType[] {NHibernateUtil.Double}
162161
);
163162
CreateObjects(typeof(Simple), session);
164-
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
163+
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery);
165164
string expectedSql = "count(Pay)";
166165
CompareSqlStrings(sqlString, expectedSql, 0);
167166
session.Close();
@@ -175,7 +174,7 @@ public void SqlProjectionTest()
175174
new string[] {"CountOfPay"}, new
176175
IType[] {NHibernateUtil.Double});
177176
CreateObjects(typeof(Simple), session);
178-
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
177+
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery);
179178
string expectedSql = "count(Pay)";
180179
CompareSqlStrings(sqlString, expectedSql, 0);
181180
session.Close();
@@ -187,7 +186,7 @@ public void SumTest()
187186
ISession session = factory.OpenSession();
188187
IProjection expression = Projections.Sum("Pay");
189188
CreateObjects(typeof(Simple), session);
190-
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
189+
SqlString sqlString = expression.ToSqlString(criteria, 0, criteriaQuery);
191190
string expectedSql = "sum(sql_alias.Pay) as y0_";
192191
CompareSqlStrings(sqlString, expectedSql, 0);
193192
session.Close();

0 commit comments

Comments
 (0)