事务与截断数据库清理器
最近,我的黄瓜场景之一遇到了问题。当该功能运行时,我的测试数据库中的某些条目消失了。 来解决问题
DatabaseCleaner.strategy = :transaction
我通过将线路更改为
DatabaseCleaner.strategy = :truncation
我不确定为什么有帮助 。数据库清理程序 gem 网页上有一个表格,但它并没有真正说明这两个术语的含义。任何有助于理解这两个概念之间差异的帮助都会很棒。
Recently I had a problem with one of my cucumber scenarios. Certain entries in my test database were disappearing whilst the feature was running. I solved the problem by changing the line
DatabaseCleaner.strategy = :transaction
to
DatabaseCleaner.strategy = :truncation
I'm not sure why that helped. There is a table on the database cleaners gem webpage, but it dosen't really say what the two terms mean. Any help on understanding the difference between the two concepts would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
用一种非常简单的方式来说:截断会从数据库中删除所有数据,事务会回滚运行场景所做的所有更改。
Putting it in a very simple way: truncation removes all data from the database and transaction rollbacks all changes that has been made by the running scenario.
截断删除了离开数据库结构的数据,事务主要回滚数据库操作,这是最快的策略。最后一项是删除。删除是删除数据并移除数据库的结构,它是最慢但最安全的。
您还可以检查截断、事务和删除数据库策略之间的差异
Truncation removes the data leaving the database structure, transaction majorly rollback the database operation and it is the fastest strategy. And there is the last one which is deletion. Deletion deletes the data and removes the structure of the database, it is the slowest but safest.
You can also check Difference between truncation, transaction and deletion database strategies