-
Notifications
You must be signed in to change notification settings - Fork 360
unexpected behavior and inconsistency of get_last_query and actual query. #307
Copy link
Copy link
Closed
Description
Hi,
Assume I have a table named "mytable" which has the following fields:
id int(11) unsigned
uuid char(36)
deleted_by varchar(80)
When using idiorm and make a query like
$query = ORM::for_table('mytable')
->where_in('uuid', $uuid)
->where('deleted_by', '')
->find_many();
Assume $uuid = [false]
After execution, ORM::get_last_query() shows
SELECT * FROM `mytable` WHERE `uuid` IN ('') AND `deleted_by` = ''
However, when logging actual query from mysql, it shows
SELECT * FROM `mytable` WHERE `uuid` IN (0) AND `deleted_by` = ''
It becomes a disaster for me because I was actually selecting rows to be deleted. And it ends up deleting all my data. There are two issues in this situation:
- ORM::get_last_query() must be exactly the same query in mysql for debugging.
- I expect the query to be interpreted in the following ways:
SELECT * FROM `mytable` WHERE `uuid` IN ('') AND `deleted_by` = ''; // good
SELECT * FROM `mytable` WHERE `uuid` IN ('false') AND `deleted_by` = ''; // good, I guess
SELECT * FROM `mytable` WHERE `uuid` IN () AND `deleted_by` = ''; // fine, at least I know something is wrong.
SELECT * FROM `mytable` WHERE `uuid` IN (0) AND `deleted_by` = '' // unacceptable, because it gets all rows.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels