-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
databaseIssues or pull requests that affect the database layerIssues or pull requests that affect the database layer
Description
PHP Version
8.2
CodeIgniter4 Version
4.5.5
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter
)
Which operating systems have you tested for this bug?
Linux
Which server did you use?
apache
Database
PostgreSQL 15.8
What happened?
when writing a query (in PostgreSQL), it became necessary to sort with the TO_CHAR function, but we get an error at the output: ASC is applied twice
Steps to Reproduce
$this->builder()->select(
[
'COUNT(lottery_coupons.id) AS regCoupons',
"TO_CHAR(lottery_coupons.updated_at, 'YYYY-MM-DD HH24:00:00') AS hourInterval"
]
)->where(['lottery_coupons.is_reg' => 1])
->groupStart()
->where("lottery_coupons.updated_at::time BETWEEN '09:00:00'::time AND '20:00:00'::time",escape: false)
->groupEnd()
->groupBy("hourInterval")
->orderBy("hourInterval", 'ASC');
$result = $this->asArray()->findAll();
Expected Output
SELECT COUNT(lottery_coupons.id) AS regCoupons, TO_CHAR(lottery_coupons.updated_at, '%Y-%m-%d %H:00:00') AS hourInterval FROM "lottery_coupons" WHERE "lottery_coupons"."is_reg" = 1 AND ( "lottery_coupons"."updated_at" BETWEEN TO_TIMESTAMP(TO_CHAR(lottery_coupons.updated_at, 'YYYY-MM-DD 09:00:00'), 'YYYY-MM-DD HH24:MI:SS') AND TO_TIMESTAMP(TO_CHAR(lottery_coupons.updated_at, 'YYYY-MM-DD 20:00:00'), 'YYYY-MM-DD HH24:MI:SS') ) GROUP BY TO_CHAR(lottery_coupons.updated_at, "%Y-%m-%d %H:00:00") ORDER BY TO_CHAR(lottery_coupons.updated_at ASC, 'YYYY-MM-DD HH24:00:00') ASC
Anything else?
No response
Metadata
Metadata
Assignees
Labels
databaseIssues or pull requests that affect the database layerIssues or pull requests that affect the database layer