Skip to content

Commit 1df41e8

Browse files
authored
Fix JetCommand regarding CREATE PROCEDURE statements and command splitting. (#87)
1 parent 54b4af5 commit 1df41e8

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

src/EFCore.Jet.Data/JetCommand.cs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -363,23 +363,30 @@ protected virtual IReadOnlyList<JetCommand> SplitCommands()
363363
var command = (JetCommand) ((ICloneable) this).Clone();
364364
command.CommandText = commandText;
365365

366-
for (var i = 0; i < usedParameterCount; i++)
366+
if (_createProcedureExpression.IsMatch(command.CommandText))
367367
{
368-
command.Parameters.RemoveAt(0);
368+
command.Parameters.Clear();
369369
}
370-
371-
var parameterIndices = parser.GetStateIndices(
372-
new[] {'@', '?'},
373-
currentCommandStart,
374-
commandDelimiter - currentCommandStart);
375-
376-
while (command.Parameters.Count > parameterIndices.Count)
370+
else
377371
{
378-
command.Parameters.RemoveAt(parameterIndices.Count);
372+
for (var i = 0; i < usedParameterCount && command.Parameters.Count > 0; i++)
373+
{
374+
command.Parameters.RemoveAt(0);
375+
}
376+
377+
var parameterIndices = parser.GetStateIndices(
378+
new[] {'@', '?'},
379+
currentCommandStart,
380+
commandDelimiter - currentCommandStart);
381+
382+
while (command.Parameters.Count > parameterIndices.Count)
383+
{
384+
command.Parameters.RemoveAt(parameterIndices.Count);
385+
}
386+
387+
usedParameterCount += parameterIndices.Count;
379388
}
380389

381-
usedParameterCount += parameterIndices.Count;
382-
383390
commands.Add(command);
384391
}
385392

0 commit comments

Comments
 (0)