Skip to content

[BUG]: PostgreSQL ORDER BY and NULLS FIRST, NULLS LAST #15917

Open
@tztztztz

Description

@tztztztz

Describe the bug
I'm not sure if it's bug or feature request but I'm leaning more towards bug, so I'm marking it as a bug.

In PostgreSQL you can decide how to treat NULLS when ordering records: NULLS FIRST, NULLS LAST.

Examples:

SELECT a.* FROM my_table a ORDER BY a.total_sum DESC NULLS LAST;
SELECT * FROM current_store ORDER BY qty ASC NULLS FIRST;

PostgreSQL documentation:

https://www.postgresql.org/docs/current/queries-order.html

When trying to use it with Phalcon ORM (PostgreSQL dialect), it produces error:

Syntax error, unexpected token IDENTIFIER(NULLS), near to ' LAST LIMIT :APL0: OFFSET :APL1:'

To Reproduce
Just use Phalcon ORM builder and try to order by [ASC|DESC] [NULLS LAST|NULLS FIRST]

$builder->orderBy('DESC NULLS LAST);
$builder->orderBy('DESC NULLS FIRST);
$builder->orderBy('ASC NULLS LAST);
$builder->orderBy('ASC NULLS FIRST);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions