spock-dbunit icon indicating copy to clipboard operation
spock-dbunit copied to clipboard

org.dbunit.dataset.NoSuchTableException: abc

Open Kanti1702 opened this issue 7 years ago • 1 comments

I have below code in my spec file: @DbUnit(configure={ IDatabaseTester it -> it.setUpOperation = InsertIdentityOperation.REFRESH it.tearDownOperation = InsertIdentityOperation.DELETE }) def content = { abc(id:123, name:'test') }

This working finr in MySql, but when I try to run for MSSQL it gives org.dbunit.dataset.NoSuchTableException : abc error.

I have verified the 'abc' table is already there in MSSSQL database.

While debugging I have found that connection.getSchema() return "".

So how I can pass schema 'dbo' to @DbUnit extension?

I don't want to pass in every class @DBUnit(schema='dbo', configure......) like this.

Instead is it possible to get schema from field like we get datasource.

Kanti1702 avatar Oct 10 '17 13:10 Kanti1702

Hi @Kanti1702 , that's not possible yet and I also don't want to keep the plugin as simple enough and not depend on too many ways to get it working. So currently your only option is to ...

  • add the schema in the @dbunit annotation
  • deal with it on the datasource level. F.e. in most connection pools, you can specify a sql that is executed when the connection is first initialized f.e. in https://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/tomcat/jdbc/pool/DataSourceProxy.html#setInitSQL(java.lang.String) Hope this helps

janbols avatar Oct 18 '17 11:10 janbols