Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H2Data cannot cope with periods in column names #20

Closed
mentiflectax opened this issue Jan 3, 2015 · 2 comments
Closed

H2Data cannot cope with periods in column names #20

mentiflectax opened this issue Jan 3, 2015 · 2 comments

Comments

@mentiflectax
Copy link

If you use H2Data with column names with dots such as user.urn, domain.name, domain.key etc. in a unit test like com.s3auth.hosts.DefaultDynamoTest#loadsDynamoConfiguration

    public void loadsDynamoConfiguration() throws Exception {
        final H2Data data = new H2Data().with(
            TABLE,
            new String[]
            {
                DefaultDynamo.USER,
            },
            new String[]
            {
                DefaultDynamo.NAME,
                DefaultDynamo.KEY,
                DefaultDynamo.SECRET,
                DefaultDynamo.REGION,
                DefaultDynamo.BUCKET,
                DefaultDynamo.SYSLOG,
            }
        );
        for (int num = 0; num < Tv.TWENTY; ++num) {
            data.put(
                TABLE,
                new Attributes(
                    this.item()
                )
            );
        }
        final Region region = new MkRegion(data);
        final RegionCreator regionCreator = Mockito.mock(RegionCreator.class);
        Mockito.when(regionCreator.createRegion()).thenReturn(region);
        final DefaultDynamo dynamo = new DefaultDynamo(
            regionCreator, TABLE
        );
        final int size = dynamo.load().size();
        MatcherAssert.assertThat(
            dynamo.load().size(),
            Matchers.is(size)
        );
        dynamo.add(new URN("urn:test:alpha"), new DomainMocker().mock());
        MatcherAssert.assertThat(
            dynamo.load().size(),
            Matchers.is(size + 1)
        );
        dynamo.close();
    }

then during the test run you get an exception like this:

[[0;31mERROR[m] com.jcabi.jdbc.JdbcSession: #execute(): thrown java.sql.SQLException(org.h2.jdbc.JdbcSQLException: Unbekannter Datentyp: "."
Unknown data type: "."; SQL statement:
CREATE TABLE table (user.urn VARCHAR PRIMARY KEY,domain.name CLOB,domain.key CLOB,domain.secret CLOB,domain.region CLOB,domain.bucket CLOB,domain.syslog CLOB) [50004-176]) out of com.jcabi.jdbc.JdbcSession#run[418] in 732ms

java.io.IOException: java.sql.SQLException: org.h2.jdbc.JdbcSQLException: Unbekannter Datentyp: "."
Unknown data type: "."; SQL statement:
CREATE TABLE table (user.urn VARCHAR PRIMARY KEY,domain.name CLOB,domain.key CLOB,domain.secret CLOB,domain.region CLOB,domain.bucket CLOB,domain.syslog CLOB) [50004-176]
    at com.jcabi.dynamo.mock.H2Data.with_aroundBody6(H2Data.java:291)
    at com.jcabi.dynamo.mock.H2Data$AjcClosure7.run(H2Data.java:1)
    at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
    at com.jcabi.aspects.aj.MethodLogger.wrap(MethodLogger.java:212)
    at com.jcabi.aspects.aj.MethodLogger.ajc$inlineAccessMethod$com_jcabi_aspects_aj_MethodLogger$com_jcabi_aspects_aj_MethodLogger$wrap(MethodLogger.java:1)
    at com.jcabi.aspects.aj.MethodLogger.wrapClass(MethodLogger.java:136)
    at com.jcabi.dynamo.mock.H2Data.with(H2Data.java:269)
    at com.s3auth.hosts.DefaultDynamoTest.loadsDynamoConfiguration(DefaultDynamoTest.java:68)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:65)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.sql.SQLException: org.h2.jdbc.JdbcSQLException: Unbekannter Datentyp: "."
Unknown data type: "."; SQL statement:
CREATE TABLE table (user.urn VARCHAR PRIMARY KEY,domain.name CLOB,domain.key CLOB,domain.secret CLOB,domain.region CLOB,domain.bucket CLOB,domain.syslog CLOB) [50004-176]
    at com.jcabi.jdbc.JdbcSession.run(JdbcSession.java:418)
    at com.jcabi.jdbc.JdbcSession.execute_aroundBody12(JdbcSession.java:329)
    at com.jcabi.jdbc.JdbcSession$AjcClosure13.run(JdbcSession.java:1)
    at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
    at com.jcabi.aspects.aj.MethodLogger.wrap(MethodLogger.java:212)
    at com.jcabi.aspects.aj.MethodLogger.ajc$inlineAccessMethod$com_jcabi_aspects_aj_MethodLogger$com_jcabi_aspects_aj_MethodLogger$wrap(MethodLogger.java:1)
    at com.jcabi.aspects.aj.MethodLogger.wrapClass(MethodLogger.java:136)
    at com.jcabi.jdbc.JdbcSession.execute(JdbcSession.java:329)
    at com.jcabi.dynamo.mock.H2Data.with_aroundBody6(H2Data.java:289)
    ... 33 more
Caused by: org.h2.jdbc.JdbcSQLException: Unbekannter Datentyp: "."
Unknown data type: "."; SQL statement:
CREATE TABLE table (user.urn VARCHAR PRIMARY KEY,domain.name CLOB,domain.key CLOB,domain.secret CLOB,domain.region CLOB,domain.bucket CLOB,domain.syslog CLOB) [50004-176]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:344)
    at org.h2.message.DbException.get(DbException.java:178)
    at org.h2.message.DbException.get(DbException.java:154)
    at org.h2.command.Parser.parseColumnWithType(Parser.java:3963)
    at org.h2.command.Parser.parseColumnForTable(Parser.java:3826)
    at org.h2.command.Parser.parseCreateTable(Parser.java:5723)
    at org.h2.command.Parser.parseCreate(Parser.java:4122)
    at org.h2.command.Parser.parsePrepared(Parser.java:351)
    at org.h2.command.Parser.parse(Parser.java:306)
    at org.h2.command.Parser.parse(Parser.java:278)
    at org.h2.command.Parser.prepareCommand(Parser.java:243)
    at org.h2.engine.Session.prepareLocal(Session.java:442)
    at org.h2.engine.Session.prepareCommand(Session.java:384)
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1188)
    at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:73)
    at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:276)
    at com.jcabi.jdbc.JdbcSession$3.statement(JdbcSession.java:341)
    at com.jcabi.jdbc.JdbcSession.run(JdbcSession.java:398)
    ... 41 more

[[0;31mERROR[m] com.jcabi.dynamo.mock.H2Data: #with('table', ['user.urn'], ['domain.name', 'domain.key', 'domain.secret', 'domain.region', 'domain.bucket', 'domain.syslog']): thrown java.io.IOException(java.sql.SQLException: org.h2.jdbc.JdbcSQLException: Unbekannter Datentyp: "."
Unknown data type: "."; SQL statement:
CREATE TABLE table (user.urn VARCHAR PRIMARY KEY,domain.name CLOB,domain.key CLOB,domain.secret CLOB,domain.region CLOB,domain.bucket CLOB,domain.syslog CLOB) [50004-176]) out of com.jcabi.dynamo.mock.H2Data#with_aroundBody6[291] in 5s

Please make sure that jcabi-dynamo can work with column names that contain periods (e. g. by replacing the periods by dots transparently to the user).

@carlosmiranda
Copy link

Duplicate of #7.

@yegor256
Copy link
Member

yegor256 commented Jan 4, 2015

yes, it's definitely a duplicate of #7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants