Skip to content

Commit

Permalink
Merge pull request #17 from alexwiese/prerelease/1.0.11
Browse files Browse the repository at this point in the history
1.0.11: Map missing types clob, blob, double, recid, don't insert rowid.
  • Loading branch information
alexwiese committed Nov 17, 2020
2 parents aa7f467 + bcfdd77 commit e4f8207
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/EFCore.OpenEdge/EFCore.OpenEdge.csproj
Expand Up @@ -21,9 +21,10 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.0.8</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>
<Version>1.0.11</Version>
<PackageReleaseNotes>Map missing types clob, blob, double, recid, don't insert rowid.</PackageReleaseNotes>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup>
Expand Down
Expand Up @@ -61,12 +61,14 @@ public OpenEdgeTypeMappingSource(TypeMappingSourceDependencies dependencies, Rel
{ "binary varying", _binary },
{ "raw", _binary },
{ "binary", _binary },
{ "blob", _binary },
{ "bit", _boolean},
{ "logical", _boolean},
{ "char varying", _char },
{ "char", _char },
{ "character varying", _char },
{ "character", _char },
{ "clob", _char },
{ "date", _date },
{ "datetime", _datetime },
{ "datetime2", _datetime },
Expand All @@ -75,13 +77,15 @@ public OpenEdgeTypeMappingSource(TypeMappingSourceDependencies dependencies, Rel
{ "dec", _decimal },
{ "decimal", _decimal },
{ "double precision", _double },
{ "double", _double },
{ "float", _double },
{ "image", _binary },
{ "int", _integer },
{ "integer", _integer },
{ "money", _decimal },
{ "numeric", _decimal },
{ "real", _float },
{ "recid", _char },
{ "smalldatetime", _datetime },
{ "smallint", _smallint},
{ "short", _smallint},
Expand Down
35 changes: 28 additions & 7 deletions src/EFCore.OpenEdge/Update/OpenEdgeUpdateSqlGenerator.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -27,23 +28,41 @@ protected override void AppendIdentityWhereCondition(StringBuilder commandString
commandStringBuilder
.Append("1 = 1");
}


protected override void AppendValues(StringBuilder commandStringBuilder, IReadOnlyList<ColumnModification> operations)
{
bool useLiterals = true;

if (operations.Count > 0)
{
commandStringBuilder
.Append("(")
.AppendJoin(
operations,
SqlGenerationHelper,
// Use '?' rather than named parameters
(sb, o, helper) => { sb.Append(o.IsWrite ? "?" : "DEFAULT"); })

(sb, o, helper) =>
{
if (useLiterals)
{
AppendSqlLiteral(sb, o.Value, o.Property);
}
else
{
// Use '?' rather than named parameters
AppendParameter(sb, o);
}
})
.Append(")");
}
}

private void AppendParameter(StringBuilder commandStringBuilder, ColumnModification modification)
{
commandStringBuilder.Append(modification.IsWrite ? "?" : "DEFAULT");
}

private void AppendSqlLiteral(StringBuilder commandStringBuilder, object value, IProperty property)
{
var mapping = property != null
Expand Down Expand Up @@ -114,10 +133,12 @@ private void AppendSqlLiteral(StringBuilder commandStringBuilder, object value,
var schema = command.Schema;
var operations = command.ColumnModifications;

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

var writeOperations = operations.Where(o => o.IsWrite)
.Where(o => o.ColumnName != "rowid")
.ToList();

AppendInsertCommand(commandStringBuilder, name, schema, writeOperations);

return ResultSetMapping.NoResultSet;
}

Expand All @@ -132,7 +153,7 @@ private void AppendSqlLiteral(StringBuilder commandStringBuilder, object value,
var conditionOperations = operations.Where(o => o.IsCondition).ToList();

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

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

0 comments on commit e4f8207

Please sign in to comment.