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
Eliminate, alter, or make caveats to references to type-safety. #20
Comments
Hey Gregory, really like what you've done with this framework and I think I can help you solve at least part of the type safety issue. Take a look at the branch on my fork called typesafe-attributes (specifically this file. Created a protocol called TypedExpressionConvertible that extends CustomExpressionConvertable to provide an associated type (the value type of the attribute). Then I've constrained the custom == operator for attributes to the value type of the attribute (see here). If you check out the branch and look at FilterTests, find the use of the new custom operator (not using == for now to avoid a large refactor for the example). You'll find that Furthermore, I've updated cdqi to pull the attribute type from the model file and use it to template the Attribute files (needs some sanitization). If you're good with this approach, I basically just need to implement TypedExpressionConvertible for each data type available in Core Data, and it's stupidly simple to do so. |
Pat, Thanks for the kind words! I haven't had a chance to look at the In early prototypes of CDQI—before I ever had it on Github—I had something similar, but ultimately I removed it because of the great many numeric types Swift has. Implementing type safety for Int, UInt, Int32, Float, CGFloat, Double, etc. got to be a bit crazy. My biggest concern with this is that it should be able to take just about any numeric type we can throw at it absolutely seemlessly, whether expressed as a literal (i.e., If you can pull it off, I'm strongly in favor of adding it. Greg |
Good point about the numeric types, I'll try to come up with something to handle that. The other odd case is a transformable attribute. Maybe the easiest solution is to let them just be KeyAttributes and be comparable to Any. Another options is that TransformableAttribute is a generic type, where T is the type being transformed in and out of the store (could be specified in the user info of the attribute for example). I'll work on a few things and submit a pull request in the near future. |
Closed in favor of #26. |
Strictly speaking, CDQI's filtering is not type safe. Using a proxy, we can make a comparison to any type, e.g.,
This produces the predicate
"name == 7"
, which will probably fail at runtime. I have no plans to create a truly type-safe version of CDQI. CDQI is focused around flexibly building keypaths and predicates, not type-safety per se.The text was updated successfully, but these errors were encountered: