cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

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

Open tztztztz opened this issue 4 years ago • 4 comments

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);

tztztztz avatar Feb 28 '22 11:02 tztztztz

Right now pgsql part of phalcon orm quite poor and not all features implemented. But. It has Criteria feature, which can be used to implement custom expressions.

BeMySlaveDarlin avatar Feb 28 '22 11:02 BeMySlaveDarlin

Yes, and I've previously contributed to Phalcon ORM and fixed minor issue regarding PostgreSQL, maybe I will fix it too, but I'm not too good with all the building process and github at all, but if it not gonna be fixed in like 2-3 months I probably will try.

tztztztz avatar Feb 28 '22 12:02 tztztztz

RN we team is out of resourses for extending orm and implementing new features due to finishing v5 asap. It will be gr8, if you create non-bc pull request with such a fix.

BeMySlaveDarlin avatar Feb 28 '22 12:02 BeMySlaveDarlin

When I'll find the Time I will try, right now I fixed my problem by other way around.

tztztztz avatar Feb 28 '22 12:02 tztztztz