viniciussanchez / dataset-serialize

JSON to DataSet and DataSet to JSON converter for Delphi and Lazarus (FPC)
MIT License
653 stars 161 forks source link

any reason for enforcing 0 field count before importing from JSON to DataSet? #143

Closed georges-hatem closed 2 years ago

georges-hatem commented 2 years ago

i have a complex filter that cannot be achieved via standard SQLite or Filter event. For that, a separate Boolean FieldDef is added prior to loading from JSON.

However when doing so (and in accordance to the docs), the JSON fields are not created. commenting out the line below, works.

//    if ((ADataSet.FieldDefs.Count = 0) and (ADataSet.FieldCount = 0)) then
      LoadFieldsFromJSON(ADataSet, AJSONObject);

Could this be, maybe an option in the config, e.g. AllowExistingFields, defaulted to False to protect unknowing users, and yet allow those who want to proceed anyway, to do so?

viniciussanchez commented 2 years ago

Yes, if you don't have fields created, it creates based on JSON