Skip to content

Incorrect parameters in the call to native function 'LOWER' on search #1889

Closed
@lukecurtis93

Description

@lukecurtis93

Summary of problem or feature request

I have the following code for a table, a Customer object with a Belongs to Parent which is a parent_id column that references another customer model. I also have a full_address attribute with concatenates the address_line_one and address_line_two columns on my customer model

$( function() {
    $('.apiCustomerTable').DataTable({
        serverSide: true,
        processing: true,
        ajax:{
            "url": '/api/datatables/customers',
            "type": "POST"
        },
        "rowCallback": function( row, data, dataIndex ) {
           $(row).addClass( 'clickable-row' );
           $(row).attr("data-href", '/admin/customers/'+data["url_id"]+'/edit');
           $(document).on('click', '.clickable-row', function() {
                window.location = $(this).data("href");
            });
        },
        columns: [
            {data: 'first_name'},
            {data: 'parent', name:'parent.first_name'},
            {data: 'address', name: 'address_line_one'},
            {data: 'email'},
            {data: 'mobile'},
        ]
    });
});

In my controller:

return datatables()->of(Customer::with('parent')->select('customers.*'))
        ->editColumn('first_name', function ($customer) {
            return $customer->name;
        })->addColumn('url_id', function ($customer) {
            return $customer->id;
        })->addColumn('parent', function($customer){
            return $customer->parent ? $customer->parent->name : '';
        })->editColumn('address', function($customer){
            return $customer->full_address;
        })
        ->toJson();

But I receive the following error when searching:

Incorrect parameters in the call to native function 'LOWER'

Incorrect parameters in the call to native function 'lower' (SQL: select count(*) as aggregate from (select '1' as `row_count` from `customers` where (LOWER(`customers`.`first_name`) LIKE %admin% or exists (select * from `customers` as `laravel_reserved_0` where `laravel_reserved_0`.`id` = `customers`.`parent_id` and LOWER(`customers` as `laravel_reserved_0.first_name`) LIKE %admin% and `laravel_reserved_0`.`deleted_at` is null) or LOWER(`customers`.`address_line_one`) LIKE %admin% or LOWER(`customers`.`email`) LIKE %admin% or LOWER(`customers`.`mobile`) LIKE %admin%) and `customers`.`deleted_at` is null) count_row_table)"}

System details

  • Operating System - Homestead, Ubuntu
  • PHP Version - 7.2
  • Laravel Version - 5.7.11
  • Laravel-Datatables Version "name": "yajra/laravel-datatables-oracle", "version": "v8.9.1",

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions