在处理更新我的数据库的某些函数时,我正在编写一些快速测试,以确保我的函数正确执行。当谈到时间,实际更新数据库,我可以在事务传递给函数,然后将其提交:如何查看SQL事务中的挂起更改?
user.Assignment("assignment value for some column in table", connection, transaction)
transaction.Commit()
我很好奇,如果有写一个快速测试,可以验证的方式,该交易将实际在提交之前更新某些行?
(pseudoish代码)
user.Assignment("assignment value for some column in table", connection, transaction)
If Not transaction["SomeColumn"] = "Expected value for SomeColumn"
assert("ColumnName was not going to be updated to the expected value!")
transaction.Rollback()
保持您的交易快速/快速,在您进行修改之前/之前进行检查,而不在之后,如果您确实需要这些修改,请使用OUTPUT返回任何更改。 – 2012-03-07 20:24:39
我已经做了所有这些。这实际上不是什么问题,但如果可能的话更是如此。什么是“输出”? – afuzzyllama 2012-03-07 20:32:00
如果你还在交易中,你应该*只能查询它......? – 2012-03-07 20:41:14