Uploaded image for project: 'DdlUtils'
  1. DdlUtils
  2. DDLUTILS-178

ModelException thrown when reading columns with "special" names

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Cannot Reproduce
    • 1.0 RC2
    • 1.1
    • Core - PostgreSql
    • None
    • PostgreSQL 8.2 on Ubuntu 7.04. Java 6.

    Description

      Trying to execute the method "readModelFromDatabase" a ModelException is thrown. The database has only one table with a field named "year". If this field is renamed by another name it works ok. The field "year" appears in the pgAdmin tool with quotes. This must be the reason why DDLutils throws the ModelException.

      This is the exception thrown:

      org.apache.ddlutils.model.ModelException: The index ad_sequence_no_key in table ad_sequence_no references the undefined column "year"
      at org.apache.ddlutils.model.Database.initialize(Database.java:393)
      at org.apache.ddlutils.platform.JdbcModelReader.getDatabase(JdbcModelReader.java:484)
      at org.apache.ddlutils.platform.JdbcModelReader.getDatabase(JdbcModelReader.java:432)
      at org.apache.ddlutils.platform.PlatformImplBase.readModelFromDatabase(PlatformImplBase.java:1884)
      at org.apache.ddlutils.platform.PlatformImplBase.readModelFromDatabase(PlatformImplBase.java:1869)
      at org.openbravo.ddl.Test.main(Test.java:52)

      The database was previously populated with the following XML::

      <?xml version="1.0"?>
      <!DOCTYPE database SYSTEM "http://db.apache.org/torque/dtd/database">
      <database name="openbravo-tests">
      <table name="ad_sequence_no">
      <column name="ad_sequence_id" primaryKey="false" required="true" type="NUMERIC" size="10" autoIncrement="false"/>
      <column name="year" primaryKey="false" required="true" type="VARCHAR" size="4" default="0000" autoIncrement="false"/>
      <column name="ad_client_id" primaryKey="false" required="true" type="NUMERIC" size="10" autoIncrement="false"/>
      <unique name="ad_sequence_no_key">
      <unique-column name="ad_sequence_id"/>
      <unique-column name="year"/>
      </unique>
      </table>
      </database>

      And in the pgAdmin tool, the table definition is:

      – Table: ad_sequence_no

      – DROP TABLE ad_sequence_no;

      CREATE TABLE ad_sequence_no
      (
      ad_sequence_id numeric(10) NOT NULL,
      "year" varchar(4) NOT NULL DEFAULT '0000'::character varying,
      ad_client_id numeric(10) NOT NULL
      )
      WITHOUT OIDS;
      ALTER TABLE ad_sequence_no OWNER TO tad;

      – Index: ad_sequence_no_key

      – DROP INDEX ad_sequence_no_key;

      CREATE UNIQUE INDEX ad_sequence_no_key
      ON ad_sequence_no
      USING btree
      (ad_sequence_id, "year");

      Attachments

        1. remove-quotes.patch
          1 kB
          Adrián Romero

        Activity

          People

            tomdz Thomas Dudziak
            adrianopenbravo Adrián Romero
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: