mbdavid / LiteDB

LiteDB - A .NET NoSQL Document Store in a single data file
http://www.litedb.org
MIT License
8.61k stars 1.25k forks source link

[BUG] FileStorage.Find with Guids in path #1733

Open jsinsel-kahua opened 4 years ago

jsinsel-kahua commented 4 years ago

Version 5.08

Describe the bug I recently upgraded to 5.0.8 from version 4.1.4. Using the FileStorage.Find method crashes with guids in the path. I was able to do this in 4.1.4. I didn't notice anything in the documentation on v5 FileStorage that would prevent this.

Code to Reproduce var connectionString = new ConnectionString { Filename = "test.db", Connection = ConnectionType.Direct }; var db = new LiteDatabase(connectionString); var guid = Guid.NewGuid(); var path = $"$/TestPath/{guid}/"; var files = db.FileStorage.Find(path).ToList();

I've also tried with no trailing slash and also formatting the guid with the N format (no dashes) with no success.

Expected behavior Be able to use guids in file "directory" paths.

litedberror

lbnascimento commented 4 years ago

@jsinsel There's an inconsistency in FileStorage.Find(string) between v4 and v5. I'll work on a fix, but in the meantime, using fs.Find(x => x.Id.StartsWith(path)) is a simple workaround.

jsinsel-kahua commented 4 years ago

That workaround keeps me moving, thanks!

nirdil commented 3 years ago

Isn't this workaround bad performance wise? wouldn't that iterate over the entire file storage?