Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 0293add

Browse files
author
Michael Grauer
committed
BUG: refs #0326. Add an explicit case to deleting a linked feed, for pgsql.
Postgres will not automatically do the type conversion from integer to string, which causes a problem when we delete an item and we are trying to find feed rows that have as their ressource the deleted item's id. So for pgsql we must explicitly cast the itemId to a string, to match the varchar type of the ressource column in the feed table.
1 parent deaca3f commit 0293add

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

core/models/pdo/ItemModel.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,18 @@ function delete($itemdao)
305305
}
306306

307307
$deleteType = array(MIDAS_FEED_CREATE_ITEM, MIDAS_FEED_CREATE_LINK_ITEM);
308+
309+
310+
$itemDaoKey = $itemdao->getKey();
311+
// postgres will not do the necessary type conversion
312+
if(Zend_Registry::get('configDatabase')->database->adapter == 'PDO_PGSQL')
313+
{
314+
$itemDaoKey = (string)$itemDaoKey;
315+
}
308316
$sql = $this->database->select()
309317
->setIntegrityCheck(false)
310318
->from(array('p' => 'feed'))
311-
->where('ressource = ?', $itemdao->getKey());
312-
319+
->where('ressource = ?', $itemDaoKey);
313320
$rowset = $this->database->fetchAll($sql);
314321
$this->ModelLoader = new MIDAS_ModelLoader();
315322
$feed_model = $this->ModelLoader->loadModel('Feed');

0 commit comments

Comments
 (0)