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

[Translatable] added selective field translation to the translatable extension #2874

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

smatyas
Copy link
Contributor

@smatyas smatyas commented Oct 3, 2024

This PR tries to solve the problem where the user reaches the mysql join table count limitation due to many translatable fields.

If we have too many, the following mysql error arises:

ERROR 1116 (HY000): Too many tables; MySQL can only use 61 tables in a join


Certainly, it is not a complete solution for the problem, meaning that we will still be unable to translate every field in one query, but I found it really useful in certain scenarios.

Using this optional hint, the user can be selective about the fields to translate, so it will limit the number of joins to those fields.

Without this, the user have to use different workarounds that makes this extension less useful.


usage example:

        $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, TranslationWalker::class);
        $query->setHint(TranslatableListener::HINT_FALLBACK, 1);
        $query->setHint(TranslatableListener::HINT_TRANSLATABLE_LOCALE, $locale);

        // Only these fields will be translated by the walker.
        $query->setHint(TranslationWalker::HINT_ONLY_FIELDS, [
            'entity.marketingTitle',
            'entity.marketingDescription',
            'event.name',
            'marketingCategory.name'
        ]);

Copy link

codecov bot commented Oct 3, 2024

Codecov Report

Attention: Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 78.82%. Comparing base (0632ab1) to head (05072ed).
Report is 67 commits behind head on main.

Files with missing lines Patch % Lines
...ranslatable/Query/TreeWalker/TranslationWalker.php 40.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2874      +/-   ##
==========================================
+ Coverage   78.75%   78.82%   +0.07%     
==========================================
  Files         163      167       +4     
  Lines        8593     8643      +50     
==========================================
+ Hits         6767     6813      +46     
- Misses       1826     1830       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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