Omeka
Omeka copied to clipboard
Default support for "field IS NULL" condition
Problem:
echo get_db()->getTable('Item')->getSelectForFindBy(array('item_type_id' => null));
Expected:
SELECT items.* FROM items WHERE item_type_id IS NULL
Actual:
SELECT items.* FROM items WHERE item_type_id = ?
And then you get error, because null
is not passed as extra parameter into prepared statement.
I know, it won't fix calls like:
echo get_db()->getTable('Item')->getSelectForFindBy(array('item_type_id' => array(1, 2, null)));
Should I fix NULL in arrays as well? So it would produce SQL like: WHERE (item_type_id IN (1,2) OR item_type_id IS NULL)
?
I'm not 100% sure if this change doesn't break it for other Omeka users calling parent::applySearchFilters()
from their plugins, but I checked few plugins (ExhibitBuilder, SimplePages, HistoryLog) and it's OK.