Uploaded image for project: 'Torque'
  1. Torque
  2. TORQUE-105

Column specification assumes NULL as implicit choice

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.3-RC2
    • 3.3-RC3
    • Generator
    • None
    • Maven2 plugin, Torque 3.3-RC2 ; tested with Sybase 15.0.2 DEV Edition Windows - should affect all Sybase

    Description

      When defining a column in a table with the Torque XML model, the assumption is that if the 'required' attribute is not present, or false, then the column is produced with no explicit NULL/ NOT NULL text. This leaves the door open to database specific behaviors.

      For example, Sybase... see http://manuals.sybase.com/onlinebooks/group-as/asg1250e/svrtsg/@Generic__BookTextView/15380.
      It says that by default, Sybase assumes that a column without an explicit NULL or NOT NULL will be translated into a NOT NULL.

      This means that from the following XML snippet :

      <table name="country" description="Country data">
      <column name="country_id" domain="dm_CountryId" required="true" primaryKey="true" />
      <column name="country_name" domain="dm_GenericName30" required="true" />
      <column name="iso_source" domain="dm_Boolean" required="true" />
      <column name="iso_threechar_code" type="CHAR" size="3" required="false" />
      <column name="iso_numeric_code" type="INTEGER" required="false"/>
      <column name="active" domain="dm_Boolean" required="true" />
      </table>

      I end up with the following DDL :

      CREATE TABLE country
      (
      country_id CHAR (2) NOT NULL,
      country_name VARCHAR (30) NOT NULL,
      iso_source CHAR (1) default 'Y' NOT NULL,
      iso_threechar_code CHAR (3),
      iso_numeric_code INT,
      active CHAR (1) default 'Y' NOT NULL,
      CONSTRAINT country_PK PRIMARY KEY(country_id)
      )
      go

      And Sybase default this to have all columns as NOT NULL, which is not what I specified in my XML.

      To avoid being dependent on a database configuration option, it would be better to make things completely explicit, so that
      when the 'required' XML attribute is either absent or false, the generated DDL specifies 'NULL' instead of an empty string.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sbenoist Sylvain Benoist
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: