v10.4.3 introduced SQL error in SELECT FOR UPDATE
josecl opened this issue · comments
José Rodríguez commented
Summary of problem or feature request
After upgrading from v10.4.2
to v10.4.3
I got ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc.
when doing SELECT FOR UPDATE
Code snippet of problem
With this query builder...
$rango = $this->institucion->rangos()
->where([
'tipo' => $this->tipo,
'manual' => false,
])
->whereNotNull('siguiente')
->whereRaw('siguiente >= desde')
->whereRaw('siguiente <= hasta')
->orderBy('siguiente')
->lockForUpdate()
->first();
On v10.4.2 👍
Bindings : [1,32,0]
select * from "RANGOS"
where "RANGOS"."INSTITUCION_ID" = ?
and "RANGOS"."INSTITUCION_ID" is not null
and ("TIPO" = ? and "MANUAL" = ?)
and "SIGUIENTE" is not null
and siguiente >= desde
and siguiente <= hasta
order by "SIGUIENTE" asc
for update
On v10.4.3 👎
select * from (
select * from "RANGOS"
where "RANGOS"."INSTITUCION_ID" = :p0
and "RANGOS"."INSTITUCION_ID" is not null
and ("TIPO" = :p1 and "MANUAL" = :p2)
and "SIGUIENTE" is not null
and siguiente >= desde
and siguiente <= hasta
order by "SIGUIENTE" asc
)
where rownum = 1 for update
Error Message : ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc.
Position : 14
Statement : select * from (select * from "RANGOS" where "RANGOS"."INSTITUCION_ID" = :p0 and "RANGOS"."INSTITUCION_ID" is not null and ("TIPO" = :p1 and "MANUAL" = :p2) and "SIGUIENTE" is not null and siguiente >= desde and siguiente <= hasta order by "SIGUIENTE" asc) where rownum = 1 for update
Bindings : [1,32,0]
System details
- Operating System: docker ORACLE image gvenzl/oracle-xe:21.3.0 running on Windows 11
- PHP Version: 8.2.16
- Laravel Version: 10.46.0
- Laravel-OCI8 Version: v10.4.3
Arjay Angeles commented
Thanks for reporting, will try to fix it as soon as possible. Please do not hesitate to submit a PR if you can.
Arjay Angeles commented
Introduced by PR #824
Arjay Angeles commented
@josecl patched released on v10.4.4, please confirm. Thanks!
José Rodríguez commented
It works!
Thank you.