editfmah / sharkorm

Shark ORM for iOS/macOS/tvOS/watchOS
http://sharkorm.com
Other
248 stars 39 forks source link

dot notation not working.. found potential fix.. #92

Closed MeteC closed 6 years ago

MeteC commented 6 years ago

Hi,

I've been struggling to get dot notation working in my where clauses - even though it's working fine in SharkORM's test cases - and I tracked it down to SharkORM.m::performQuery:rowBlock: method.

Debugging on line 1913, I see that the fromList element has the join statement @" LEFT JOIN OMTrack as query_auto_join_track ON OMTrackPoint.track = query_auto_join_OMTrack.Id " - notice this should finish with "... = query_auto_join_track.Id", not "... = query_auto_join_OMTrack.Id".

The fix for this is to change line 1908 from:

[fromList addObject:[NSString stringWithFormat:@" LEFT JOIN %@ as query_auto_join_%@ ON %@.%@ = query_auto_join_%@.%@ ", [r.targetClass description], qFieldName, [r.sourceClass description], qFieldName, [r.targetClass description], SRK_DEFAULT_PRIMARY_KEY_NAME]];

to:

[fromList addObject:[NSString stringWithFormat:@" LEFT JOIN %@ as query_auto_join_%@ ON %@.%@ = query_auto_join_%@.%@ ", [r.targetClass description], qFieldName, [r.sourceClass description], qFieldName, qFieldName, SRK_DEFAULT_PRIMARY_KEY_NAME]];

But having not touched this class before, I'm not sure if that would have other ramifications...

MeteC commented 6 years ago

Hold the phones, I just notice in the test code, there was a commit last year making this exact change! (cc2b7290) Is it possible CocoaPods somehow served me up an older version of SharkORM? Or that change was overwritten later by another commit?

editfmah commented 6 years ago

I did think it felt like it was very familiar. Thank you for taking the time to fully investigate it though, it's rare nowadays.

MeteC commented 6 years ago

FYI in my podfile I just have: pod 'SharkORM', :inhibit_warnings => true

(there was an unclosed #pragma somewhere in there too) On repeat cocoapod install, it still gives me the older SharkORM version.

editfmah commented 6 years ago

I'm about to push anew version, so hopefully CocoaPods will un-stuff itself.