cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Øyvind Harboe (JIRA) <j...@apache.org>
Subject [jira] Commented: (CAY-1395) createSetAllowNullToDb() return incorrect SQL statement to createSql()
Date Wed, 24 Feb 2010 12:56:28 GMT

    [ https://issues.apache.org/jira/browse/CAY-1395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12837765#action_12837765
] 

Øyvind Harboe commented on CAY-1395:
------------------------------------

Without the kludge above, the SQL statement will be

ALTER xxxx NOT NULL 

instead of

ALTER XXXX NULL

as SetAllowNullToDb() invokes isMandatory() and isMandatory() returns true when converting
a DbAttribute to not mandatory.


>From JdbcAdapter.java:


sqlBuffer.append(column.isMandatory() ? " NOT NULL" : " NULL");

> createSetAllowNullToDb() return incorrect SQL statement to createSql()
> ----------------------------------------------------------------------
>
>                 Key: CAY-1395
>                 URL: https://issues.apache.org/jira/browse/CAY-1395
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 3.0RC2
>            Reporter: Øyvind Harboe
>             Fix For: 3.0
>
>
> The problem with createSql() is that it is executed *before* the property is changed.
> The following kludge to SQLServerManagerFactory.createSetAllowNullToDb() works on my
rocket...
>         return new SetAllowNullToDb(entity, column) {
>             @Override
>             public List<String> createSql(DbAdapter adapter) {
>                 StringBuffer sqlBuffer = new StringBuffer();
>                 QuotingStrategy context = adapter.getQuotingStrategy(getEntity()
>                         .getDataMap()
>                         .isQuotingSQLIdentifiers());
>                 sqlBuffer.append("ALTER TABLE ");
>                 sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
>                 sqlBuffer.append(" ALTER COLUMN ");
>                 /* Kludge!!!! how should this be handled really??? */
>                 column.setMandatory(false);
>                 adapter.createTableAppendColumn(sqlBuffer, column);
>                 return Collections.singletonList(sqlBuffer.toString());
>             }

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


Mime
View raw message