bgultekin / laravel4-datatables-package

Server-side handler of DataTables Jquery Plugin for Laravel 4
267 stars 108 forks source link

Getting Exception 'Invalid table and column names format for ..." when filtering #34

Closed mpemberton5 closed 11 years ago

mpemberton5 commented 11 years ago

So something has changed recently. My filtering used to work. Getting this exception on all the data tables I have. Most of my datatables are simple tables. Here's one table:

TABLE IF NOT EXISTS permissions ( id int(10) unsigned NOT NULL AUTO_INCREMENT, name varchar(100) COLLATE utf8_unicode_ci NOT NULL, description varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, created_at timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', updated_at timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', deleted_at timestamp NULL DEFAULT NULL, PRIMARY KEY (id), KEY permissions_name_index (name) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

Error is on the 'id' column. What gives? I did a composer update and have the latest "dev-master".

mpemberton5 commented 11 years ago

Downloaded latest code and everything appears to be working again.

Also noted that DB::raw() calls doesn't appear to allow naming those columns. Example: DB::raw('categories as cats'). Throws exception in MySQL when filtering because it adds 'as cats' in the where section (it would look something like this - ... WHERE categories as cats LIKE '%c%' ...). Simply took out the column designation and all works well.

bloodyuki commented 11 years ago

I need to convert Integer stored IP to ascii before usage, $incidents = Incident::select(DB::raw("date, INET_NTOA(ip)")); But this doesn't work when searching.

{"error":{"type":"Exception","message":"SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s) (SQL: select count(*) as aggregate from incidents where (date, INET_NTOA(ip) LIKE ?)) (Bindings: array (\n 0 => '%as%',\n))"