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

Support virtual columns (only add table-prefix if column exists on table) #447

Merged
merged 1 commit into from
Sep 5, 2021
Merged

Support virtual columns (only add table-prefix if column exists on table) #447

merged 1 commit into from
Sep 5, 2021

Conversation

Enaah
Copy link
Contributor

@Enaah Enaah commented Sep 2, 2021

Hey,

I was working on a project with a kind of complex query which powers the livewire-table. In the end, the values of three virtual columns are being displayed.
Since the package automatically adds the table prefix from the table of the query (src/Traits/WithFilters.php- 320), the search function does not work, because the virtual columns do only exist without the prefix.
So I added checking if the column name exists on the given table via the Schema-Facade.

The functionality should be the same + supporting virtual columns.

Extends the applySearchFilter($query)-function to check if the name of the $whereColumn exists on the (parent) schema. If the column (name) exists, add the table-name as a prefix [tableName].[columnName] just like before. If the column name does not exist, just take the column name [columnName]. If it still does not exists (as a virtual column), it will fail just like before.

Extends the `applySearchFilter($query)`-function to check if the name of the `$whereColumn` exists on the (parent) schema. If the column (name) exists, add the table-name as a prefix `[tableName].[columnName]` just like before. If the column name does not exist, just take the column name `[columnName]`. If it still does not exists (as a **virtual column**), it will fail just like before.
@rappasoft rappasoft added the Awaiting Next Release Currently merged into development awaiting a release to master label Sep 3, 2021
@rappasoft rappasoft mentioned this pull request Sep 5, 2021
@rappasoft rappasoft merged commit fdb18fa into rappasoft:master Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Next Release Currently merged into development awaiting a release to master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants