Can't nil out nullable 1 to 1 field

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Can't nil out nullable 1 to 1 field

David Buck
I have an object called a Ticket which has a one-to-one nullable relationship to a Code_Release.  When I try to set the field in the ticket to nil, it doesn't make that change in the database.  The funny think is that it's happy to increment the version number but doesn't nil codeRelease.  Any ideas?  I'm using the Glorp packaged with VisualWorks 7.10.1 with an Oracle database.

Details:

Code to nil the code release:

        MyGlorpSession inUnitOfWorkDo: [:session |
                selectedCodeRelease tickets do: [:ticket |
                        session register: ticket.
                        ticket version: ticket version + 1.
                        ticket codeRelease: nil]].


Ticket class model:
classModelForTicket: aClassModel
        aClassModel
                newAttributeNamed: #id;
                newAttributeNamed: #version;
                newAttributeNamed: #codeRelease type: TicketCodeRelease

Ticket mappings:
descriptorForTicket: aDescriptor
        | table |
        table := self tableNamed: 'TICKETS'.
        aDescriptor table: table.
        (aDescriptor newMapping: Glorp.DirectMapping) from: #id to: (table fieldNamed: 'id_pk').
        (aDescriptor newMapping: Glorp.DirectMapping) from: #version to: (table fieldNamed: 'version_lk').
        (aDescriptor newMapping: Glorp.OneToOneMapping)
                attributeName: #codeRelease;
                mappingCriteria: (
                        Glorp.Join
                                from: (table fieldNamed: 'code_release_fk')
                                to: ((self tableNamed: 'CODE_RELEASES') fieldNamed: 'id_pk')).

Ticket table:
tableForTICKETS: aTable

        | codeReleaseField |
        (aTable createFieldNamed: 'id_pk' type: platform sequence) bePrimaryKey.
        (aTable createFieldNamed: 'version_lk' type: platform integer) beLockKey.
        (codeReleaseField := aTable createFieldNamed: 'code_release_fk' type: platform integer) beNullable: true.
        aTable
                addForeignKeyFrom: codeReleaseField
                to: ((self tableNamed: 'CODE_RELEASES') fieldNamed: 'id_pk').