Single Item last field gets duplicated on Replace (When upsert: true and field names in Datastore are in camel case)
See original GitHub issueBug:
- When replacing a field value on single item mode, the last field that gets updated duplicates itself in the DataStore file.
Replication:
public static class Program
{
public static void Main(string[] args)
{
var entity = new Entity();
for (int i = 1; i <= 2; i++)
{
// First to Update
entity.DoesNotDuplicate = $"Updated {i} Times, Doesn't Duplicate";
// Last to Update
entity.Duplicates = $"Updated {i} Times, Duplicates";
Thread.Sleep(500);
}
}
internal class Entity
{
private static readonly DataStore _dataStore = new DataStore("DuplicateBug.json");
internal string? DoesNotDuplicate
{
get => _dataStore.GetItem(nameof(DoesNotDuplicate));
set => _dataStore.ReplaceItem(nameof(DoesNotDuplicate), value, true);
}
internal string? Duplicates
{
get => _dataStore.GetItem(nameof(Duplicates));
set => _dataStore.ReplaceItem(nameof(Duplicates), value, true);
}
}
}
Output:
{
"doesNotDuplicate": "Updated 2 Times, Doesn't Duplicate",
"duplicates": "Updated 1 Times, Duplicates",
"duplicates": "Updated 2 Times, Duplicates"
}
Observation:
- the doesNotDuplicate field is updated correctly, does not duplicate itself since it is the first field updated.
- the duplicates field is not updated correctly, and duplicates itself instead.
Issue Analytics
- State:
- Created 4 months ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Issues · ttu/json-flatfile-datastore
Single Item last field gets duplicated on Replace (When upsert: true and field names in Datastore are in camel case) bug in progress....
Read more >Why does upsert cause a DUPLICATE_VALUE error?
I have a custom object, with a Text Name (ID) field. When I upsert two records with identical Name/ID, but otherwise different values,...
Read more >MongoDB inserting duplicate document within upsert
I was checking existing data within the DB and found several documents in which the fields that should be used to match in...
Read more >arcgis.features module | ArcGIS API for Python
Used only when upsert is true. Used to skip inserts if the value is true. The default value is false. upsert_matching_field. Optional string....
Read more >Strange Error: "A duplicate value was specified for field"
If you r trying to deploy metadata(Object information) from one Org to another, and the fields name are same you get this error....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Fix released: https://www.nuget.org/packages/JsonFlatFileDataStore/2.4.2
Fixed in: #89
Fix will be in the next patch release.