cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r746521 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne: dba/derby/ dba/h2/ dba/hsqldb/ dba/mysql/ dba/postgres/ dba/sqlserver/ merge/
Date Sat, 21 Feb 2009 14:57:05 GMT
Author: aadamchik
Date: Sat Feb 21 14:57:04 2009
New Revision: 746521

URL: http://svn.apache.org/viewvc?rev=746521&view=rev
Log:
CAY-289 Implement Quoting of identifiers

patch by Olga Tkachova - support for quoting in the merge package

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/derby/DerbyMergerFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/h2/H2MergerFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLMergerFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLMergerFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresMergerFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerMergerFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddColumnToDb.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DbMerger.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropColumnToDb.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropRelationshipToDb.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetAllowNullToDb.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetColumnTypeToDb.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetNotNullToDb.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/derby/DerbyMergerFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/derby/DerbyMergerFactory.java?rev=746521&r1=746520&r2=746521&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/derby/DerbyMergerFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/derby/DerbyMergerFactory.java
Sat Feb 21 14:57:04 2009
@@ -22,6 +22,7 @@
 import java.util.List;
 
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.merge.MergerFactory;
@@ -41,12 +42,12 @@
         return new SetColumnTypeToDb(entity, columnOriginal, columnNew) {
 
             @Override
-            protected void appendPrefix(StringBuffer sqlBuffer) {
+            protected void appendPrefix(StringBuffer sqlBuffer, QuotingStrategy context)
{
                 // http://db.apache.org/derby/manuals/reference/sqlj26.html
                 sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(entity.getFullyQualifiedName());
+                sqlBuffer.append(context.quoteFullyQualifiedName(entity));
                 sqlBuffer.append(" ALTER ");
-                sqlBuffer.append(columnNew.getName());
+                sqlBuffer.append(context.quoteString(columnNew.getName()));
                 sqlBuffer.append(" SET DATA TYPE ");
             }
         };
@@ -59,11 +60,13 @@
             @Override
             public List<String> createSql(DbAdapter adapter) {
                 StringBuilder sqlBuffer = new StringBuilder();
-
+                QuotingStrategy context = adapter.getQuotingStrategy(getEntity()
+                        .getDataMap()
+                        .isQuotingSQLIdentifiers());
                 sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(getEntity().getFullyQualifiedName());
+                sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
                 sqlBuffer.append(" ALTER COLUMN ");
-                sqlBuffer.append(getColumn().getName());
+                sqlBuffer.append(context.quoteString(getColumn().getName()));
                 sqlBuffer.append(" NOT NULL");
 
                 return Collections.singletonList(sqlBuffer.toString());
@@ -79,11 +82,13 @@
             @Override
             public List<String> createSql(DbAdapter adapter) {
                 StringBuilder sqlBuffer = new StringBuilder();
-
+                QuotingStrategy context = adapter.getQuotingStrategy(getEntity()
+                        .getDataMap()
+                        .isQuotingSQLIdentifiers());
                 sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(getEntity().getFullyQualifiedName());
+                sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
                 sqlBuffer.append(" ALTER COLUMN ");
-                sqlBuffer.append(getColumn().getName());
+                sqlBuffer.append(context.quoteString(getColumn().getName()));
                 sqlBuffer.append(" NULL");
 
                 return Collections.singletonList(sqlBuffer.toString());

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/h2/H2MergerFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/h2/H2MergerFactory.java?rev=746521&r1=746520&r2=746521&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/h2/H2MergerFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/h2/H2MergerFactory.java
Sat Feb 21 14:57:04 2009
@@ -23,6 +23,7 @@
 import java.util.List;
 
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.merge.MergerFactory;
@@ -43,11 +44,11 @@
         return new SetColumnTypeToDb(entity, columnOriginal, columnNew) {
 
             @Override
-            protected void appendPrefix(StringBuffer sqlBuffer) {
+            protected void appendPrefix(StringBuffer sqlBuffer, QuotingStrategy context)
{
                 sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(entity.getFullyQualifiedName());
+                sqlBuffer.append(context.quoteFullyQualifiedName(entity));
                 sqlBuffer.append(" ALTER ");
-                sqlBuffer.append(columnNew.getName());
+                sqlBuffer.append(context.quoteString(columnNew.getName()));
                 sqlBuffer.append(" ");
             }
         };

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLMergerFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLMergerFactory.java?rev=746521&r1=746520&r2=746521&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLMergerFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLMergerFactory.java
Sat Feb 21 14:57:04 2009
@@ -22,6 +22,7 @@
 import java.util.List;
 
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.merge.MergerFactory;
@@ -40,11 +41,11 @@
         return new SetColumnTypeToDb(entity, columnOriginal, columnNew) {
 
             @Override
-            protected void appendPrefix(StringBuffer sqlBuffer) {
+            protected void appendPrefix(StringBuffer sqlBuffer, QuotingStrategy context)
{
                 sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(entity.getFullyQualifiedName());
+                sqlBuffer.append(context.quoteFullyQualifiedName(entity));
                 sqlBuffer.append(" ALTER ");
-                sqlBuffer.append(columnNew.getName());
+                sqlBuffer.append(context.quoteString(columnNew.getName()));
                 sqlBuffer.append(" ");
             }
         };
@@ -57,11 +58,13 @@
             @Override
             public List<String> createSql(DbAdapter adapter) {
                 StringBuilder sqlBuffer = new StringBuilder();
-
+                QuotingStrategy context = adapter.getQuotingStrategy(getEntity()
+                        .getDataMap()
+                        .isQuotingSQLIdentifiers());
                 sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(getEntity().getFullyQualifiedName());
+                sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
                 sqlBuffer.append(" ALTER COLUMN ");
-                sqlBuffer.append(getColumn().getName());
+                sqlBuffer.append(context.quoteString(getColumn().getName()));
                 sqlBuffer.append(" NULL");
 
                 return Collections.singletonList(sqlBuffer.toString());

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLMergerFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLMergerFactory.java?rev=746521&r1=746520&r2=746521&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLMergerFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLMergerFactory.java
Sat Feb 21 14:57:04 2009
@@ -22,6 +22,7 @@
 import java.util.List;
 
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
@@ -43,14 +44,15 @@
             public List<String> createSql(DbAdapter adapter) {
                 StringBuffer sqlBuffer = new StringBuffer();
 
+                QuotingStrategy context = adapter.getQuotingStrategy(getEntity()
+                        .getDataMap()
+                        .isQuotingSQLIdentifiers());
+                
                 sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(getEntity().getFullyQualifiedName());
+                sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
                 sqlBuffer.append(" CHANGE ");
-                sqlBuffer.append(getColumn().getName());
+                sqlBuffer.append(context.quoteString(getColumn().getName()));
                 sqlBuffer.append(" ");
-                sqlBuffer.append(getColumn().getName());
-                sqlBuffer.append(" ");
-
                 adapter.createTableAppendColumn(sqlBuffer, column);
 
                 return Collections.singletonList(sqlBuffer.toString());
@@ -68,12 +70,12 @@
         return new SetColumnTypeToDb(entity, columnOriginal, columnNew) {
 
             @Override
-            protected void appendPrefix(StringBuffer sqlBuffer) {
+            protected void appendPrefix(StringBuffer sqlBuffer, QuotingStrategy context)
{
                 // http://dev.mysql.com/tech-resources/articles/mysql-cluster-50.html
                 sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(entity.getFullyQualifiedName());
+                sqlBuffer.append(context.quoteFullyQualifiedName(entity));
                 sqlBuffer.append(" MODIFY ");
-                sqlBuffer.append(columnNew.getName());
+                sqlBuffer.append(context.quoteString(columnNew.getName()));
                 sqlBuffer.append(" ");
             }
 
@@ -94,11 +96,13 @@
                 if (fkName == null) {
                     return Collections.emptyList();
                 }
-
+                QuotingStrategy context = adapter.getQuotingStrategy(getEntity()
+                        .getDataMap()
+                        .isQuotingSQLIdentifiers());
                 StringBuilder buf = new StringBuilder();
                 // http://dev.mysql.com/tech-resources/articles/mysql-cluster-50.html
                 buf.append("ALTER TABLE ");
-                buf.append(entity.getFullyQualifiedName());
+                buf.append(context.quoteFullyQualifiedName(entity));
                 buf.append(" DROP FOREIGN KEY ");
                 buf.append(fkName);
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresMergerFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresMergerFactory.java?rev=746521&r1=746520&r2=746521&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresMergerFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresMergerFactory.java
Sat Feb 21 14:57:04 2009
@@ -18,6 +18,7 @@
  ****************************************************************/
 package org.apache.cayenne.dba.postgres;
 
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.merge.MergerFactory;
@@ -35,12 +36,12 @@
         return new SetColumnTypeToDb(entity, columnOriginal, columnNew) {
 
             @Override
-            protected void appendPrefix(StringBuffer sqlBuffer) {
+            protected void appendPrefix(StringBuffer sqlBuffer, QuotingStrategy context)
{
                 // http://www.postgresql.org/docs/8.2/static/sql-altertable.html
                 sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(entity.getFullyQualifiedName());
+                sqlBuffer.append(context.quoteFullyQualifiedName(entity));
                 sqlBuffer.append(" ALTER ");
-                sqlBuffer.append(columnNew.getName());
+                sqlBuffer.append(context.quoteString(columnNew.getName()));
                 sqlBuffer.append(" TYPE ");
             }
         };

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerMergerFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerMergerFactory.java?rev=746521&r1=746520&r2=746521&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerMergerFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerMergerFactory.java
Sat Feb 21 14:57:04 2009
@@ -22,6 +22,7 @@
 import java.util.List;
 
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.merge.AddColumnToDb;
@@ -42,12 +43,12 @@
         return new SetColumnTypeToDb(entity, columnOriginal, columnNew) {
 
             @Override
-            protected void appendPrefix(StringBuffer sqlBuffer) {
+            protected void appendPrefix(StringBuffer sqlBuffer, QuotingStrategy context)
{
                 // http://msdn2.microsoft.com/en-us/library/ms190273.aspx
                 sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(entity.getFullyQualifiedName());
+                sqlBuffer.append(context.quoteFullyQualifiedName(entity));
                 sqlBuffer.append(" ALTER COLUMN ");
-                sqlBuffer.append(columnNew.getName());
+                sqlBuffer.append(context.quoteString(columnNew.getName()));
                 sqlBuffer.append(" ");
             }
         };
@@ -58,17 +59,17 @@
         return new AddColumnToDb(entity, column) {
 
             @Override
-            protected void appendPrefix(StringBuffer sqlBuffer) {
+            protected void appendPrefix(StringBuffer sqlBuffer, QuotingStrategy context)
{
                 // http://msdn2.microsoft.com/en-us/library/ms190273.aspx
                 sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(entity.getFullyQualifiedName());
+                sqlBuffer.append(context.quoteFullyQualifiedName(entity));
                 sqlBuffer.append(" ADD ");
-                sqlBuffer.append(column.getName());
+                sqlBuffer.append(context.quoteString(column.getName()));
                 sqlBuffer.append(" ");
             }
         };
     }
-    
+
     @Override
     public MergerToken createSetAllowNullToDb(DbEntity entity, final DbAttribute column)
{
         return new SetAllowNullToDb(entity, column) {
@@ -77,9 +78,12 @@
             public List<String> createSql(DbAdapter adapter) {
                 StringBuffer sqlBuffer = new StringBuffer();
 
+                QuotingStrategy context = adapter.getQuotingStrategy(getEntity()
+                        .getDataMap()
+                        .isQuotingSQLIdentifiers());
 
                 sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(getEntity().getFullyQualifiedName());
+                sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
                 sqlBuffer.append(" ALTER COLUMN ");
 
                 adapter.createTableAppendColumn(sqlBuffer, column);
@@ -89,19 +93,20 @@
 
         };
     }
-    
+
     @Override
     public MergerToken createSetNotNullToDb(DbEntity entity, final DbAttribute column) {
-        
+
         return new SetNotNullToDb(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(getEntity().getFullyQualifiedName());
+                sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
                 sqlBuffer.append(" ALTER COLUMN ");
 
                 SQLServerAdapter sqladapter = (SQLServerAdapter) adapter;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddColumnToDb.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddColumnToDb.java?rev=746521&r1=746520&r2=746521&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddColumnToDb.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddColumnToDb.java
Sat Feb 21 14:57:04 2009
@@ -23,6 +23,7 @@
 
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.dba.TypesMapping;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
@@ -32,23 +33,26 @@
     public AddColumnToDb(DbEntity entity, DbAttribute column) {
         super(entity, column);
     }
-    
+
     /**
      * append the part of the token before the actual column data type
      */
-    protected void appendPrefix(StringBuffer sqlBuffer) {
+    protected void appendPrefix(StringBuffer sqlBuffer, QuotingStrategy context) {
+
         sqlBuffer.append("ALTER TABLE ");
-        sqlBuffer.append(getEntity().getFullyQualifiedName());
+        sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
         sqlBuffer.append(" ADD COLUMN ");
-        sqlBuffer.append(getColumn().getName());
+        sqlBuffer.append(context.quoteString(getColumn().getName()));
         sqlBuffer.append(" ");
     }
 
     @Override
     public List<String> createSql(DbAdapter adapter) {
         StringBuffer sqlBuffer = new StringBuffer();
-
-        appendPrefix(sqlBuffer);
+        QuotingStrategy context = adapter.getQuotingStrategy(getEntity()
+                .getDataMap()
+                .isQuotingSQLIdentifiers());
+        appendPrefix(sqlBuffer, context);
 
         // copied from JdbcAdapter.createTableAppendColumn
         String[] types = adapter.externalTypesForJdbcType(getColumn().getType());
@@ -69,7 +73,8 @@
         // append size and precision (if applicable)
         if (TypesMapping.supportsLength(getColumn().getType())) {
             int len = getColumn().getMaxLength();
-            int scale = TypesMapping.isDecimal(getColumn().getType()) ? getColumn().getScale()
: -1;
+            int scale = TypesMapping.isDecimal(getColumn().getType()) ? getColumn()
+                    .getScale() : -1;
 
             // sanity check
             if (scale > len) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DbMerger.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DbMerger.java?rev=746521&r1=746520&r2=746521&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DbMerger.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DbMerger.java
Sat Feb 21 14:57:04 2009
@@ -98,7 +98,9 @@
                     null,
                     null,
                     new DataMap());
-
+            
+            detectedDataMap.setQuotingSQLIdentifiers(dataMap.isQuotingSQLIdentifiers());
+            
             Map<String, DbEntity> dbEntityToDropByName = new HashMap<String, DbEntity>(
                     detectedDataMap.getDbEntityMap());
 
@@ -108,7 +110,7 @@
                 if (!includeTableName(tableName)) {
                     continue;
                 }
-
+                
                 // look for table
                 DbEntity detectedEntity = findDbEntity(detectedDataMap, tableName);
                 if (detectedEntity == null) {
@@ -119,6 +121,7 @@
                     }
                     continue;
                 }
+                
                 dbEntityToDropByName.remove(detectedEntity.getName());
 
                 checkRelationshipsToDrop(adapter, tokens, dbEntity, detectedEntity);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropColumnToDb.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropColumnToDb.java?rev=746521&r1=746520&r2=746521&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropColumnToDb.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropColumnToDb.java
Sat Feb 21 14:57:04 2009
@@ -22,6 +22,7 @@
 import java.util.List;
 
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 
@@ -34,11 +35,13 @@
     @Override
     public List<String> createSql(DbAdapter adapter) {
         StringBuilder sqlBuffer = new StringBuilder();
-
+        QuotingStrategy context = adapter.getQuotingStrategy(getEntity()
+                .getDataMap()
+                .isQuotingSQLIdentifiers());
         sqlBuffer.append("ALTER TABLE ");
-        sqlBuffer.append(getEntity().getFullyQualifiedName());
+        sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
         sqlBuffer.append(" DROP COLUMN ");
-        sqlBuffer.append(getColumn().getName());
+        sqlBuffer.append(context.quoteString(getColumn().getName()));
 
         return Collections.singletonList(sqlBuffer.toString());
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropRelationshipToDb.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropRelationshipToDb.java?rev=746521&r1=746520&r2=746521&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropRelationshipToDb.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropRelationshipToDb.java
Sat Feb 21 14:57:04 2009
@@ -22,6 +22,7 @@
 import java.util.List;
 
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.DbRelationshipDetected;
@@ -49,10 +50,12 @@
         if (fkName == null) {
             return Collections.emptyList();
         }
-
+        QuotingStrategy context = adapter.getQuotingStrategy(getEntity()
+                .getDataMap()
+                .isQuotingSQLIdentifiers());
         StringBuilder buf = new StringBuilder();
         buf.append("ALTER TABLE ");
-        buf.append(getEntity().getFullyQualifiedName());
+        buf.append(context.quoteFullyQualifiedName(getEntity()));
         buf.append(" DROP CONSTRAINT ");
         buf.append(fkName);
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetAllowNullToDb.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetAllowNullToDb.java?rev=746521&r1=746520&r2=746521&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetAllowNullToDb.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetAllowNullToDb.java
Sat Feb 21 14:57:04 2009
@@ -22,6 +22,7 @@
 import java.util.List;
 
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 
@@ -38,11 +39,13 @@
     @Override
     public List<String> createSql(DbAdapter adapter) {
         StringBuilder sqlBuffer = new StringBuilder();
-
+        QuotingStrategy context = adapter.getQuotingStrategy(getEntity()
+                .getDataMap()
+                .isQuotingSQLIdentifiers());
         sqlBuffer.append("ALTER TABLE ");
-        sqlBuffer.append(getEntity().getFullyQualifiedName());
+        sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
         sqlBuffer.append(" ALTER COLUMN ");
-        sqlBuffer.append(getColumn().getName());
+        sqlBuffer.append(context.quoteString(getColumn().getName()));
         sqlBuffer.append(" DROP NOT NULL");
 
         return Collections.singletonList(sqlBuffer.toString());

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetColumnTypeToDb.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetColumnTypeToDb.java?rev=746521&r1=746520&r2=746521&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetColumnTypeToDb.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetColumnTypeToDb.java
Sat Feb 21 14:57:04 2009
@@ -23,6 +23,7 @@
 
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.dba.TypesMapping;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
@@ -43,21 +44,24 @@
     
     /**
      * append the part of the token before the actual column data type
+     * @param context 
      */
-    protected void appendPrefix(StringBuffer sqlBuffer) {
+    protected void appendPrefix(StringBuffer sqlBuffer, QuotingStrategy context) {
         sqlBuffer.append("ALTER TABLE ");
-        sqlBuffer.append(getEntity().getFullyQualifiedName());
+        sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
         sqlBuffer.append(" ALTER ");
-        sqlBuffer.append(columnNew.getName());
+        sqlBuffer.append(context.quoteString(columnNew.getName()));
         sqlBuffer.append(" TYPE ");
     }
 
     @Override
     public List<String> createSql(DbAdapter adapter) {
         StringBuffer sqlBuffer = new StringBuffer();
-
-        appendPrefix(sqlBuffer);
-
+        QuotingStrategy context = adapter.getQuotingStrategy(getEntity()
+                .getDataMap()
+                .isQuotingSQLIdentifiers());
+        appendPrefix(sqlBuffer, context);
+  
         // copied from JdbcAdapter.createTableAppendColumn
         String[] types = adapter.externalTypesForJdbcType(columnNew.getType());
         if (types == null || types.length == 0) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetNotNullToDb.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetNotNullToDb.java?rev=746521&r1=746520&r2=746521&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetNotNullToDb.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetNotNullToDb.java
Sat Feb 21 14:57:04 2009
@@ -22,12 +22,12 @@
 import java.util.List;
 
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 
 /**
  * A {@link MergerToken} to add a "not null" clause to a column.
- * 
  */
 public class SetNotNullToDb extends AbstractToDbToken.EntityAndColumn {
 
@@ -38,11 +38,13 @@
     @Override
     public List<String> createSql(DbAdapter adapter) {
         StringBuilder sqlBuffer = new StringBuilder();
-
+        QuotingStrategy context = adapter.getQuotingStrategy(getEntity()
+                .getDataMap()
+                .isQuotingSQLIdentifiers());
         sqlBuffer.append("ALTER TABLE ");
-        sqlBuffer.append(getEntity().getFullyQualifiedName());
+        sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
         sqlBuffer.append(" ALTER COLUMN ");
-        sqlBuffer.append(getColumn().getName());
+        sqlBuffer.append(context.quoteString(getColumn().getName()));
         sqlBuffer.append(" SET NOT NULL");
 
         return Collections.singletonList(sqlBuffer.toString());



Mime
View raw message