DB Doctor sets type to "unknown" for new fields

#1

Hi,

we are using ObjectDB 2.5.4_04 on Linux.

We added two new Boolean fields to a persistable type and run DB Doctor on the exiting DB file in order to update the schema. The fields are added to the schema as expected, however their type is set to unknown - we were expecting Boolean.

The attached DB file is what was produced by DB Doctor after adding the emergency and broadcast fields. If you run in DB Explorer

select r.emergency from RecordingMetaData as r

you will notice that the type (RSL) is set to unknown. Both are defined as Boolean in Java code.

As a result, update operations for the two new fields fail.

Suggestions?

 

Thank you

Emil

 

 

#2

Nothing is wrong with the database, and the new Boolean fields look fine.

Apparently your report indicates an Explorer behavior of specifying null results as Unknown type, even when static field type can be used. By the way, in other cases the type is shown, for example:

SELECT r.emergency,  r.emergency FROM RecordingMetaData AS r

In addition, the entity class schema shows the Boolean type, as well as when you view RecordingMetaData objects in the Explorer.

ObjectDB Support
#3

Thank you for checking the DB file and for the confirmation that it is Ok.

We are struggling to understand then why updates like the following fail to change the value from null to false:

UPDATE RecordingMetaData AS r SET r.emergency=false WHERE r.emergency IS NULL

DB Explorer reports all OK on the update, but a subsequent SELECT shows 'null' as value for r.emergency, i.e. the value does not change.

We also tried and got the same result:

UPDATE RecordingMetaData AS r SET r.emergency=false WHERE r.emergency=null

Updates of fields that were in the old schema are working fine. For example this works (i.e. subsequent SELECT returns the new value):

UPDATE RecordingMetaData AS r SET r.doNotDelete=true WHERE r.doNotDelete=false

 

I can also confirm that the following sequence of updates works fine:

UPDATE RecordingMetaData AS r SET r.doNotDelete=null

UPDATE RecordingMetaData AS r SET r.doNotDelete=true WHERE r.doNotDelete is null

 

In summary, we cannot get UPDATEs to work for the new fields after updating the schema.

 

Thank you

Emil

 

#4

When the schema changes, existing objects remain with the old schema until the next time they are stored in the database, and then their content is automatically updated to the new schema. The current implementation of UPDATE queries does not support schema update during UPDATE query execution, so UPDATE queries can only update fields that are already included in the objects. See also this forum thread.

Accordingly, you will have to use a loop that iterates over the objects and initializes their new fields before you can update them with an UPDATE query.

ObjectDB Support
#5

Ok, thank you.

When can we expect a version of ObjectDB that will support use of UPDATE queries to initialise  new fields?

Emil

#6

For updates regarding this issue please subscribe to this new issue.

I don't know when it will be fixed, but you can use the workaround of writing several lines of code to update the database after adding a new field.

ObjectDB Support

Reply