[odb-users] Objects without primitive fields & NULL data to BLOB

Alexander Prokhorov prokher at gmail.com
Wed Jan 16 04:03:26 EST 2013


Dear Boris,

thank you for quick response. My comments are in the text below.

On 01/14/2013 08:12 PM, Boris Kolpackov wrote:
> Hi Alexander,
>
> Alexander Prokhorov <prokher at gmail.com> writes:
>
>> 1. [clear bug] It took some time to pinpoint exact problem, which is
>> this - objects without any primitive fields can't be loaded. So, when
>> persistent object contains only collections, load fails with syntax
>> error - odb generates broken query like "SELECT FROM ...". Look into
>> attached example odb_collections_test. Simple workaround is to add dummy
>> primitive field to persistent class.
> Fixed, thanks for the report and the test! Would you like a pre-release
> with the fix (the fix affects the ODB compiler)?
That is great news. It would be great to have pre-release ODB compler 
for i686-windows, i686-linux-gnuo, x86_64-linux-gnu. Thank you in advance.
>
>
>> 2. [bug or feature] Another strange thing that was encountered in same
>> persistent classes - saving NULL data to "blob" type by custom traits.
>> It's unclear, whether such operation is valid, however, I haven't found
>> deep traits description that is deep enough to figure it out. It fails
>> with 'object already persistent' message, which is, at least,
>> perplexing. Message is clearly bad, the question is, can we save NULL
>> blob at all? Non-null with zero size is ok. Look into attached example
>> odb_traits_test.
> Your data member in the persistent class does not allow NULL values.
> To enable NULL, you will need to add the 'null' specifier to your
> pragma, for example:
>
>    #pragma db type("BLOB") null
>    KludgyBool data;
>
> You can also enable this on the per-type basis, if you wish:
>
> #pragma db value(KludgyBool) type("BLOB") null
>
> Newer versions of ODB also indicate whether the value can or cannot
> be NULL via the is_null by-reference argument. That is, before calling
> set_image(), ODB initializes this argument to true if the value can be
> NULL and false otherwise.
>
> As for why you get 'object already persistent' instead of, say 'NULL
> constraint violation', see Section 14.5.4, "Constraint Violations"
> in the ODB manual:
>
> http://www.codesynthesis.com/products/odb/doc/manual.xhtml#14.5.4
That is clear, thank you.
>
> Boris



More information about the odb-users mailing list