AlexDenisov / iActiveRecord

ActiveRecord for iOS without CoreData, only SQLite
http://alexdenisov.github.com/iActiveRecord/
MIT License
354 stars 50 forks source link

The "order by" has incorrect order #89

Closed paulocoutinhox closed 9 years ago

paulocoutinhox commented 9 years ago

The "order by" has incorrect order. Example:

[fetcherChapters orderBy:@"sequence"];
[fetcherChapters orderBy:@"id"];

When iActiveRecord create the "order by" query, it creates:

id ASC, sequence ASC

But the problem is not with iActiveRecord, the problem is with NSMutableDictionary. The method "orderBy" use a NSMutableDictionary to store the "orderBy" sentences. But NSMutableDictionary automatically order the items alphabetically.

Have any way to solve it?

AlexDenisov commented 9 years ago

The only way I see is to fix implementation...

paulocoutinhox commented 9 years ago

Have any apple dictionary or mutable array that i can use without auto sort?

AlexDenisov commented 9 years ago

The easiest way I see is to create a kinda model/tuple to store these values, e.g.:

enum SortOrder { SortOrderASC, SortOrderDESC };
@interface ARSort : NSObject
@property NSString *name;
@property SortOrder order;
@end

and put the instances into NSArray/NSMutableArray.

paulocoutinhox commented 9 years ago

I solve the problem. Will make a PR.

paulocoutinhox commented 9 years ago

https://github.com/AlexDenisov/iActiveRecord/pull/90

paulocoutinhox commented 9 years ago

Can you check? Here is working perfect.