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

Ilias Lazaridis ilias at lazaridis.com
Wed Apr 27 04:16:47 EDT 2005


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.

.

-- 
http://lazaridis.com




More information about the Nitro-general mailing list