Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+getModelInfos 逻辑修改 #1

Open
wving5 opened this issue May 15, 2019 · 2 comments
Open

+getModelInfos 逻辑修改 #1

wving5 opened this issue May 15, 2019 · 2 comments
Labels
Enhancement New feature or request Review

Comments

@wving5
Copy link
Owner

wving5 commented May 15, 2019

See:
https://github.com/li6185377/LKDBHelper-SQLite-ORM/issues/138

@wving5 wving5 added the Review label May 15, 2019
@wving5
Copy link
Owner Author

wving5 commented May 15, 2019

Changes:

  1. + getSelfPropertys: protypes: 不再返回父类属性 (鉴于只有 + getModelInfos 一处调用,直接修改原有实现,也算符合方法命名 ❓
  2. 各 cls 只管理自身属性(不含父类) 的 tableMapping ,即子类不主动 override + getTableMapping 方法, 就不会被调用到
    2.1 注意此处用 class_getMethodImplementation(objc_getMetaClass(clsName.UTF8String), @selector(getTableMapping)) 会增加方法执行时间 (鉴于只在初始化 ORM 的时候执行一次,姑且认为影响不大
    2.2 也可以在父类实现里放入类似以下实现,只是同样会有样板代码的问题,违背修改的初衷
@implementation SuperClass
+ (id)getTableMapping {
    if( self != [SuperClass class] ) return;
    // ...
}
@end
  1. 原先 LKSQL_Mapping_UserCalculate mapping 类型的属性不会加入到子类 modelInfos 中去, 改为加入子类 modelInfos

7ed48ba
8311c03
8812754

@wving5 wving5 added the Enhancement New feature or request label May 15, 2019
@wving5
Copy link
Owner Author

wving5 commented Jun 16, 2019

已知问题:

  • getTableMapping 不是向下兼容的, 如果包含了父类的字段,会触发断言

NSUInteger index = [propertyNames indexOfObject:property_name];
NSAssert(index != NSNotFound, @"#ERROR TableMapping SQL column name %@ not fount %@ property name", column_name, property_name);
property_type = [propertyType objectAtIndex:index];
column_type = LKSQLTypeFromObjcType(property_type);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Review
Projects
None yet
Development

No branches or pull requests

1 participant