Skip to content

Commit e50e472

Browse files
committed
Check all nodes
1 parent 68d5e3c commit e50e472

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/NHibernate/Hql/Ast/ANTLR/AstPolymorphicProcessor.cs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Linq;
33
using NHibernate.Engine;
44
using NHibernate.Hql.Ast.ANTLR.Tree;
5+
using NHibernate.Util;
56

67
namespace NHibernate.Hql.Ast.ANTLR
78
{
@@ -30,30 +31,25 @@ private IASTNode[] Process()
3031
_nodeMapping = new PolymorphicQuerySourceDetector(_factory).Process(_ast);
3132

3233
if (_nodeMapping.Count > 0)
33-
{
34-
foreach (var kv in _nodeMapping.Where(x => x.Value.Length == 0))
35-
throw new QuerySyntaxException(kv.Key + " is not mapped");
36-
37-
return DuplicateTree().ToArray();
34+
{
35+
if (_nodeMapping.All(x => x.Value.Length == 0))
36+
throw new QuerySyntaxException(
37+
_nodeMapping.Keys.Count == 1
38+
? _nodeMapping.First().Key + " is not mapped"
39+
: string.Join(", ", _nodeMapping.Keys) + " are not mapped");
40+
41+
return DuplicateTree();
3842
}
3943
else
4044
{
4145
return new[] { _ast };
4246
}
4347
}
4448

45-
private IEnumerable<IASTNode> DuplicateTree()
49+
private IASTNode[] DuplicateTree()
4650
{
4751
var replacements = CrossJoinDictionaryArrays.PerformCrossJoin(_nodeMapping);
48-
49-
var dups = new IASTNode[replacements.Count()];
50-
51-
for (var i = 0; i < replacements.Count(); i++)
52-
{
53-
dups[i] = DuplicateTree(_ast, replacements[i]);
54-
}
55-
56-
return dups;
52+
return replacements.ToArray(x => DuplicateTree(_ast, x));
5753
}
5854

5955
private static IASTNode DuplicateTree(IASTNode ast, IDictionary<IASTNode, IASTNode> nodeMapping)

0 commit comments

Comments
 (0)