如何在使用bpchar的h2数据库中执行单元测试? [英] How to perform unit tests with h2 database where bpchar is used?
问题描述
我有一个使用postgres数据库的spring + hibernate应用程序.我需要为控制器编写单元测试.对于测试,我想使用h2数据库,但不幸的是,在create-drop期间测试崩溃,使我无法得知bpchar数据类型无效的信息.我想知道如何解决此问题,以便我可以运行测试.
I have a spring + hibernate application that uses postgres database. I need to write unit tests for the controllers. For tests I wanted to use h2 database but unfortunately test crashes during create-drop leaving me with information that bpchar data type is invalid. I wonder how to solve this issue so I could run tests.
我无法将bpchar的列更改为varchar,它需要保持原样.我也尝试设置postgresql模式,但没有帮助.我唯一的解决方案是使用嵌入式postgres数据库执行测试,还是我可以使用其他方法吗?
I can't change my columns with bpchar to varchar, it need to stay as it is. I also tried to set postgresql mode but it didn't helped. Am I right that the only solution I have is to use embedded postgres database in order to perform tests or is there any other approach that I could use?
推荐答案
我是对的,我唯一的解决方案是使用嵌入式postgres数据库来执行测试,或者还有其他方法可以使用吗?
Am I right that the only solution I have is to use embedded postgres database in order to perform tests or is there any other approach that I could use?
您尝试将特定于Postgres的数据类型与h2一起使用(没有).当然,这是行不通的.
You try to use postgres-specific data type with h2 (which does not have it). Of course, it does not work.
如果您无法更改此字段的类型,请在测试中使用嵌入式的postgres.
If you cannot change type of this field - use embedded postgres in tests.
这篇关于如何在使用bpchar的h2数据库中执行单元测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!