在1.4号交响曲中工作,为我的ORM(不确定如何找到Propel版本)。
在对数据库中具有独特限制的物体进行单位测试时,I测试是否捕获例外:
try {
$room1a->save();
// Shouldn t have saved, so shouldn t have an id
$t->ok(!$room1a->getId(), "Failed to save duplicate room");
} catch (Exception $e) {
$t->ok($e, "Threw exception on creating duplicate room");
}
如果我纠正了重复的重复,再试一次,
$room1a->setCode( 1a );
$room1a->save();
$t->ok($room1a->getId()), "Saved this time");
我得到"无法获得序列代号":
PropelException: Unable to get sequence id. [wrapped:
SQLSTATE[25P02]: In failed sql transaction: 7 ERROR: current
transaction is aborted, commands ignored until end of transaction
block]
(in
lib/vendor/symfony/lib/plugins/sfPropelPlugin/lib/vendor/propel/util/BasePeer.php
on line 264)
我尝试过重塑对象(即一个新的房间对象)并保存它,结果相同;似乎在相关(?)方面有一个需要重塑的状态。
我找到的唯一办法 就是收回交易 开始新的交易