Skip to content
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.

SQL error when searching on virtualField columns. #3

Closed
cnizzardini opened this issue Jun 25, 2013 · 2 comments
Closed

SQL error when searching on virtualField columns. #3

cnizzardini opened this issue Jun 25, 2013 · 2 comments
Assignees
Labels

Comments

@cnizzardini
Copy link
Owner

When searching is performed on a virtualField a SQL error is encountered because SQL cannot find the field.

I am not sure how I want to address this problem at the moment. I certainly don't want to muddy the code with what could be a relatively edge scenario.

Work Around:
For now in your DataTables aoColumns configuration set {bSearchable: false} on columns which are virtualFields. If you want to search on these fields put them in DataTables (the actual columns and not the virtualField) and in the configuration set {bVisible: false}.

@ghost ghost assigned cnizzardini Jun 25, 2013
@ionas
Copy link
Contributor

ionas commented Jul 10, 2013

On the topic of Work Around - Furthermore: create a SQL VIEW so you have the field composition on the server.
Sadly this means switching tables for your cake model between read (SQL VIEW) and write (original SQL table) operations. Also means one can skip the virtualField alltogather.

The other way to fix this is probably fixing virtualFields of cakephp to also allow comparison (see
http://stackoverflow.com/a/5734595 ) -though not sure if this is possible on Postgres and MS SQL Server etc.

Btw. thanks for your awesome Datatables Component...:)

@fr0z3nfyr
Copy link

Create the virtual field in your model constructor instead of in the controller action and the search will work normally. See issue #36 for more details.

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

No branches or pull requests

3 participants