Question

I recently modified a MYSQL query using the keyword RLIKE however when I ran the unit test which uses HSQLDB in order to mock a database it throws an unknown SQL token exception.

In order to resolve this currently I have commented out these tests, but would like to find a work around so I can actually test my code.

My google-fu failed to result in a solution as HSQLDB documentation seems lacking, any help would be appreciated.

Was it helpful?

Solution

I think the moral of this story is: Run your tests with the same software stack as you intend to deploy.

If you test in a different environment, your tests might pass but your app fail in production - this is bad.

OTHER TIPS

RLIKE is a non-standard operator and HSQL does not support it. If you want to continue your testing with HSQL, you will have to rewrite your query using LIKE statements or some other standard method. Alternatively, you could mock the database interaction using e.g. dbunit.

The equivalent in HSQLDB 2.0 is the function

REGEXP_MATCHES ( , )

and the usage is

SELECT ... WHERE REGEXP_MATCHES( mystring, regexpr)

The latest Hibernate 3.5.5 supports HSLQDB 2.0

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top