db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r418871 - in /db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase: SybaseBuilder.java SybaseModelReader.java
Date Mon, 03 Jul 2006 23:20:40 GMT
Author: tomdz
Date: Mon Jul  3 16:20:39 2006
New Revision: 418871

URL: http://svn.apache.org/viewvc?rev=418871&view=rev
Log:
Fixed/enhanced Sybase platform

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseModelReader.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java?rev=418871&r1=418870&r2=418871&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java Mon
Jul  3 16:20:39 2006
@@ -202,6 +202,14 @@
     }
 
     /**
+     * {@inheritDoc}
+     */
+    public String getSelectLastIdentityValues(Table table)
+    {
+        return "SELECT @@IDENTITY";
+    }
+
+    /**
      * Writes the statement that turns on the ability to write delimited identifiers.
      */
     private void writeQuotationOnStatement() throws IOException
@@ -224,6 +232,30 @@
         print("'");
         print(identifier);
         print("'");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void writeCopyDataStatement(Table sourceTable, Table targetTable) throws IOException
+    {
+        boolean hasIdentity = targetTable.getAutoIncrementColumns().length > 0;
+
+        if (hasIdentity)
+        {
+            print("SET IDENTITY_INSERT ");
+            printIdentifier(getTableName(targetTable));
+            print(" ON");
+            printEndOfStatement();
+        }
+        super.writeCopyDataStatement(sourceTable, targetTable);
+        if (hasIdentity)
+        {
+            print("SET IDENTITY_INSERT ");
+            printIdentifier(getTableName(targetTable));
+            print(" OFF");
+            printEndOfStatement();
+        }
     }
 
     /**

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseModelReader.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseModelReader.java?rev=418871&r1=418870&r2=418871&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseModelReader.java
(original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseModelReader.java
Mon Jul  3 16:20:39 2006
@@ -35,6 +35,7 @@
 import org.apache.ddlutils.model.Index;
 import org.apache.ddlutils.model.Reference;
 import org.apache.ddlutils.model.Table;
+import org.apache.ddlutils.model.TypeMap;
 import org.apache.ddlutils.platform.DatabaseMetaDataWrapper;
 import org.apache.ddlutils.platform.JdbcModelReader;
 import org.apache.oro.text.regex.MalformedPatternException;
@@ -109,26 +110,33 @@
 			// Back-mapping to BIGINT
 			column.setTypeCode(Types.BIGINT);
 		}
-		else if ((column.getTypeCode() == Types.TIMESTAMP) && (column.getDefaultValue()
!= null))
-		{
-			// Sybase maintains the default values for DATE/TIME jdbc types, so we have to
-			// migrate the default value to TIMESTAMP
-			PatternMatcher matcher   = new Perl5Matcher();
-			Timestamp      timestamp = null;
-
-			if (matcher.matches(column.getDefaultValue(), _isoDatePattern))
-			{
-				timestamp = new Timestamp(Date.valueOf(matcher.getMatch().group(1)).getTime());
-			}
-			else if (matcher.matches(column.getDefaultValue(), _isoTimePattern))
-			{
-				timestamp = new Timestamp(Time.valueOf(matcher.getMatch().group(1)).getTime());
-			}
-			if (timestamp != null)
-			{
-				column.setDefaultValue(timestamp.toString());
-			}
-		}
+        else if (column.getDefaultValue() != null)
+        {
+    		if (column.getTypeCode() == Types.TIMESTAMP)
+    		{
+    			// Sybase maintains the default values for DATE/TIME jdbc types, so we have to
+    			// migrate the default value to TIMESTAMP
+    			PatternMatcher matcher   = new Perl5Matcher();
+    			Timestamp      timestamp = null;
+    
+    			if (matcher.matches(column.getDefaultValue(), _isoDatePattern))
+    			{
+    				timestamp = new Timestamp(Date.valueOf(matcher.getMatch().group(1)).getTime());
+    			}
+    			else if (matcher.matches(column.getDefaultValue(), _isoTimePattern))
+    			{
+    				timestamp = new Timestamp(Time.valueOf(matcher.getMatch().group(1)).getTime());
+    			}
+    			if (timestamp != null)
+    			{
+    				column.setDefaultValue(timestamp.toString());
+    			}
+    		}
+            else if (TypeMap.isTextType(column.getTypeCode()))
+            {
+                column.setDefaultValue(unescape(column.getDefaultValue(), "'", "''"));
+            }
+        }
 		return column;
 	}
 



Mime
View raw message