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

[WIP] Allow passing locale to queries #210

Closed
wants to merge 3 commits into from
Closed

Conversation

shioyama
Copy link
Owner

Fixes #51.

This PR works for all backends except column currently. Ironically, column is the simplest backend but supporting an array-valued locale option to queries (Post.i18n.where(title: "foo", locale: [:en, :fr])) is more complicated than I thought.

I'm going to try getting basic specs green first, then think about how this can be cleaned up. I have a rough plan to lean much more heavily on Arel and hopefully make the query interface more flexible.

@shioyama
Copy link
Owner Author

The pleasant surprise is that except for Column, other backends were quite easy to adapt to this feature.

@shioyama shioyama force-pushed the query_locales branch 2 times, most recently from 66e1bd1 to cc1e621 Compare April 18, 2018 04:05
@shioyama
Copy link
Owner Author

Although specs are passing, this is not quite working yet. It breaks if you query on more than one translated attribute with different backends in a single where, because one backend strips the locale key/value so other backends don't get it.

Will work on a fix, but for basic cases this should work.

@shioyama
Copy link
Owner Author

shioyama commented May 5, 2018

Closing this since #216 will require many changes. I'll make a new PR later once query stuff settles down a bit.

@shioyama shioyama closed this May 5, 2018
@shioyama shioyama deleted the query_locales branch May 8, 2018 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant