Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] #2254

Open
xmlanjia opened this issue Nov 29, 2022 · 3 comments
Open

[BUG] #2254

xmlanjia opened this issue Nov 29, 2022 · 3 comments
Labels

Comments

@xmlanjia
Copy link

Data

Product
{
"_id": 1,
"Sn": {"$guid": "28fc0e64-f26a-4423-a9e5-bd435fabb188"},
"GoodsNumber": "DC00001"
}

SELECT $ FROM Product where GoodsNumber like '%00001%'
OK
SELECT $ FROM Product where GoodsNumber like '%01%'
No Data

????

in C#
ILiteQueryable q = db.GetCollection(Lanjia.DB.SysDB.Product).Query();

           var list = q.Where(p => p.GoodsNumber.Contains("00001")) .ToList();

ok

var list = q.Where(p => p.GoodsNumber.Contains("01")) .ToList();
No Data

why????

@xmlanjia xmlanjia added the bug label Nov 29, 2022
@ProKn1fe
Copy link

Very interesting behavior. Feels like some integer conversion bug.

    public class Issue2254_Tests
    {
        [Fact]
        public void SelectTest()
        {
            var ms = new MemoryStream();
            var litedb = new LiteDatabase(ms);

            var collection = litedb.GetCollection<TestData>();
            collection.Insert(new TestData()
            {
                Guid = Guid.NewGuid(),
                Name = "DC00001"
            });

            var test1 = collection.FindOne(a => a.Name.Contains('0')); // Work
            var test2 = collection.FindOne(a => a.Name.Contains('1')); // Work
            var test3 = collection.FindOne(a => a.Name.Contains("01")); // Not work
            var test4 = collection.FindOne(a => a.Name.Contains("001")); // Not work
            var test5 = collection.FindOne(a => a.Name.Contains("0001")); // Not work
            var test6 = collection.FindOne(a => a.Name.Contains("00001")); // Work
            var test7 = collection.FindOne(a => a.Name.Contains("C00001")); // Work
            var test8 = collection.FindOne(a => a.Name.Contains("DC00001")); // Work
            //Assert.NotNull(item);
        }

        private class TestData
        {
            public Guid Guid { get; set; }
            public string Name { get; set; }
        }
    }

@xmlanjia
Copy link
Author

@ProKn1fe Yes, the same to u,hexadecimal?

@ProKn1fe
Copy link

No it's not integers bug, it's SqlLike function bug. Actually there is already pull request #2235 (not merged) that fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants