I am trying to do an "Collection.Upsert" on the following POCO class. [There are other classes like this where upsert works fine!. Only this class fails]. The error is: Error "Invalid format: Collection" when doing Upsert
public class Order : BindableBase
{
public Order()
{
this.OrderItems = new List
}
public int Id { get; set; }
[BsonRef("OrderMaster")]
public OrderMaster OrderMaster { get; set; }
public List
}
Stack trace:
Invalid format: Collection
at LiteDB.CollectionService.Add (System.String name) [0x0002b] in:0
at LiteDB.LiteEngine.GetCollectionPage (System.String name, System.Boolean addIfNotExits) [0x00035] in:0
at LiteDB.LiteEngine.Transaction[T] (System.String collection, System.Boolean addIfNotExists, System.Func`2[T,TResult] action) [0x00006] in:0
Thank you for the help..
When you paste code block, you can use three back tick to quote it.
Are your other working collections all derived from BindableBase?
What collection name are you using when you call GetCollection?
I add a similar problem. I was using a GUID string to name collections. Then I realised that Collection naming can not include '-' character. I then replaced the '-' for a '_'. But it didn't make it for me. Still had the problem. Finally I decided to shorten the name (it now has 7 characters) and, hurray, it is working.
I have the same problem and I think I know where the problem lies.
If a collection name exceeds 30 positions, it fails!
Could you please increase the limit of the name, or at least generate some kind of error...
The 30 characters limitation for a collection name is very restrictive. This does not allow me to store an instance of a class with a name like TransformationPlannerSagaStateMachine. This fails:
var collection = db.GetCollection<TSaga>();
collection.Insert(context.Saga);
Can the name limit be increased?
I think it should be at minimum 32 characters, that way we can use guids (without -) and/or MD5 the content as the collection name
Length limitation of 30 verified. So basically this code
db.GetCollection<T>("AAAA5AAA10AAA15AAA20AAA25AAA30A").Insert(data);
will get you this error:
at LiteDB.CollectionService.Add(String name)
at LiteDB.LiteEngine.GetCollectionPage(String name, Boolean addIfNotExits)
at LiteDB.LiteEngine.TransactionT
at LiteDB.LiteCollection1.Insert(IEnumerable1 docs)
Hi @MrSmoke and @leek9 changed in dev branch a14b8e6 - 60 char max length. Will be available in next major version 3.5
It still seems to be limites to 30 charaters in version 4.0
LiteDB/LiteDB/Engine/Structures/CollectionIndex.cs
public static Regex IndexPattern = new Regex(@"^[\w](\.?[\w\$][\w-]*){0,29}$", RegexOptions.Compiled);
Additionally the limit in LiteDB/LiteDB/Engine/Pages/CollectionPage.cs seems to play a role here:
public static Regex NamePattern = new Regex(@"^[\w-]{1,36}$", RegexOptions.Compiled);
Hi @corelgott, humm... really strange. I think that I change in twice and, when git request a merge (in vim) i just do :wq 馃槃 I will back to 60 in both cases
Hi @mbdavid, it would be really nice to have this issue fixed in the NuGet package.
Do you have any plans to deliver a new release in the nearest future?
Hi @vanufryiuk, soon... maybe this week :) I'm will release v4.0.1 before v4.1 that I'm working in another branch.
Shit, almost 2 days do debugging the code, finally find the cause of "exception: invalid format" is due to character over than 30.
i use version runtime : v4.0.30319
Upgrade do 4.1, it麓s fixed now in 60 chars (at limit of 3000 for all collections names)
It would be nice with more explicit error messages than just "Invalid format". For example "Name too long" and "Invalid character in name" and ...
Hi! With the objective of organizing our issues, we are closing old unsolved issues. Please check the latest version of LiteDB and open a new issue if your problem/question/suggestion still applies. Thanks!
Most helpful comment
It would be nice with more explicit error messages than just "Invalid format". For example "Name too long" and "Invalid character in name" and ...