db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sylvain Benoist (JIRA)" <j...@apache.org>
Subject [jira] Commented: (TORQUE-105) Column specification assumes NULL as implicit choice
Date Wed, 31 Oct 2007 15:50:51 GMT

    [ https://issues.apache.org/jira/browse/TORQUE-105?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12539106
] 

Sylvain Benoist commented on TORQUE-105:
----------------------------------------

Suggest overriding getNullString method in org.apache.torque.engine.platform.PlatformSybaseImpl,
or even DefaultPlatformImpl if this behavior should be applied consistently to all platforms.

public String getNullString(boolean notNull)
    {
        return (notNull ? "NOT NULL" : "NULL");
    }


What bothers me is that this implementation is no longer in sync with all the comments that
I have seen that indicate that the method returns an empty string for 'NULL' - this may break
code that tests for string length for example. 

> Column specification assumes NULL as implicit choice
> ----------------------------------------------------
>
>                 Key: TORQUE-105
>                 URL: https://issues.apache.org/jira/browse/TORQUE-105
>             Project: Torque
>          Issue Type: Bug
>          Components: Generator
>    Affects Versions: 3.3-RC2
>         Environment: Maven2 plugin, Torque 3.3-RC2 ; tested with Sybase 15.0.2 DEV Edition
Windows - should affect all Sybase
>            Reporter: Sylvain Benoist
>
> 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.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message