Project

General

Profile

Actions

Feature #84814

closed

Support literal orderBy clauses

Added by Michael Stopp about 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2018-04-20
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

With the QueryBuilder it's currently not possible to do orderings that go beyond simple field list, i.e. something like in these real-life examples:

ORDER BY FIELD(eventtype, 0, 4, 1, 2, 3), sorting

or

ORDER BY CAST(SUBSTRING_INDEX(c.IP, '.', -1) AS UNSIGNED)

There should be something equivalent to selectLiteral for orderBy.

Without this, it can be difficult to properly migrate extensions from $GLOBALS['TYPO3_DB'] to Doctrine DBAL syntax.

Actions #1

Updated by Georg Ringer about 6 years ago

  • Status changed from New to Needs Feedback

I would go with ->add('orderBy', 'FIELD(eventtype, 0, 4, 1, 2, 3)', true). what do you think?

Actions #2

Updated by Michael Stopp about 6 years ago

Oh great, thanks! I must admit that I wasn't aware of this. When I checked the API reference, I was looking for something more specific and thus must have missed this rather generic method. I guess this issue can be closed then.

I would suggest however, that the API core documentation should mention such possibilities (eg. add, selectLiteral, addSelectLiteral). Neither the page on QueryBuilder nor the one "Migrating from TYPO3_DB" do really point this out.

Actions #3

Updated by Georg Ringer about 6 years ago

  • Status changed from Needs Feedback to Resolved
Actions #4

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF