[Nitro] [OG] - Automated table modification / extension
Ilias Lazaridis
ilias at lazaridis.com
Wed Apr 27 11:58:28 EDT 2005
PAUL HANCHETT wrote:
> Ilias--
>
> You might try searching this list for the problem you describe--
I don't have to.
I've raised this issue.
> 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).
you are not up-to-date.
please review the latest threads.
> The problem is that there are a variety of things that can happen that
[...] - (obvious/irrelevant stuff)
I've suggested what is trivial:
implementing initially "add field" and "remove field".
> For now, I believe that you have to manually update changes to the table
> structure once Og has created it.
what you believe is irrelevant.
I'm awaiting the reply of an developer.
[posted it here as no developer-list available].
> 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.
>>
>> .
>>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Nitro-general mailing list
> Nitro-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/nitro-general
--
http://lazaridis.com
More information about the Nitro-general
mailing list