Field-indexers for changed fields

Posts   
 
    
HcD avatar
HcD
User
Posts: 214
Joined: 12-May-2005
# Posted on: 22-Feb-2006 14:28:27   

Hi,

It is my understanding that the object model uses the field-index to access an entities value. Now i wonder what happens if the database changes the field-index .. is there a one-time assert on startup to verify that the field indices are correct ? Eg, assume you have a table with three fields F1,F2,F3 .. if for some reason someone changes the field order in de database to F1,F3,F2 and does not regenerate the datalayer, will this get noticed somewhere before all kinds of strange bugs happen in the application ?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 22-Feb-2006 15:42:32   

Will only be noticed if you refreshed your catalog from the designer.

Otherwise, the Designer works in an offline mode, once it retreives the schema it works independantly from the database.

The generated code can't notice this unless when it tries to use the fields, then an exception will be thrown somewhere.

Best Practice: kill anybody who touches your database without saying he did so

(Otis: tssssk wink )

HcD avatar
HcD
User
Posts: 214
Joined: 12-May-2005
# Posted on: 22-Feb-2006 16:35:58   

The generated code can't notice this unless when it tries to use the fields, then an exception will be thrown somewhere.

That is still acceptable ..but i fear an exception will not be thrown if the swapped fields were the same type (eg. both double or varchar(20)) ..that is worse then frowning

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39930
Joined: 17-Aug-2003
# Posted on: 22-Feb-2006 18:55:16   

It should keep on working. The object read logic calculates the ordinals from the index of fields in the query.

So the query will look like SELECT F1, F2, F3 FROM table

and it then calculates name-index pairs to quickly read values from the value arrays returned by the datareader, so it should keep on working.

Frans Bouma | Lead developer LLBLGen Pro