Skip to content

Commit

Permalink
Merge pull request #42 from mateusvicente100/master
Browse files Browse the repository at this point in the history
Issue #41 Padrão lowerCamelCase no nome do DataSet
  • Loading branch information
viniciussanchez committed May 6, 2020
2 parents b94cc8e + e58b748 commit 16a1035
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/DataSet.Serialize.Export.pas
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function TDataSetSerialize.DataSetToJSONObject(const ADataSet: TDataSet): TJSONO
if FOnlyUpdatedRecords then
TFDDataSet(LNestedDataSet).FilterChanges := [rtInserted, rtModified, rtDeleted, rtUnmodified];
if LNestedDataSet.RecordCount > 0 then
Result.AddPair(LowerCase(TDataSetSerializeUtils.FormatDataSetName(LNestedDataSet.Name)), DataSetToJSONArray(LNestedDataSet, True));
Result.AddPair(TDataSetSerializeUtils.FormatDataSetName(LNestedDataSet.Name), DataSetToJSONArray(LNestedDataSet, True));
if FOnlyUpdatedRecords then
TFDDataSet(LNestedDataSet).FilterChanges := [rtInserted, rtModified, rtUnmodified];
end;
Expand Down
2 changes: 1 addition & 1 deletion src/core/DataSet.Serialize.Import.pas
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ procedure TJSONSerialize.JSONObjectToDataSet(const AJSONObject: TJSONObject; con
ADataSet.GetDetailDataSets(LDataSetDetails);
for LNestedDataSet in LDataSetDetails do
begin
if not AJSONObject.TryGetValue(LowerCase(TDataSetSerializeUtils.FormatDataSetName(LNestedDataSet.Name)), LJSONValue) then
if not AJSONObject.TryGetValue(TDataSetSerializeUtils.FormatDataSetName(LNestedDataSet.Name), LJSONValue) then
Continue;
if LJSONValue is TJSONNull then
Continue;
Expand Down
8 changes: 7 additions & 1 deletion src/providers/DataSet.Serialize.Utils.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

interface

uses System.DateUtils, System.JSON, Data.DB, DataSet.Serialize.BooleanField, System.SysUtils, System.Classes;
uses System.DateUtils, System.JSON, Data.DB, DataSet.Serialize.BooleanField, System.SysUtils, System.Classes, System.Character;

type
/// <summary>
Expand Down Expand Up @@ -161,6 +161,8 @@ class function TDataSetSerializeUtils.FieldNameToLowerCamelCase(const AFieldName
end;

class function TDataSetSerializeUtils.FormatDataSetName(const ADataSetName: string): string;
const
FIRST_CHAR = 1;
var
LPrefix: string;
begin
Expand All @@ -171,6 +173,10 @@ class function TDataSetSerializeUtils.FormatDataSetName(const ADataSetName: stri
Result := Copy(ADataSetName, Succ(LPrefix.Length), ADataSetName.Length - LPrefix.Length);
Break;
end;
if not TDataSetSerializeConfig.GetInstance.LowerCamelCase then
Result := Result.ToLower
else
Result[FIRST_CHAR] := Result[FIRST_CHAR].ToLower;
end;

class function TDataSetSerializeUtils.NewDataSetField(const ADataSet: TDataSet; const AFieldStructure: TFieldStructure): TField;
Expand Down

0 comments on commit 16a1035

Please sign in to comment.