metamodel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bobby (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (METAMODEL-116) Improve sqlite support
Date Thu, 12 Mar 2015 19:35:38 GMT

    [ https://issues.apache.org/jira/browse/METAMODEL-116?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14359228#comment-14359228
] 

Bobby commented on METAMODEL-116:
---------------------------------

Table with space test.
It fails in that test:
{code}
        //Check if table with spaces creation works
        CreateTable createTable = new CreateTable(schema, spacedTableName);
        createTable.withColumn("id").ofType(ColumnType.INTEGER);
        dc.executeUpdate(createTable);
{code}
with error: org.apache.metamodel.MetaModelException: Could not execute create table statement:
CREATE TABLE test table (id INTEGER): near "table": syntax error

{code:title=SqliteTest.java|borderStyle=solid}
    public void testSpacedTable() throws Exception{
        Connection connection = _connection;

        assertNotNull(connection);

        String spacedTableName = "test table";
        try {
            // clean up, if nescesary
            connection.createStatement().execute("DROP TABLE \"" + spacedTableName + "\"");
        } catch (SQLException e) {
            // do nothing
        }

        assertFalse(connection.isReadOnly());

        JdbcDataContext dc = new JdbcDataContext(connection);
        final Schema schema = dc.getDefaultSchema();

        //Check if table with spaces creation works
        CreateTable createTable = new CreateTable(schema, spacedTableName);
        createTable.withColumn("id").ofType(ColumnType.INTEGER);
        dc.executeUpdate(createTable);

        dc.refreshSchemas();

        //Check if table name is not quoted and with space, like original one
        Table testTable = schema.getTableByName(spacedTableName);
        Assert.assertNotNull(testTable);
        Assert.assertEquals(1, testTable.getColumnCount());
        Assert.assertEquals(ColumnType.INTEGER, testTable.getColumnByName("id").getType());

        //Check if table with spaces query works
        DataSet dataSet = dc.executeQuery(dc.query().from(testTable).selectAll().toQuery());
        Assert.assertTrue(dataSet.toRows().isEmpty());

        connection.createStatement().execute("DROP TABLE \"" + spacedTableName + "\"");
    }
{code}

> Improve sqlite support
> ----------------------
>
>                 Key: METAMODEL-116
>                 URL: https://issues.apache.org/jira/browse/METAMODEL-116
>             Project: Apache MetaModel
>          Issue Type: Improvement
>    Affects Versions: 4.3.0-incubating
>            Reporter: Bobby
>
> The following features are not correctly handled by default QueryRewriter for sqlite
:
> - Text and Blob SQL types are considered as VARCHAR
> 1. Create a table with Text and Blob columns
> 2. Get column list and check each column JDBC type: columns of type Text and Blob are
recognized as VARCHAR
> - Query maxRows works, but returns (maxRows + 1) rows
> 1. Create a table with at least 3 rows
> 2. Query this table with maxRows set to 1 : 2 rows are returned
> 3. Query this table with maxRows set to 2 : 3 rows are returned
> - Table names are not escaped properly when needed
> 1. Create a table with name "Test table"
> 2. Get table list: "Test table" is correctly returned
> 3. Query this table: SQL error [SQLITE_ERROR] SQL error or missing database (near "table":
syntax error)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message