Closed jklimke closed 10 years ago
Yes, I think this could be done without problems. We already have similar stuff here
hi,
i tried to customize the relation foreign key columns by adding selectors named after the original columns. This works very well except for adding objects to belongs_to relations. this is because the setRecord method use the setValue methods directly and do not use selectors as it is done with has_many_through relations. Is there a reason for this ?
Otherwise i could implement something like this and it would work well for me:
´´´ @implementation NBContact
@dynamic name, phone, email, address_id;
belongs_to_imp(NBAddress, address, ARDependencyDestroy)
has_many_through_imp(NBTopic, NBContactGroup, topics, ARDependencyNullify)
This results in the following (desired) table scheme:
contacts id name phone email address_id created_at updated_at
I also noticed, that if the table name for models ist defined through overwriting + (NSString*) recordName in the model class, it is not used consistently throught the framework. Especially when using joins or has_many / has_many_through relation, the class name is used for select statements.
@jklimke, nice catch. Seems it's bug. I'll fix it, PR are welcome too.
OK. I will see what i can do.
This should be fixed with the pull request https://github.com/AlexDenisov/iActiveRecord/pull/59 (did accidentially open up a new issue)
Currently it seems to me that foreign keys for the database are always assumed to be in CamelCase. it would be nice if this could be configured somehow.
E.g. if you have a Contact-Model and an Address model like the following, the foreign key must (???) be like referencedModeNameId and cannot be called referenced_model_name_id.
If this could be changed (optionally), you could easily use a small Rails application to e.g. build a content database to feed you application. That means i would like to have a foreign key like ´´´address_id´´´to be generated
Would this be easily possible ?