Version
Creating the database in v4.1.4
Opening the database in v5.0.18
Describe the bug
If a database created in liteDB v4.1.4 is opened with liteDB v5.0.18 without the param upgrade=true there is a "File is not a valid LiteDB database format or contains a invalid password." exception.
Then the database is corrupt and it's not possible to open it with LiteDB v4.1.4 nor to open it with LiteDB v5.0.18 (even with the upgrading param)
Code to Reproduce
Creating a database in v4.1.1
open it with new LiteDatabase() method but without the upgrade=true parameter
The code throw an exception
Now the size of the database is changed and the database is corrupted
Here the code I use to create the v4 database:
void CreateV4Database()
{
string dbFolder = @"Data\";
Directory.CreateDirectory(dbFolder);
string dbPath = $"{dbFolder}dbTest{liteDBVersion}.db";
using (var db = new LiteDatabase(dbPath))
{
// Create collection
var col = db.GetCollection<MyObject>("MyCollection");
var id = ObjectId.NewObjectId();
var newObject = new MyObject()
{
Id = id,
Name = "test",
};
var actualId = col.Insert(newObject);
}
}
public class MyObject
{
public object Id { get; set; }
public string Name { get; set; }
}
And here the code used to try to open the database with LiteDB v5.0.18
void OpenDatabaseNoUpgrade()
{
string dbFolder = @"Data\";
Directory.CreateDirectory(dbFolder);
string dbPath = $"{dbFolder}dbTest4.1.4.0 - Copy.db";
using (var db = new LiteDatabase($"Filename={dbPath}"))
{
Console.WriteLine("Open database");
}
}
Expected behavior
The exception is a good thing but the database should not be edited. The v4 database should stay the same or at least it should be possible to migrate to v5 with the upgrade=true parameter after it failed wihout the parameter
Screenshots/Stacktrace
Additional context
I add the database before and after trying to open with LiteDBV5
Version Creating the database in v4.1.4 Opening the database in v5.0.18
Describe the bug If a database created in liteDB v4.1.4 is opened with liteDB v5.0.18 without the param upgrade=true there is a "File is not a valid LiteDB database format or contains a invalid password." exception. Then the database is corrupt and it's not possible to open it with LiteDB v4.1.4 nor to open it with LiteDB v5.0.18 (even with the upgrading param)
Code to Reproduce
new LiteDatabase()
method but without the upgrade=true parameterHere the code I use to create the v4 database:
And here the code used to try to open the database with LiteDB v5.0.18
Expected behavior The exception is a good thing but the database should not be edited. The v4 database should stay the same or at least it should be possible to migrate to v5 with the upgrade=true parameter after it failed wihout the parameter
Screenshots/Stacktrace
Additional context I add the database before and after trying to open with LiteDBV5
databases.zip