使用HSQLDB测试日期值 [英] Testing date values with HSQLDB

查看:76
本文介绍了使用HSQLDB测试日期值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在生产中使用SQLServer,但在集成测试中使用HSQLDB.使用HSQLDB是因为它是内存数据库.

We use SQLServer in production, but HSQLDB for our integration tests. HSQLDB is used because it's an in-memory database.

我有一个执行以下代码的SQLServer SQL:

I have an SQLServer SQL that executes the following code:

select convert(varchar(8), pos_val_date, 112) 
from wscpos;

在HSQLDB中,这不起作用.该代码应为:

In HSQLDB, this does not work. The code should be:

select to_char( pos_val_date, 'YYYYMMDD')
from wscpos;

调整代码以使其同时在生产环境和集成测试中运行的最佳实践是什么?

What's the best practice to adapt my code such that it runs both in production and in my integration test?

推荐答案

如果您倾向于更改数据库以进行集成测试,建议您使用 MODE = MSSQLServer 采用H2,它应提供与MS SQL Server的兼容性更好,比HSQLDB现在提供的更好.

If you are inclined to change your DB for integration tests, I would recommend to adopt H2 using MODE=MSSQLServer which should provide a better compatibility against MS SQL Server, better than what HSQLDB gives you now.

这篇关于使用HSQLDB测试日期值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆