>
> Right now I am taking  test run object from local database, then I call 
> expunge on that object (cascade is set to expunge).
>
 then I put this object into this python method :
 

 

def _reset_primary_keys(self, test_run):
    make_transient(test_run)
    test_run.ID = None
    if test_run.OrderNumber:
        make_transient(test_run.OrderNumber)
        test_run.OrderNumber.ID = None

    for equipment in test_run.TestEquipments:
        make_transient(equipment)
        equipment.ID = None

    for trd in test_run.TestRunToDevs:
        make_transient(trd)
        trd.ID = None

        if trd.TestedDut:
            make_transient(trd.TestedDut)
            trd.TestedDut.ID = None

        for test_step in trd.TestSteps:
            make_transient(test_step)
            test_step.ID = None

            for test_result in test_step.TestResults:
                make_transient(test_result)
                test_result.ID = None


This method reset all primary keys, so I can merge it into master database 
which will generate new primary keys. Is there a better or easier way how to do 
it?

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to