Skip to content

Bug: orderBy method does not allow ordering by custom field names containing spaces #630

@leigh-ols

Description

@leigh-ols
SELECT CONCAT('',a.date_created,'',DATE_FORMAT(a.date_created,'%d/%m/%Y')) AS 'Order Date',
FROM my_table
ORDER BY `Order Date`

Is valid SQL

However doing

$db->orderBy('Order Date');

Results in the SQL query having:

ORDER BY OrderDate

Note how Order Date became OrderDate which is a non-existant field and returns an SQL error.

This is due to the regex in the orderBy method stripping out spaces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions