OrderByClause class
The OrderByClause class represents an order by clause for a QgsFeatureRequest.
Contents
It can be a simple field or an expression. Multiple order by clauses can be added to a QgsFeatureRequest to fine tune the behavior if a single field or expression is not enough to completely specify the required behavior.
If expression compilation is activated in the settings and the expression can be translated for the provider in question, it will be evaluated on provider side. If one of these two premises does not apply, the ordering will take place locally which results in increased memory and CPU usage.
If the ordering is done on strings, the order depends on the system's locale if the local fallback implementation is used. The order depends on the server system's locale and implementation if ordering is done on the server.
In case the fallback code needs to be used, a limit set on the request will be respected for the features returned by the iterator but internally all features will be requested from the provider.
Constructors, destructors, conversion operators
- OrderByClause(const QString& expression, bool ascending = true)
- Creates a new OrderByClause for a QgsFeatureRequest.
- OrderByClause(const QString& expression, bool ascending, bool nullsfirst)
- Creates a new OrderByClause for a QgsFeatureRequest.
- OrderByClause(const QgsExpression& expression, bool ascending = true)
- Creates a new OrderByClause for a QgsFeatureRequest.
- OrderByClause(const QgsExpression& expression, bool ascending, bool nullsfirst)
- Creates a new OrderByClause for a QgsFeatureRequest.
Public functions
- auto ascending() const -> bool
- Order ascending.
- auto dump() const -> QString
- Dumps the content to an SQL equivalent.
- auto expression() const -> QgsExpression
- The expression.
- auto nullsFirst() const -> bool
- Set if NULLS should be returned first.
- auto prepare(QgsExpressionContext* context) -> bool
- Prepare the expression with the given context.
- void setAscending(bool ascending)
- Set if ascending order is requested.
- void setNullsFirst(bool nullsFirst)
- Set if NULLS should be returned first.
Function documentation
QgsFeatureRequest:: OrderByClause:: OrderByClause(const QString& expression,
bool ascending = true)
Creates a new OrderByClause for a QgsFeatureRequest.
| Parameters | |
|---|---|
| expression | The expression to use for ordering |
| ascending | If the order should be ascending (1,2,3) or descending (3,2,1) If the order is ascending, by default nulls are last If the order is descending, by default nulls are first |
QgsFeatureRequest:: OrderByClause:: OrderByClause(const QString& expression,
bool ascending,
bool nullsfirst)
Creates a new OrderByClause for a QgsFeatureRequest.
| Parameters | |
|---|---|
| expression | The expression to use for ordering |
| ascending | If the order should be ascending (1,2,3) or descending (3,2,1) |
| nullsfirst | If true, NULLS are at the beginning, if false, NULLS are at the end |
QgsFeatureRequest:: OrderByClause:: OrderByClause(const QgsExpression& expression,
bool ascending = true)
Creates a new OrderByClause for a QgsFeatureRequest.
| Parameters | |
|---|---|
| expression | The expression to use for ordering |
| ascending | If the order should be ascending (1,2,3) or descending (3,2,1) If the order is ascending, by default nulls are last If the order is descending, by default nulls are first |
QgsFeatureRequest:: OrderByClause:: OrderByClause(const QgsExpression& expression,
bool ascending,
bool nullsfirst)
Creates a new OrderByClause for a QgsFeatureRequest.
| Parameters | |
|---|---|
| expression | The expression to use for ordering |
| ascending | If the order should be ascending (1,2,3) or descending (3,2,1) |
| nullsfirst | If true, NULLS are at the beginning, if false, NULLS are at the end |
bool QgsFeatureRequest:: OrderByClause:: ascending() const
Order ascending.
| Returns | If ascending order is requested |
|---|
QgsExpression QgsFeatureRequest:: OrderByClause:: expression() const
The expression.
| Returns | the expression |
|---|
bool QgsFeatureRequest:: OrderByClause:: nullsFirst() const
Set if NULLS should be returned first.
| Returns | if NULLS should be returned first |
|---|
bool QgsFeatureRequest:: OrderByClause:: prepare(QgsExpressionContext* context)
Prepare the expression with the given context.