模式名称用短划线/连字符i HyperSQL

时间:2021-07-21 16:49:37

I'm writing unittests for a legacy application that uses mysql directly as a datastorage.

我正在为使用mysql直接作为数据存储的遗留应用程序编写单元测试。

The approach we have descided on is to abstract out the database access to it's own layer, and dependency inject that. We will also write tests for that layer using hsqldb as a in memory database (for speed reasons).

我们已经确定的方法是抽象出对它自己的层的数据库访问,并且依赖注入它。我们还将使用hsqldb作为内存数据库为该层编写测试(出于速度原因)。

The current code use a schema that has a dash in it's name, and as far as i can figure out hypersql doesn't have any way to escape that?

当前代码使用的是一个名称中包含破折号的模式,据我所知,hypersql没有任何办法逃脱它?

Do I need to inject the schema name into the database layer, or is there some way to configure hsqldb to accept dashes?

我是否需要将模式名称注入数据库层,或者是否有某种方法可以将hsqldb配置为接受破折号?

1 个解决方案

#1


1  

Supposing your database access code is using something like SELECT * FROM schema-name.tablename, or SCHEMA-NAME.tablename with any character case variations, then you should use this with HyperSQL:

假设您的数据库访问代码使用SELECT * FROM schema-name.tablename或SCHEMA-NAME.tablename以及任何字符大小写变体,那么您应该将它与HyperSQL一起使用:

CREATE SCHEMA "SCHEMA-NAME" AUTHORIZATION DBA

and

SELECT * FROM "SCHEMA-NAME".tablename

If all your data is in the same schema, then you can simply set this schema as default and avoid using "SCHEMA-NAME" in SQL queries.

如果所有数据都在同一模式中,则只需将此模式设置为默认模式,并避免在SQL查询中使用“SCHEMA-NAME”。

#1


1  

Supposing your database access code is using something like SELECT * FROM schema-name.tablename, or SCHEMA-NAME.tablename with any character case variations, then you should use this with HyperSQL:

假设您的数据库访问代码使用SELECT * FROM schema-name.tablename或SCHEMA-NAME.tablename以及任何字符大小写变体,那么您应该将它与HyperSQL一起使用:

CREATE SCHEMA "SCHEMA-NAME" AUTHORIZATION DBA

and

SELECT * FROM "SCHEMA-NAME".tablename

If all your data is in the same schema, then you can simply set this schema as default and avoid using "SCHEMA-NAME" in SQL queries.

如果所有数据都在同一模式中,则只需将此模式设置为默认模式,并避免在SQL查询中使用“SCHEMA-NAME”。