ArtB ArtB - 11 days ago 7
Java Question

How to support support SqlServer's ".." in HyperSQL?

tl;dr: I am trying to unit test some SqlServer queries which state the db name but they do not seem to work in HyperSql.




We are using Sql Server in production and I am trying to use HyperSQL as my database for unit testing. I am trying to test a class that creates SQL queries so stubbing out the database is not an option as having the queries parsed by a real database is part of the test.

Queries are supposed to be created in the form of
SELECT * FROM EntAsdfDb007..Data_Table
, although we can use the schema name ( 'db' ) if we wish.

From what I understand about the SELECT format for SqlServer, it allows you to specify the name of database followed by the name of schema. Also, you can drop the name of the database and have it inferred.

In HyperSqlDb I have been able to create the schema 'db' and create the necessary tables within it, and have been able to create tables within that schema but I have not be able to query with the database name even after setting the DB name using
.setDatabaseName()
. The exception I get is:

Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: ENTASDFDB007


Just to be clear: I am unit-testing a class that uses SQL like
SELECT * FROM EntAsdfDb007..Data_Table
. I am trying to set up an instance of HyperSql for unit testing purposes but HyperSql seems to reject the syntax used.

Answer

That won't be possible.

HyperSQL cannot be changed to accept non-standard naming schemes.

Comments