This fails:
var results = container.Query<SomeClass>(s =>
s.Field == value && s.AnEnumField != SomeEnum.AnEnumValue
);
Assert.AreEqual(1, results.Count);
But this doesn't:
Predicate<SomeClass> matches = s =>
s.Field == value && s.AnEnumField != SomeEnum.AnEnumValue;
var results = container.Query<SomeClass>(s => matches(s));
Assert.AreEqual(1, results.Count);
The different in the tests clearly demonstrates the issue happens only when db4o does the expression transformation, as calling a method prevents that. The value checked in the test, is the exact value (no case differences), as the test inserts it first.
Any special conditions where the db4o transformations has bugs with those queries? maybe with .net enums?
I have narrowed it down, and my example above didn't include the troublesome bit. Doesn't have to do with the enum field, but with "value" in the above expression.
Specifically the issue happens when the query includes someInstance.Field for the value, like:
var results =
container.Query<SomeClass>(s =>
s.Field == someInstance.Field && s.AnEnumField != SomeEnum.AnEnumValue
);
Assert.AreEqual(1, results.Count);
I finally got to reproduce it in an isolated project (after narrowing it down more in the main project).
Conditions under which this particular bug occur are very specific. Given the last sample code I posted in the question: