Skip to content
This repository

Generated headers lack @class declaration for fetch requests #58

Open
bgulanowski opened this Issue · 4 comments

2 participants

Brent Gulanowski Jonathan 'Wolf' Rentzsch
Brent Gulanowski

Generated code for fetching supports variable substitution (FTW). However, fetch request templates which use relationships invariably use a custom class from the model. Those classes are not declared in generated header files using @class directives, resulting in compilation errors.

Solution may require caching of prettyFetchRequests before template merge is performed so that entity class names can be extracted from fetch request bindings.

Jonathan 'Wolf' Rentzsch
Owner

I guess my fetch requests don't usually involve relationships, so I'm not running into this issue. Can you give me an example of the generated code and what code you'd like to see generated?

Brent Gulanowski

I have a thing A that has things B that has things C. Given thing A, I want all those things C, but not necessarily things B.

Fetch all C's where C.B==A.B.

The fetch request is generated fine, but it uses the class for A in the method signature, which isn't recognized by the compiler.

Jonathan 'Wolf' Rentzsch
Owner

Thanks. If you want this fixed, could you fork mogeneratorTestMule and add the test entities (you can name them EntityA, EntityB, etc) and the fetch request that results in the failing codegen?

There's the hard (correct) way to fix this: do the lookups and put stash the results in an NSSet that can be accessed by the templates. But there's also an easy (hacky) way work-around: we could add an "extraMachineClassDeclararions" Entity.userInfo and you could specify it manually.

Jonathan 'Wolf' Rentzsch
Owner

Dup'd as #123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.