Skip to content
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

No method for random query #1608

Closed
arshad115 opened this issue Aug 16, 2018 · 4 comments
Closed

No method for random query #1608

arshad115 opened this issue Aug 16, 2018 · 4 comments

Comments

@arshad115
Copy link

DBFlow Version: 4.2.4

Bug or Feature Request: Feature Request

Description:

DBFlow does not support random query.

In SQLite I would simply write the query as:

select * from table_name ORDER BY RANDOM() LIMIT 1;

I couldn't find anything which is equivalent for it DBFlow.

@agrosner
Copy link
Owner

Did you try something like .orderBy(Property<Any>(NameAlias.rawBuilder("Random()").build()))?

@arshad115
Copy link
Author

Thanks for the reply, but, it does not work with Property<Any>.

@agrosner
Copy link
Owner

For now, use orderBy(OrderBy.fromString("RANDOM()")) sorry for late reply! I will add a new way in 5.0.0-alpha2

@agrosner
Copy link
Owner

Now even better, orderBy random will work in kotlin. Java, use .orderBy(Method.random)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants