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 17:21:39 GMT

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

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

Hi Kasper,

Here is a test method I added to SqliteTest (not committed) to check firstRow and maxRows
in Sqlite.

Bobby

    public void testFirstMaxRows() throws Exception {
        Connection connection = _connection;

        assertNotNull(connection);

        try {
            // clean up, if nescesary
            connection.createStatement().execute("DROP TABLE test_table");
        } catch (SQLException e) {
            // do nothing
        }

        assertFalse(connection.isReadOnly());

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

        CreateTable createTable = new CreateTable(schema, "test_table");
        createTable.withColumn("id").ofType(ColumnType.INTEGER);
        dc.executeUpdate(createTable);

        dc.refreshSchemas();

        Table testTable = schema.getTableByName("test_table");
        Assert.assertNotNull(testTable);
        Assert.assertEquals(1, testTable.getColumnCount());
        Assert.assertEquals(ColumnType.INTEGER, testTable.getColumnByName("id").getType());

        for (int i = 1; i <= 10; i++) {
            dc.executeUpdate(new InsertInto(testTable).value("id", i));
        }

        DataSet dataSet;
        //check if 10 rows were correctly inserted
        dataSet = dc.executeQuery(dc.query().from(testTable).selectAll().toQuery());
        Assert.assertEquals(10, dataSet.toRows().size());

        //check if firstRow is correctly interpreted
        dataSet = dc.executeQuery(dc.query().from(testTable).selectAll().firstRow(2).toQuery());
        Assert.assertEquals(9, dataSet.toRows().size());

        //check if maxRows is correctly interpreted
        int maxRows = 3;
        dataSet = dc.executeQuery(dc.query().from(testTable).selectAll().maxRows(maxRows).toQuery());
        Assert.assertEquals(maxRows, dataSet.toRows().size());

        connection.createStatement().execute("DROP TABLE test_table");
    }


> 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