Hi,
I improved the TCK-test for Optional.

With the latest datanucleus (5.0.0-release-SNAPSHOT) there is are some problems remaining:

1) "SELECT FROM org.apache.jdo.tck.pc.query.OptionalSample WHERE !(optionalPC.optionalPC.isPresent())"

I think this should only return an object A if A references an object B where B does not reference anything else. However, it also returns objects A where A do not reference anything else (reference is not present).


2) All the orElse() tests still fail. I fixed a number of errors in the tests, but I believe the tests are now correct.

I'll upload the latest version in a minute.

Best regards,
Tilmann


On 04-Jun-16 15:30, Andy Jefferson wrote:
Hi,

a) SQLSyntaxErrorException : Encountered "NOT" at line 1, column 185
Just seen your SQL generated. "WHERE NOT NOT (A0.OPTIONAL_PC IS NULL)"
That is valid on some RDBMS but maybe Derby is throwing its toys out of the 
pram due to it? Current DN code will put brackets in there. i.e NOT (NOT (...))


b) optionalPC.get().id
Released DN code only supports "optionalPC.get()" and not the access of fields 
of the dereferenced object (i.e it didn't do a join to the related table holding the 
object). Current DN code does however support that.
As I mentioned previously, if having problems use nightly builds.


c) Optional.orElse is currently not supported
Yes it is, and has been since DataNucleus v5.0.0-m4. You must be using an old 
version.

Regarding a use-case for orElse, the test I use is putting the orElse in the 
SELECT clause

Query q = pm.newQuery("SELECT id, stringField.orElse('NotPresent') FROM 
mydomain.MyClass");

so I get back the value that is stored when it is set, or some other value if 
not set (much like could be achieved with a CASE statement with other 
datatypes).



Regards


Reply via email to