-
Notifications
You must be signed in to change notification settings - Fork 194
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
Custom Query string #445
Comments
Hi! Floor currently only supports binding parameters but not bigger query segments. Can you describe your use case a bit more? |
for example at the current version parameter null throw exception and i force to do my query: String query = @query('SELECT * FROM PartnerLocationEntity WHERE :query') |
I think this is high important feature for your library to supprot "rawQuery", |
Try this... Not ideal but works
|
+1 |
Such a feature would be pretty cool, indeed. What are your thoughts about the approach Room takes with raw queries? https://developer.android.com/reference/androidx/room/RawQuery |
I like it. But just FYI, as it stands, you can completely write custom query/raw sql. Just add this to your DAO, similar to what I wrote above. Write any query: To return single row
For multiple rows
Usage example
You can even manipulate the results into the model fields |
Do not forget to allow to construct your own sql query string. |
@salvaterra I am trying to implement a BaseDao based on your example but am not able to get it to work. Do you know how I could do something like this? Here is my code:
At runtime it throws |
Should work, I just tested it. Look at the generated code and how you are inheriting the Base dao.
Generated code
|
@salvaterra thanks for getting back to me! I am able to generate the code fine and my project compiles. My
However at runtime when I go to use |
Is it iOS or Android? I tested on iOS, could it be the implementation of SQL in Android? |
Oh interesting, I am testing on the Android emulator. I'll see if I get different results on iOS |
Yup, that's it. Only works on iOS :( |
I'm out of hacking alternatives :) I guess we would need to implement the proper way. Maybe a new @queryRaw tag that doesn't do the binding. Should be easy, just comment the arguments attribute. |
Hey guys, |
Here is a draft PR. I've verified it briefly, it's working ok for me, so you can try to switch to my branch until it will be merged to the master branch. |
I just want to add that you should not rely on this behaviour. This is more of a bug than a feature and it might no longer work at all after #531 is merged. But I agree that Regarding the initial proposal: I would personally prefer to keep |
Well, it's been so long, but I almost finished |
Hi, can you tell when this feature will be available? floor is awesome btw, I just started working with it. |
I stopped developing it because there is an option allows you access to performing raw requests.
|
Thanks! |
How can i do custom query like :
@query('SELECT * FROM MyEntity WHERE :queryString')
List filterMyEntity(String queryString)
The text was updated successfully, but these errors were encountered: