db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergio Cruz (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DDLUTILS-275) platform.readModelFromDatabase(name) is not working if one of the table names contains underscore.
Date Mon, 09 Apr 2012 11:33:20 GMT

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

Sergio Cruz commented on DDLUTILS-275:
--------------------------------------

Hi Masker.
Of course I tested before but I think I didn't explain myself correctly.

Here it goes:

I have checked out from Subversion both revisions: trunk and tag 1.0

- http://svn.apache.org/repos/asf/db/ddlutils/trunk/
- http://svn.apache.org/repos/asf/db/ddlutils/tags/1.0/

I have created the bin distros via "ant bin-archive" for both revisions just to get the complete
packages with all the nedded dependencies.

I have created a mysql db called test_db:

DROP DATABASE IF EXISTS test_db;
CREATE DATABASE test_db;
USE test_db;
CREATE TABLE `test_table` (`col_bit` TINYINT(1));

I use the same ant script to dump the ddl with this task.

    <target name="database-dump" description="DDL Dump">
        <taskdef name="databaseToDdl" classname="org.apache.ddlutils.task.DatabaseToDdlTask">
            <classpath refid="runtime-classpath"/>
        </taskdef>
        <echo message="jdbc:mysql://${mysql.host.name}:${mysql.host.port}/${mysql.database.name}}"/>
        <databaseToDdl modelName="MyModel">
            <database   url="jdbc:mysql://${mysql.host.name}:${mysql.host.port}/${mysql.database.name}"
                        driverClassName="com.mysql.jdbc.Driver"
                        username="${mysql.user.name}"
                        password="${mysql.user.password}"/>
            <writeSchemaToFile outputFile="${ddlutils.struct.file.name}"/>
            <writeDataToFile outputFile="${ddlutils.data.file.name}"/>
        </databaseToDdl>
    </target>

After executing that script on both revisions I get the following output

Tag V-1.0
=========
~/tmp/apache-ddlutils/v-1.0 $ ant -propertyfile build.properties database-dump 
Buildfile: /home/scmoral/tmp/apache-ddlutils/v-1.0/build.xml

database-dump:
     [echo] jdbc:mysql://localhost:3306/test_db
[databaseToDdl] Written schema to /home/scmoral/tmp/apache-ddlutils/v-1.0/struct.xml
[databaseToDdl] Written data XML to file/home/scmoral/tmp/apache-ddlutils/v-1.0/data.xml

BUILD SUCCESSFUL
Total time: 2 seconds

The ddl file generated was as follows:

<?xml version="1.0"?>
<!DOCTYPE database SYSTEM "http://db.apache.org/torque/dtd/database">
  <database name="MyModel">
    <table name="test_table">
      <column name="col_bit" primaryKey="false" required="false" type="BIT" autoIncrement="false"/>
    </table>
  </database>

TRUNK
=======
~/tmp/apache-ddlutils/v-1.1 $ ant -propertyfile build.properties database-dump 
Buildfile: /home/scmoral/tmp/apache-ddlutils/v-1.1/build.xml

database-dump:
     [echo] jdbc:mysql://localhost:3306/test_db

BUILD FAILED
/home/scmoral/tmp/apache-ddlutils/v-1.1/build.xml:23: Could not read the schema from the specified
database: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'test_db.test\_table'
doesn't exist

Total time: 1 second

The same version of mysql jdbc driver was used for both tests (mysql-connector-java-5.1.18.jar)

Hope that helps.
                
> platform.readModelFromDatabase(name) is not working if one of the table names contains
underscore.
> --------------------------------------------------------------------------------------------------
>
>                 Key: DDLUTILS-275
>                 URL: https://issues.apache.org/jira/browse/DDLUTILS-275
>             Project: DdlUtils
>          Issue Type: Bug
>          Components: Core - MySql
>    Affects Versions: 1.1
>         Environment: Ubuntu 10.02, 64 bit, JDK 1.6.0_20, probably all others as well.
>            Reporter: Masker71
>            Assignee: Thomas Dudziak
>            Priority: Blocker
>              Labels: patch
>
> org.apache.ddlutils.platform.JdbcModelReader
> lines 859, 900, 1007
>             pkData = metaData.getPrimaryKeys(metaData.escapeForSearch(tableName));
>             fkData = metaData.getForeignKeys(metaData.escapeForSearch(tableName));
>             indexData = metaData.getIndices(metaData.escapeForSearch(tableName), false,
false);
> should be replaced to:
>             pkData = metaData.getPrimaryKeys(tableName);
>             fkData = metaData.getForeignKeys(tableName);
>             indexData = metaData.getIndices(tableName, false, false);
> According to MySQL 5 documentation "show create table" accepts table name, not table
name pattern.
> http://dev.mysql.com/doc/refman/5.0/en/show-create-table.html
> If any of the table names contain underline this line bombs:
> 		Database db = platform.readModelFromDatabase( "test" );

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message