强制 DataMapper 断开与 postgresql 的连接
我有一个测试,正在 postgresql 中创建和销毁多个数据库。为了能够删除数据库,我需要告诉 DataMapper 断开连接。我似乎找不到任何有关如何执行此操作的文档。
DataMapper::Adapters::PostgresAdapter 上有一个 close_connection 方法,但它受到保护,并且需要一个我似乎无法获取的连接对象。
这可能吗?
I have a test that is creating and destroying a number of databases in postgresql. In order to be able to drop a database I need to tell DataMapper to disconnect. I can't seem to find any documentation on how to do that.
There is a close_connection method on DataMapper::Adapters::PostgresAdapter but it is protected and requires a connection object that I can't seem to get.
Is this even possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DataObjects::Pooling.pools.each {|池|只要您一次只打开一个连接,pool.dispose} 似乎就可以工作。
DataObjects::Pooling.pools.each {|pool| pool.dispose}
seems to work as long as you have only one connection open at a time.