[exo-jcr-commits] exo-jcr SVN: r5088 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Oct 26 05:57:46 EDT 2011


Author: tolusha
Date: 2011-10-26 05:57:46 -0400 (Wed, 26 Oct 2011)
New Revision: 5088

Modified:
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java
Log:
EXOJCR-1585: add unit tests for MySQL

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java	2011-10-26 09:19:43 UTC (rev 5087)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java	2011-10-26 09:57:46 UTC (rev 5088)
@@ -47,6 +47,8 @@
 
    static public String SQL_CREATETABLE = "^(CREATE(\\s)+TABLE(\\s)+(IF(\\s)+NOT(\\s)+EXISTS(\\s)+)*){1}";
 
+   static public String SQL_ALTERTABLE = "^(ALTER(\\s)+TABLE(\\s)+(IF(\\s)+NOT(\\s)+EXISTS(\\s)+)*){1}";
+
    static public String SQL_CREATEVIEW = "^(CREATE(\\s)+VIEW(\\s)+(IF(\\s)+NOT(\\s)+EXISTS(\\s)+)*){1}";
 
    static public String SQL_OBJECTNAME = "((JCR_[A-Z_]+){1}(\\s*?|(\\(\\))*?)+)+?";
@@ -71,6 +73,8 @@
 
    protected final Pattern creatTablePattern;
 
+   protected final Pattern alterTablePattern;
+
    protected final Pattern creatViewPattern;
 
    protected final Pattern dbObjectNamePattern;
@@ -92,6 +96,7 @@
       this.script = script(scriptPath);
 
       this.creatTablePattern = Pattern.compile(SQL_CREATETABLE, Pattern.CASE_INSENSITIVE);
+      this.alterTablePattern = Pattern.compile(SQL_ALTERTABLE, Pattern.CASE_INSENSITIVE);
       this.creatViewPattern = Pattern.compile(SQL_CREATEVIEW, Pattern.CASE_INSENSITIVE);
       this.dbObjectNamePattern = Pattern.compile(SQL_OBJECTNAME, Pattern.CASE_INSENSITIVE);
       this.creatIndexPattern = Pattern.compile(SQL_CREATEINDEX, Pattern.CASE_INSENSITIVE);
@@ -144,6 +149,25 @@
             }
          }
       }
+      else if ((tMatcher = alterTablePattern.matcher(sql)).find())
+      {
+         // CREATE TABLE
+         tMatcher = dbObjectNamePattern.matcher(sql);
+         if (tMatcher.find())
+         {
+            // got table name
+            String tableName = sql.substring(tMatcher.start(), tMatcher.end());
+            if (isTableExists(conn, tableName))
+            {
+               if (LOG.isDebugEnabled())
+               {
+                  LOG.debug("Table is already exists " + tableName);
+               }
+               existingTables.add(tableName);
+               return true;
+            }
+         }
+      }
       else if ((tMatcher = creatViewPattern.matcher(sql)).find())
       {
          // CREATE VIEW



More information about the exo-jcr-commits mailing list