Skip to content

Commit

Permalink
[NOSQL] AWS DynamoDB Support for .NET Generator (#502)
Browse files Browse the repository at this point in the history
* DynamoDB external datastore support library (Issue 69246)

* Add support for reserved keywords. Allow simple queries. Reorganize code

* Support constants in filters

* Fix inserts/updates/deletes

* fix update names

* fix assignments

* empty constants are supported

* add empty value for GX IsEmpty() method

* Add support for retrieving results over secondary indexes

* update nuget packages & fix lint errors

* Add support to .NET 5/6

* Reorganize folder structure and projects to build DynService.Core and DynService.Dynamo to a common package for NET Framework and NET 6

* Remove unneeded net5.0 target framework

* Make this library and the Java one more homogeneous

* Fix lint warnings

* Add special case for queries that filter with an empty string key

* Fix DynamoDB Local connections not using -sharedDb. Region was not taken into account

* Add support for binary streams

* Fix NullReferenceException when trying to get a binary stream from a record which does not have one

* Add support for when duplicate/when none semantics

* Improve Query/Scan inference. Fix lint errors

* Fix datetime fields. Fix update queries

* Fix parsing numeric when field was null

Co-authored-by: Gonzalo <gonzalogallotti@gmail.com>
Co-authored-by: Claudia Murialdo <cmurialdo@genexus.com>
Co-authored-by: claudiamurialdo <33756655+claudiamurialdo@users.noreply.github.com>
  • Loading branch information
4 people authored Sep 2, 2022
1 parent b292a13 commit ec9e523
Show file tree
Hide file tree
Showing 31 changed files with 885 additions and 574 deletions.
18 changes: 7 additions & 11 deletions dotnet/DotNetStandardClasses.sln
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GXGoogleCloud", "src\dotnet
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dynservice", "dynservice", "{A14C2C2C-ACE3-4712-A527-E4E5F02729FA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DynService.Core", "src\dotnetframework\DynService.Core\DynService.Core.csproj", "{B0DEB9ED-9E0A-42E3-BBE1-9F70DD78DC93}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DynService.Core", "src\dotnetcommon\DynService.Core\DynService.Core.csproj", "{B0DEB9ED-9E0A-42E3-BBE1-9F70DD78DC93}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DynService.DynamoDB", "src\dotnetframework\DynService.Dynamo\DynService.DynamoDB.csproj", "{4DC1C813-E7C1-442E-B7D6-C9B932A55759}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DynService.DynamoDB", "src\dotnetcommon\DynService.Dynamo\DynService.DynamoDB.csproj", "{4DC1C813-E7C1-442E-B7D6-C9B932A55759}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DynService.Fabric", "src\dotnetframework\DynServiceFabric\DynService.Fabric.csproj", "{42D048EC-29C5-4553-B301-A6A5A76A7FB8}"
EndProject
Expand Down Expand Up @@ -119,8 +119,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetUnitTest", "test\DotN
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dynservice", "dynservice", "{79C9ECC6-2935-4C43-BF32-94698547F584}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DynService.Core", "src\dotnetcore\DynService\Core\DynService.Core.csproj", "{E2FB8843-503A-4A22-923E-B12510233127}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DynServiceOData", "src\dotnetcore\DynService\OData\DynServiceOData.csproj", "{2238FCB1-3A83-46C2-873E-82DA4266069D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "azurefunctionhandlers", "azurefunctionhandlers", "{BD804A75-9F3F-416C-BF6B-D3DF6C4A8DC0}"
Expand Down Expand Up @@ -186,6 +184,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
..\.editorconfig = ..\.editorconfig
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dynservice", "dynservice", "{C264F34E-2CE0-4DCA-B22D-4155821BE611}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GxXsl", "src\dotnetcore\GxXsl\GxXsl.csproj", "{30E7E437-F9B0-42B8-9144-A8E8F972B462}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GXAzureQueue", "src\dotnetcore\Providers\Messaging\GXAzureQueue\GXAzureQueue.csproj", "{0CED9D4D-EE7C-4E19-9FC6-D4BBCB04DA97}"
Expand Down Expand Up @@ -404,10 +404,6 @@ Global
{251CCD53-21B3-4EBE-8627-49885C4E98B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{251CCD53-21B3-4EBE-8627-49885C4E98B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{251CCD53-21B3-4EBE-8627-49885C4E98B9}.Release|Any CPU.Build.0 = Release|Any CPU
{E2FB8843-503A-4A22-923E-B12510233127}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2FB8843-503A-4A22-923E-B12510233127}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2FB8843-503A-4A22-923E-B12510233127}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2FB8843-503A-4A22-923E-B12510233127}.Release|Any CPU.Build.0 = Release|Any CPU
{2238FCB1-3A83-46C2-873E-82DA4266069D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2238FCB1-3A83-46C2-873E-82DA4266069D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2238FCB1-3A83-46C2-873E-82DA4266069D}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -559,8 +555,8 @@ Global
{F6372249-AF37-4455-B572-5BDF8DE2ACC8} = {F82842DA-F15E-49C5-993E-4C269818FF1F}
{E9072D95-D116-4D4B-B981-46146BCDE052} = {F82842DA-F15E-49C5-993E-4C269818FF1F}
{A14C2C2C-ACE3-4712-A527-E4E5F02729FA} = {F900A4AD-7249-41B4-B918-CB9E8C73747C}
{B0DEB9ED-9E0A-42E3-BBE1-9F70DD78DC93} = {A14C2C2C-ACE3-4712-A527-E4E5F02729FA}
{4DC1C813-E7C1-442E-B7D6-C9B932A55759} = {A14C2C2C-ACE3-4712-A527-E4E5F02729FA}
{B0DEB9ED-9E0A-42E3-BBE1-9F70DD78DC93} = {C264F34E-2CE0-4DCA-B22D-4155821BE611}
{4DC1C813-E7C1-442E-B7D6-C9B932A55759} = {C264F34E-2CE0-4DCA-B22D-4155821BE611}
{42D048EC-29C5-4553-B301-A6A5A76A7FB8} = {A14C2C2C-ACE3-4712-A527-E4E5F02729FA}
{9C521E63-7B6F-4AD3-ACB5-132175D9413A} = {A14C2C2C-ACE3-4712-A527-E4E5F02729FA}
{277490D7-8834-4722-9084-E894F804C66A} = {2261B65E-3757-4E5B-9DCD-EAE8D1E236A3}
Expand All @@ -583,7 +579,6 @@ Global
{55297803-2DE8-48C4-AB65-9D19E77614E1} = {1D6F1776-FF4B-46C2-9B3D-BC46CCF049DC}
{251CCD53-21B3-4EBE-8627-49885C4E98B9} = {1D6F1776-FF4B-46C2-9B3D-BC46CCF049DC}
{79C9ECC6-2935-4C43-BF32-94698547F584} = {2261B65E-3757-4E5B-9DCD-EAE8D1E236A3}
{E2FB8843-503A-4A22-923E-B12510233127} = {79C9ECC6-2935-4C43-BF32-94698547F584}
{2238FCB1-3A83-46C2-873E-82DA4266069D} = {79C9ECC6-2935-4C43-BF32-94698547F584}
{BD804A75-9F3F-416C-BF6B-D3DF6C4A8DC0} = {C6AFB6A3-FF0B-4970-B1F1-10BCD3D932B2}
{41E1D031-799F-484F-85DE-7A30AF1A6FBA} = {BD804A75-9F3F-416C-BF6B-D3DF6C4A8DC0}
Expand Down Expand Up @@ -613,6 +608,7 @@ Global
{911BC7CC-4A07-408F-BA20-8BAB5355BE84} = {C8590651-46B6-4681-A6A0-0850B5A9A697}
{B59F76D8-FDB2-4F51-89DB-F15E9BDFF1DC} = {420E8A4A-11D9-42E9-BFB7-4325EA7330B8}
{D97E17A4-C945-4BF3-957E-F73142C4C6D0} = {947E032A-C385-4586-96E3-FC7D2767F082}
{C264F34E-2CE0-4DCA-B22D-4155821BE611} = {F1E13DF4-9F50-41A2-9DC3-04B673B21032}
{30E7E437-F9B0-42B8-9144-A8E8F972B462} = {2261B65E-3757-4E5B-9DCD-EAE8D1E236A3}
{0CED9D4D-EE7C-4E19-9FC6-D4BBCB04DA97} = {30159B0F-BE61-4DB7-AC02-02851426BE4B}
{30159B0F-BE61-4DB7-AC02-02851426BE4B} = {2261B65E-3757-4E5B-9DCD-EAE8D1E236A3}
Expand Down
21 changes: 21 additions & 0 deletions dotnet/src/dotnetcommon/DynService.Core/DynService.Core.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<RootNamespace>GeneXus.Data.NTier</RootNamespace>
<AssemblyName>GeneXus.Data.DynService.Core</AssemblyName>
<NoWarn>CA1812</NoWarn>
<PackageTags>Dynservice</PackageTags>
<PackageId>GeneXus.DynService.Core</PackageId>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)'!='net462'">
<DefineConstants>NETCORE</DefineConstants>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)'!='net462'">
<ProjectReference Include="..\..\dotnetcore\GxClasses\GxClasses.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net462'">
<ProjectReference Include="..\..\dotnetframework\GxClasses\GxClasses.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,20 @@ namespace GeneXus.Data.NTier
{
public class Query
{
private object mDataStoreHelper;

public string TableName { get; set; } = String.Empty;
public string[] Projection { get; set; } = Array.Empty<string>();
public string[] OrderBys { get; set; } = Array.Empty<string>();
public string[] Filters { get; set; } = Array.Empty<string>();
public string[] AssignAtts { get; set; } = Array.Empty<string>();
public IODataMap2[] SelectList { get; set; } = Array.Empty<IODataMap2>();
public VarValue[] Vars { get; set; } = Array.Empty<VarValue>();
public IEnumerable<string> Projection { get; set; } = Array.Empty<string>();
public IEnumerable<string> OrderBys { get; set; } = Array.Empty<string>();
public IEnumerable<string> Filters { get; set; } = Array.Empty<string>();
private List<KeyValuePair<string, string>> mAssignAtts;
public IEnumerable<KeyValuePair<string, string>> AssignAtts { get { return mAssignAtts ?? Array.Empty<KeyValuePair<string, string>>() as IEnumerable<KeyValuePair<string, string>>; } }
public IEnumerable<IODataMap2> SelectList { get; set; } = Array.Empty<IODataMap2>();

private List<VarValue> mVarValues;
public IEnumerable<VarValue> Vars { get { return (mVarValues ?? Array.Empty<VarValue>() as IEnumerable<VarValue>); } }
public CursorType CursorType { get; set; } = CursorType.Select;

public Query(object dataStoreHelper)
{
mDataStoreHelper = dataStoreHelper;
}
public Query(object dataStoreHelper) { }

public Query For(string v)
{
TableName = v;
Expand All @@ -54,9 +53,10 @@ public Query Filter(string[] filters)
return this;
}

public Query Set(string[] assignAtts)
public Query Set(string name, string value)
{
AssignAtts = assignAtts;
mAssignAtts = mAssignAtts ?? new List<KeyValuePair<string, string>>();
mAssignAtts.Add(new KeyValuePair<string, string>(name, value));
return this;
}

Expand All @@ -66,18 +66,19 @@ public Query SetMaps(IODataMap2[] iODataMap)
return this;
}

public Query SetVars(VarValue[] vars)
{
Vars = vars;
return this;
}

public Query SetType(CursorType cType)
{
CursorType = cType;
return this;
}

public Query AddConst(GXType gxType, object parm)
{
mVarValues = mVarValues ?? new List<VarValue>();
mVarValues.Add(new VarValue($":const{ mVarValues.Count + 1 }", gxType, parm));
return this;
}
}

public class VarValue
Expand All @@ -89,24 +90,18 @@ public class VarValue
public VarValue(string name, GXType type, object value)
{
Name = name;
Type = type;
Value = value;
}

}

public class QueryExpression
{
public string For { get; set; }
internal string[] Select { get; set; }
}



public interface IODataMap2
{
object GetValue(IOServiceContext serviceContext, RecordEntryRow currentEntry);
string GetName(IOServiceContext serviceContext);
void SetValue(IOServiceContext serviceContext, RecordEntryRow currentEntry, object value);
void SetValue(RecordEntryRow currentEntry, object value);
}


Expand All @@ -129,7 +124,7 @@ public virtual object GetValue(IOServiceContext context, RecordEntryRow currentE
throw new NotImplementedException();
}

public virtual void SetValue(IOServiceContext context, RecordEntryRow currentEntry, object value)
public virtual void SetValue(RecordEntryRow currentEntry, object value)
{
throw new NotImplementedException();
}
Expand Down Expand Up @@ -157,7 +152,15 @@ public interface IODataMap
void SetValue(IDictionary<string, object> currentEntry, object value);
}

public abstract class DynServiceDataStoreHelper : DataStoreHelperBase
public abstract class DynServiceDataStoreHelperBase : DataStoreHelperBase
{
public static object InvalidQuery(string msg)
{
throw new ServiceException(msg);
}
}

public abstract class DynServiceDataStoreHelper : DynServiceDataStoreHelperBase
{
public abstract Guid GetParmGuid(IDataParameterCollection parms, string parm);
public abstract string GetParmStr(IDataParameterCollection parms, string parm);
Expand Down
5 changes: 5 additions & 0 deletions dotnet/src/dotnetcommon/DynService.Core/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<RootNamespace>GeneXus.Data.NTier</RootNamespace>
<AssemblyName>GeneXus.Data.DynService.DynamoDB</AssemblyName>
<SignAssembly>false</SignAssembly>
<PackageTags>DynamoDB</PackageTags>
<PackageId>GeneXus.DynService.DynamoDB</PackageId>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)'!='net462'">
<DefineConstants>NETCORE</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.0.103" />
<ProjectReference Include="..\DynService.Core\DynService.Core.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'!='net462'">
<ProjectReference Include="..\..\dotnetcore\GxClasses\GxClasses.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net462'">
<ProjectReference Include="..\..\dotnetframework\GxClasses\GxClasses.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
Loading

0 comments on commit ec9e523

Please sign in to comment.