Coder Social home page Coder Social logo

anavarro9731 / datastore Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 4.0 2.65 MB

A Document-Centric Data Access Framework for DocumentDb

License: Other

C# 99.71% PowerShell 0.29%
cosmosdb cosmos-db documentdb azure-documentdb azure-cosmos-db document-database ormlite

datastore's People

Contributors

anavarro9731 avatar lpedrosorodriguez avatar

Stargazers

 avatar

Watchers

 avatar  avatar

datastore's Issues

Created and CreatedAsMillisecondsEpocTime not set on Create<T>()

When new Aggregates are created using DataStoreCreateCapabilities.Create<T>(), the Created, CreatedAsMillisecondsEpochTime, Modified and ModifiedAsMillisecondsEpochTime properties are set to DateTime.MinValue.

The issue here appears within WalkGraphAndUpdateEntityMeta(), it's checking to see if the properties are null & setting them to DateTime.UtcNow if they are null but since these properties are now non-nullable, they are being left at default (DateTime.MinValue):

else if (p.Name == nameof(IEntity.Created))
{
    //set created datetime if this is null
    if ((DateTime?)p.GetValue(current, null) == null)
    {
        p.SetValue(current, DateTime.UtcNow, null);
    }
}
else if (p.Name == nameof(IEntity.CreatedAsMillisecondsEpochTime))
{
    //set created datetime if this is null
    if (p.GetValue(current, null) == null)
    {
        p.SetValue(current, DateTime.UtcNow.ConvertToSecondsEpochTime(), null);
    }
}

Error Message for Restricted Properties does not include newly restricted properties "Modified" & "ModifiedAsMillisecondsEpochTime"

"Cannot change restricted properties [id, schema, Created, CreatedAsMillisecondsEpochTime on entity " + originalId);

The error message thrown for when restricted properties are modified does not include the newly restricted properties "Modified" & "ModifiedAsMillisecondsEpochTime". It currently reads:

"Cannot change restricted properties [id, schema, Created, CreatedAsMillisecondsEpochTime on entity "

But should be updated to be:

"Cannot change restricted properties [id, schema, Created, CreatedAsMillisecondsEpochTime, Modified, ModifiedAsMillisecondsEpochTime] on entity "

Read/ReadActive not applying predicate on replayed results

DataStoreQueryCapabilities.Read and DataStoreQueryCapabilities.ReadActive do not reapply the predicate to the result set after EventReplay has modified the result set by calling ApplyAggregateEvents()

This can be replicated by adding the following line into the WhenCallingCreateWithoutCommitting.ItShouldReflectTheChangeInFutureQueriesFromTheSameSession() unit test:

Assert.Empty(this.testHarness.DataStore.ReadActive<Car>(car => car.Make == "Ford").Result);

SkipAndTake can return more items than expected when take exceeds maxtakesize

If the amount specified by Take is greater than a single maxtakesize, then extra results are returned. To reproduce in WhenCallingReadWithBigSkipAndTake:

this.carsFromDatabaseWithFilter4 = this.testHarness.DataStore.WithoutEventReplay.Read<Car, WithoutReplayOptions<Car>>(car => car.Make == "Volvo", o => o.Skip(100).Take(1500)).Result;
[Fact]
        public void ItShouldReturnTheCorrectAmountOfVolvosWhenTakeIsLessThanAmountOfVolvosAvailableAfterSKip()
        {
            Assert.True(this.testHarness.DataStore.ExecutedOperations.All(e => e is AggregatesQueriedOperation<Car>));
            Assert.Equal(2202, this.carsInDatabase.Count());
            Assert.Equal(1500, this.carsFromDatabaseWithFilter4.Count()); //this fails and due to 2000 items being returned
        }

Read/ReadActive not retrieving Aggregates that have been updated to match the predicate

When DataStoreQueryCapabilities.Read and DataStoreQueryCapabilities.ReadActive query for results they first retrieve results from the DbConnection that match the provided predicate.

If an QueuedUpdateOperation that updates an Aggregate so that it now matches the predicate has not been committed yet, then this Aggregate will not be included in the result set as part of EventReplay.ApplyAggregateEvents.

This can be replicated by adding the following line to WhenCallingUpdateByIdWithoutCommitting.ItShouldOnlyMakeTheChangesInSession:

Assert.Single(this.testHarness.DataStore.ReadActive<Car>(car => car.Make == "Ford").Result);

SUGGESTION: Whitelist or Blacklist of Aggregate Types for Version History

Currently when UseVersionHistory is set to true in DataStoreOptions it will create aggregate history items for all aggregates using DataStore when it calls IncrementAggregateHistoryIfEnabled<T>.

If DataStoreOptions was extended to allow for either a white list or a blacklist of aggregate types for version history then it would prevent un-needed read and write for aggregates where the version history will never be used (e.g. in log items).

DataStoreCreateCapabilities.Create<T> checks for exists already against model.id instead of newObject.id

DataStoreCreateCapabilities.Create has a guard against items that are already preexisting with the same id:

bool existsAlready = (await this.DsConnection.Exists(new AggregateQueriedByIdOperation(methodName, model.id)));
            Guard.Against(existsAlready, "An item with the same ID already exists", Guid.Parse("cfe3ebc2-4677-432b-9ded-0ef498b9f59d"));

However it's checking for model.id instead of newObject.id, this can cause issues if model.id is not yet set and the created aggregate id is expected to be set by the call to ForceProperties() against newObject.

HardDelete when using Version History

HardDelete throws an error when using Version History. HardDelete is failing if the aggregate does not exist and the Version History is activated.

Observation: TestDataCreator is deleting and recreating the aggregate with the same ID (Guid), this might create an issue if Version History already exists for that ID value.

DataStoreQueryCapabilities.Exists not using EventReplay events

When creating an aggregate with a specific id, and then calling Exists() prior to CommitChanges() will result in false being returned rather than true. This appears to be due to the previously executed events are not replayed.

Example:

testHarness.DataStore.Create(newCar).Wait();

\\ result should be true but comes across as false
var result = testHarness.DataStore.Exists(newCar.id).Result;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.