Skip to content

feat: add option to enable alias on relation tables #3234

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

Merged
merged 1 commit into from
May 17, 2025

Conversation

Seb33300
Copy link
Contributor

@Seb33300 Seb33300 commented May 7, 2025

In #3216, I implemented automatic unique aliases on relation tables to prevent duplicated table name issues.

That bugfix unfortunately introduce a BC break that we cannot prevent.

As suggested by @Arkhas, that makes that feature optional and disabled by default to keep backward compatibility.

$datatable = new EloquentDataTable($this->query());
$datatable->enableEagerJoinAliases();

@Arkhas
Copy link
Contributor

Arkhas commented May 12, 2025

Sounds good, maybe add the ability to set a default value in the config ? that's would be nice to have, but we can work with this if you don't think that would be a good idea.

Thank you very much !

@Seb33300 Seb33300 changed the title feat: add option to disable alias on relation tables feat: add option to enable alias on relation tables May 16, 2025
@Seb33300
Copy link
Contributor Author

@yajra Since it's not possible to implement alias on join table in a backward compatible way and because this is causing multiple bug reports and complication for developers who want to upgrade (see #3216 (comment) or #3237 (comment)), I finally updated that PR to disable aliases on join tables by default.

The developer will have to opt in for that feature if he is facing a Not unique table/alias error:

$datatable = new EloquentDataTable($this->query());
$datatable->enableEagerJoinAliases();

Copy link

@yajra
Copy link
Owner

yajra commented May 17, 2025

Confirmed working as expected 💯, Thanks!

@yajra yajra merged commit bcf7040 into yajra:master May 17, 2025
6 of 7 checks passed
@yajra
Copy link
Owner

yajra commented May 17, 2025

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.

3 participants