Skip to content

Commit

Permalink
Merge pull request #5 from alexwiese/bugfix/valuegenerated
Browse files Browse the repository at this point in the history
Fix bug that could occur when a computed/database generated value was…
  • Loading branch information
alexwiese committed Dec 17, 2018
2 parents b17f2aa + 9e08262 commit b6d6ce3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/EFCore.OpenEdge/EFCore.OpenEdge.csproj
Expand Up @@ -21,7 +21,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.0.5-beta2</Version>
<Version>1.0.6</Version>
<PackageReleaseNotes>Fix issues where query was being cached, moved modifications up to the model generator so that the actual query would differ and not be cached.</PackageReleaseNotes>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</PropertyGroup>
Expand Down
36 changes: 36 additions & 0 deletions src/EFCore.OpenEdge/Update/OpenEdgeUpdateSqlGenerator.cs
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using EntityFrameworkCore.OpenEdge.Extensions;
using Microsoft.EntityFrameworkCore.Metadata;
Expand All @@ -16,10 +18,14 @@ public OpenEdgeUpdateSqlGenerator(UpdateSqlGeneratorDependencies dependencies) :

protected override void AppendRowsAffectedWhereCondition(StringBuilder commandStringBuilder, int expectedRowsAffected)
{
commandStringBuilder
.Append("1 = 1");
}

protected override void AppendIdentityWhereCondition(StringBuilder commandStringBuilder, ColumnModification columnModification)
{
commandStringBuilder
.Append("1 = 1");
}


Expand Down Expand Up @@ -99,5 +105,35 @@ private void AppendSqlLiteral(StringBuilder commandStringBuilder, object value,
}
}
}

public override ResultSetMapping AppendInsertOperation(StringBuilder commandStringBuilder, ModificationCommand command,
int commandPosition)
{

var name = command.TableName;
var schema = command.Schema;
var operations = command.ColumnModifications;

var writeOperations = operations.Where(o => o.IsWrite).ToList();

AppendInsertCommand(commandStringBuilder, name, schema, writeOperations);

return ResultSetMapping.NoResultSet;
}

public override ResultSetMapping AppendUpdateOperation(StringBuilder commandStringBuilder, ModificationCommand command,
int commandPosition)
{
var name = command.TableName;
var schema = command.Schema;
var operations = command.ColumnModifications;

var writeOperations = operations.Where(o => o.IsWrite).ToList();
var conditionOperations = operations.Where(o => o.IsCondition).ToList();

AppendUpdateCommand(commandStringBuilder, name, schema, writeOperations, conditionOperations);

return AppendSelectAffectedCountCommand(commandStringBuilder, name, schema, commandPosition);
}
}
}

0 comments on commit b6d6ce3

Please sign in to comment.