markrendle / Simple.Data

A light-weight, dynamic data access component for C# 4.0
MIT License
1.33k stars 303 forks source link

Query does not return matching results when comparing 2 columns in Where clause and using InMemoryAdapter #379

Open wmekal opened 8 years ago

wmekal commented 8 years ago

Hi,

I've noticed that query comparing 2 columns in Where clause is not returning matching results, when using InMemoryAdapter, which hurts me in my unit tests. I've checked it with real db (mysql in my case) and it works correctly, so it looks it's only InMemoryAdapter issue.

I'm using version 0.19. Below, you can find a unit test, which demonstrates the bug.

        [Fact]
        public void SimpleData_When2ColumnsAreComparedInWhere_FindsExpectedRow()
        {
            Database.UseMockAdapter(new InMemoryAdapter());
            var db = Database.Open();
            db.Translations.Insert(
                Text: "some text",
                Language: "pl",
                OriginalLanguage: "pl"
            );

            var result = db.Translations
                .All()
                .Where(db.Translations.Language == db.Translations.OriginalLanguage);

            Assert.Equal(1, result.Count());
        }