[Nitro] [OG] - Automated table modification / extension

PAUL HANCHETT paulha at aracnet.com
Wed Apr 27 11:47:58 EDT 2005


Ilias--

You might try searching this list for the problem you describe-- I've 
seen it mentioned here and George responded that there was a feature to 
automatically update the structure.  He said it was presently turned off 
because he worried that it was a bit dangerous (and it is).

The problem is that there are a variety of things that can happen that 
will change the structure of the table, and the meta information to know 
how to handle each case is not there.  Adding a new field is relatively 
clean, so it dropping one.  But renaming a field looks like a drop /and/ 
an add, and a naieve implementation will loose data rather than rename 
the field as desired.

For now, I believe that you have to manually update changes to the table 
structure once Og has created it.

Paul


Ilias Lazaridis wrote:

> Ilias Lazaridis wrote:
>
>> I create a class, instantiate an object and save it within an
>> sqlite3.
>>
>> I retrieve this object.
>>
>> [the table was created, and I load the object back]
>>
>>
>> In the next step, I add a new "property" to the class.
>>
>> I instantiate an new object, and try to save it.
>>
>> but: the save fails with an "field not fould" exception.
>>
>> [the new property i've added]
>>
>> -
>>
>> How do I setup OG that it automaticaly match the table to the updated
>>  class-definition? (= automaticly add columns).
>
>
> Implementation Suggestion:
>
> in pseudo-code:
>
> #-------------------------------------
>
> if store.freezed?
>   return appStoreFreezedError
>
> for each store.classes (aClass)
>
>   if not aClass.store.freezed?
>     if not aClass.store.actual?
>       aClass.store.restructure()
>
> next
>
> #-------------------------------------
>
> aClass::store::restructure()
>
> for each class.field (aField)
>
>   action = aField.detectActionToPerform()
>   if action
>     # call action
>   else
>     # doNothing
>
> next
>
>   # actions prioritized:
>   # add fields to table
>   # removde field (optionally keep removed fields)
>   # change field type
>   # execute "SQL restructure"
>
> #-------------------------------------
>
> store.addField(newField)
>   # SQL TABLE ALTER - ADD COLUMN
>   # http://www.sqlite.org/omitted.html
>
> #-------------------------------------
>
> -
>
> please let me know if I should refine this further.
>
> .
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/nitro-general/attachments/20050427/58edc238/attachment.html 


More information about the Nitro-general mailing list