Skip to content

Commit 84c8bd5

Browse files
committed
Fix Placeholder translation for Postgre
1 parent 72dbe2b commit 84c8bd5

File tree

1 file changed

+22
-2
lines changed
  • Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v8_0

1 file changed

+22
-2
lines changed

Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v8_0/Compiler.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ namespace Xtensive.Sql.Drivers.PostgreSql.v8_0
1313
{
1414
internal class Compiler : SqlCompiler
1515
{
16+
private readonly static Type SqlPlaceholderType = typeof(SqlPlaceholder);
17+
1618
private static readonly SqlNative OneYearInterval = SqlDml.Native("interval '1 year'");
1719
private static readonly SqlNative OneMonthInterval = SqlDml.Native("interval '1 month'");
1820
private static readonly SqlNative OneDayInterval = SqlDml.Native("interval '1 day'");
@@ -32,8 +34,26 @@ public override void Visit(SqlBinary node)
3234
{
3335
var right = node.Right as SqlArray;
3436
if (!right.IsNullReference() && (node.NodeType==SqlNodeType.In || node.NodeType==SqlNodeType.NotIn)) {
35-
var row = SqlDml.Row(right.GetValues().Select(value => SqlDml.Literal(value)).ToArray());
36-
base.Visit(node.NodeType==SqlNodeType.In ? SqlDml.In(node.Left, row) : SqlDml.NotIn(node.Left, row));
37+
if (right.ItemType == SqlPlaceholderType) {
38+
using (context.EnterScope(node)) {
39+
context.Output.AppendText(translator.Translate(context, node, NodeSection.Entry));
40+
node.Left.AcceptVisitor(this);
41+
context.Output.AppendText(translator.Translate(node.NodeType));
42+
context.Output.AppendText("(");
43+
var items = right.GetValues();
44+
for (var i = 0; i < items.Length - 1; i++) {
45+
Visit((SqlPlaceholder) items[i]);
46+
context.Output.AppendDelimiter(translator.RowItemDelimiter);
47+
}
48+
Visit((SqlPlaceholder) items[items.Length - 1]);
49+
context.Output.AppendText(")");
50+
context.Output.AppendText(translator.Translate(context, node, NodeSection.Exit));
51+
}
52+
}
53+
else {
54+
var row = SqlDml.Row(right.GetValues().Select(value => SqlDml.Literal(value)).ToArray());
55+
base.Visit(node.NodeType == SqlNodeType.In ? SqlDml.In(node.Left, row) : SqlDml.NotIn(node.Left, row));
56+
}
3757
}
3858
else {
3959
switch (node.NodeType) {

0 commit comments

Comments
 (0)