db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpoes...@apache.org
Subject cvs commit: db-torque/src/generator/src/templates/sql/base Control.vm
Date Tue, 25 Nov 2003 16:57:14 GMT
mpoeschl    2003/11/25 08:57:14

  Modified:    src/generator/src/templates/sql/base/postgresql columns.vm
               src/generator/src/templates/sql/base/hypersonic columns.vm
               src/generator/src/templates/sql/base/oracle columns.vm
               src/generator/src/templates/sql/base/interbase columns.vm
               src/generator/src/templates/sql/base/cloudscape columns.vm
               src/generator/src/java/org/apache/torque/engine/database/model
                        Column.java Table.java Database.java
               src/generator/src/templates/sql/base/msaccess columns.vm
               src/generator/src/java/org/apache/torque/engine/platform
                        PlatformMssqlImpl.java PlatformDefaultImpl.java
                        Platform.java
               src/generator/src/templates/sql/base/db2400 columns.vm
               src/generator/src/templates/sql/base/sapdb columns.vm
               src/generator/src/templates/sql/base/db2 columns.vm
               src/generator/src/templates/sql/base/mysql columns.vm
               src/generator/src/templates/sql/base/mssql columns.vm
               src/generator/src/templates/sql/base/sybase columns.vm
               src/generator/src/templates/sql/base Control.vm
  Log:
  move 'NOT NULL' handling to platform package
  
  Revision  Changes    Path
  1.3       +1 -2      db-torque/src/generator/src/templates/sql/base/postgresql/columns.vm
  
  Index: columns.vm
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/templates/sql/base/postgresql/columns.vm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- columns.vm	7 Aug 2003 21:27:46 -0000	1.2
  +++ columns.vm	25 Nov 2003 16:57:13 -0000	1.3
  @@ -14,8 +14,7 @@
       #else
         #set ( $default = $col.DefaultSetting )
       #end
  -    #set ( $nullString = $strings.select($col.isNotNull(), $dbprops.get("NOTNULL"),"")
)
  -    #set ( $entry = "$col.Name $type $size $default $nullString" )
  +    #set ( $entry = "$col.Name $type $size $default $col.NotNullString" )
       #if ($col.isAutoIncrement() && $table.IdMethod == "native")
         #set ( $autoIncrement = $dbprops.get("AUTOINCREMENT") )
       #else
  
  
  
  1.3       +0 -1      db-torque/src/generator/src/templates/sql/base/hypersonic/columns.vm
  
  Index: columns.vm
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/templates/sql/base/hypersonic/columns.vm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- columns.vm	7 Aug 2003 21:27:46 -0000	1.2
  +++ columns.vm	25 Nov 2003 16:57:13 -0000	1.3
  @@ -2,7 +2,6 @@
       #set ( $type = $dbprops.get($col.Type) )
       #set ( $size = $col.printSize() )
       #set ( $default = $col.DefaultSetting )
  -    #set ( $nullString = $strings.select($col.isNotNull(), $dbprops.get("NOTNULL"),"")
)
       #if ($col.isAutoIncrement() && $table.IdMethod == "native")
         #set ( $autoIncrement = $dbprops.get("AUTOINCREMENT") )
       #else
  
  
  
  1.2       +1 -2      db-torque/src/generator/src/templates/sql/base/oracle/columns.vm
  
  Index: columns.vm
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/templates/sql/base/oracle/columns.vm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- columns.vm	10 Feb 2003 13:18:47 -0000	1.1
  +++ columns.vm	25 Nov 2003 16:57:13 -0000	1.2
  @@ -2,7 +2,6 @@
       #set ( $type = $dbprops.get($col.Type) )
       #set ( $size = $col.printSize() )
       #set ( $default = $col.DefaultSetting )
  -    #set ( $nullString = $strings.select($col.isNotNull(), $dbprops.get("NOTNULL"),"")
)
  -    #set ( $entry = "$col.Name $type $size $default $nullString," )
  +    #set ( $entry = "$col.Name $type $size $default $col.NotNullString," )
       $strings.sub($strings.collapseSpaces($entry)," ,",",")
   #end
  
  
  
  1.3       +1 -2      db-torque/src/generator/src/templates/sql/base/interbase/columns.vm
  
  Index: columns.vm
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/templates/sql/base/interbase/columns.vm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- columns.vm	7 Aug 2003 21:27:46 -0000	1.2
  +++ columns.vm	25 Nov 2003 16:57:13 -0000	1.3
  @@ -2,13 +2,12 @@
       #set ( $type = $dbprops.get($col.Type) )
       #set ( $size = $col.printSize() )
       #set ( $default = $col.DefaultSetting )
  -    #set ( $nullString = $strings.select($col.isNotNull(), $dbprops.get("NOTNULL"),"")
)
       #if ($col.isAutoIncrement() && $table.IdMethod == "native")
         #set ( $autoIncrement = $dbprops.get("AUTOINCREMENT") )
       #else
         #set ( $autoIncrement = " " )
       #end    
       #set ( $colName = $strings.concat(['"',$col.Name,'"']) )
  -    #set ( $entry = "$colName $type $size $default $nullString $autoIncrement," )
  +    #set ( $entry = "$colName $type $size $default $col.NotNullString $autoIncrement,"
)
       $strings.sub($strings.collapseSpaces($entry)," ,",",")
   #end
  
  
  
  1.3       +0 -1      db-torque/src/generator/src/templates/sql/base/cloudscape/columns.vm
  
  Index: columns.vm
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/templates/sql/base/cloudscape/columns.vm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- columns.vm	7 Aug 2003 21:27:46 -0000	1.2
  +++ columns.vm	25 Nov 2003 16:57:13 -0000	1.3
  @@ -2,7 +2,6 @@
       #set ( $type = $dbprops.get($col.Type) )
       #set ( $size = $col.printSize() )
       #set ( $default = $col.DefaultSetting )
  -    #set ( $nullString = $strings.select($col.isNotNull(), $dbprops.get("NOTNULL"),"")
)
       #if ($col.isAutoIncrement() && $table.IdMethod == "native")
         #set ( $autoIncrement = $dbprops.get("AUTOINCREMENT") )
       #else
  
  
  
  1.13      +12 -1     db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Column.java
  
  Index: Column.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Column.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Column.java	18 Nov 2003 18:21:48 -0000	1.12
  +++ Column.java	25 Nov 2003 16:57:13 -0000	1.13
  @@ -432,6 +432,17 @@
       {
           isNotNull = status;
       }
  +    
  +    /**
  +     * Return NOT NULL String for this column
  +     * 
  +     * @return "NOT NULL" if null values are not allowed or an empty String.
  +     */
  +    public String getNotNullString()
  +    {
  +        return getTable().getDatabase().getPlatform()
  +                .getNullString(this.isNotNull());
  +    }
   
       /**
        * Set if the column is a primary key or not
  
  
  
  1.4       +1 -9      db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Table.java
  
  Index: Table.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Table.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Table.java	26 Jun 2003 22:09:41 -0000	1.3
  +++ Table.java	25 Nov 2003 16:57:13 -0000	1.4
  @@ -162,14 +162,6 @@
           {
               idMethod = defaultIdMethod;
           }
  -        if ("autoincrement".equals(idMethod) || "sequence".equals(idMethod))
  -        {
  -            log.warn("The value '" + idMethod + "' for Torque's "
  -                    + "table.idMethod attribute has been deprecated in favor "
  -                    + "of '" + NATIVE + "'.  Please adjust your "
  -                    + "Torque XML schema accordingly.");
  -            idMethod = NATIVE;
  -        }
           skipSql = "true".equals(attrib.getValue("skipSql"));
           // pkg = attrib.getValue("package");
           abstractValue = "true".equals(attrib.getValue("abstract"));
  
  
  
  1.12      +3 -1      db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Database.java
  
  Index: Database.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Database.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Database.java	29 Oct 2003 01:19:10 -0000	1.11
  +++ Database.java	25 Nov 2003 16:57:13 -0000	1.12
  @@ -415,6 +415,7 @@
               // if idMethod="autoincrement", make sure a column is
               // specified as autoIncrement="true"
               // FIXME: Handle idMethod="native" via DB adapter.
  +            // TODO autoincrement is no longer supported!!!
               if (currTable.getIdMethod().equals("autoincrement"))
               {
                   Column[] columns = currTable.getColumns();
  @@ -450,6 +451,7 @@
                   }
                   else
                   {
  +                    // TODO check type and size 
                       List referrers = foreignTable.getReferrers();
                       if ((referrers == null || !referrers.contains(currFK)))
                       {
  
  
  
  1.3       +0 -1      db-torque/src/generator/src/templates/sql/base/msaccess/columns.vm
  
  Index: columns.vm
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/templates/sql/base/msaccess/columns.vm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- columns.vm	7 Aug 2003 21:27:46 -0000	1.2
  +++ columns.vm	25 Nov 2003 16:57:13 -0000	1.3
  @@ -2,7 +2,6 @@
       #set ( $type = $dbprops.get($col.Type) )
       #set ( $size = $col.printSize() )
       #set ( $default = $col.DefaultSetting )
  -    #set ( $nullString = $strings.select($col.isNotNull(), $dbprops.get("NOTNULL"),"")
)
       #if ($col.isAutoIncrement() && $table.IdMethod == "native")
         #set ( $autoIncrement = $dbprops.get("AUTOINCREMENT") )
       #else
  
  
  
  1.3       +17 -1     db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformMssqlImpl.java
  
  Index: PlatformMssqlImpl.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformMssqlImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PlatformMssqlImpl.java	16 Nov 2003 20:16:53 -0000	1.2
  +++ PlatformMssqlImpl.java	25 Nov 2003 16:57:13 -0000	1.3
  @@ -97,4 +97,20 @@
       {
           return 30;
       }
  +    
  +    /**
  +     * Explicitly returns NULL if null values allowed 
  +     * (as recomended by Microsoft).
  +     * 
  +     * @see Platform#getNullString(boolean)
  +     */
  +    public String getNullString(boolean notNull) 
  +    {
  +        if (notNull) 
  +        {
  +            return "NOT NULL";
  +        }
  +        return "NULL";
  +    }
  +
   }
  
  
  
  1.3       +17 -1     db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformDefaultImpl.java
  
  Index: PlatformDefaultImpl.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformDefaultImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PlatformDefaultImpl.java	16 Nov 2003 20:16:53 -0000	1.2
  +++ PlatformDefaultImpl.java	25 Nov 2003 16:57:13 -0000	1.3
  @@ -121,4 +121,20 @@
           return (Domain) schemaDomainMap.get(jdbcType);
       }
   
  +    /**
  +     * 
  +     * @param notNull
  +     * @return
  +     */
  +    public String getNullString(boolean notNull)
  +    {
  +        if (notNull) 
  +        {
  +            // TODO check if this is true for all dbs 
  +            // check old sybase templates!
  +            return "NOT NULL";
  +        }
  +        return "";
  +    }
  +    
   }
  
  
  
  1.3       +9 -1      db-torque/src/generator/src/java/org/apache/torque/engine/platform/Platform.java
  
  Index: Platform.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/platform/Platform.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Platform.java	16 Nov 2003 20:16:53 -0000	1.2
  +++ Platform.java	25 Nov 2003 16:57:13 -0000	1.3
  @@ -86,4 +86,12 @@
        * @return the db specific domain
        */
       Domain getDomainForSchemaType(SchemaType jdbcType);
  +    
  +    /**
  +     * Returns the db specific String for NULL or NOT NULL.
  +     * 
  +     * @return the db specific String
  +     */
  +    String getNullString(boolean notNull);
  +    
   }
  
  
  
  1.3       +1 -2      db-torque/src/generator/src/templates/sql/base/db2400/columns.vm
  
  Index: columns.vm
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/templates/sql/base/db2400/columns.vm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- columns.vm	7 Aug 2003 21:27:46 -0000	1.2
  +++ columns.vm	25 Nov 2003 16:57:13 -0000	1.3
  @@ -7,7 +7,6 @@
       #else
         #set ( $autoIncrement = " " )
       #end    
  -    #set ( $nullString = $strings.select($col.isNotNull(), $dbprops.get("NOTNULL"),"")
)
  -    #set ( $entry = "$col.Name $type $size $default $nullString $autoIncrement," )
  +    #set ( $entry = "$col.Name $type $size $default $col.NotNullString $autoIncrement,"
)
       $strings.sub($strings.collapseSpaces($entry)," ,",",")
   #end
  
  
  
  1.2       +1 -2      db-torque/src/generator/src/templates/sql/base/sapdb/columns.vm
  
  Index: columns.vm
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/templates/sql/base/sapdb/columns.vm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- columns.vm	10 Feb 2003 13:18:44 -0000	1.1
  +++ columns.vm	25 Nov 2003 16:57:14 -0000	1.2
  @@ -2,7 +2,6 @@
       #set ( $type = $dbprops.get($col.Type) )
       #set ( $size = $col.printSize() )
       #set ( $default = $col.DefaultSetting )
  -    #set ( $nullString = $strings.select($col.isNotNull(), $dbprops.get("NOTNULL"),"")
)
  -    #set ( $entry = "$col.Name $type $size $default $nullString," )
  +    #set ( $entry = "$col.Name $type $size $default $col.NotNullString," )
       $strings.sub($strings.collapseSpaces($entry)," ,",",")
   #end
  
  
  
  1.4       +3 -4      db-torque/src/generator/src/templates/sql/base/db2/columns.vm
  
  Index: columns.vm
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/templates/sql/base/db2/columns.vm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- columns.vm	7 Aug 2003 21:27:46 -0000	1.3
  +++ columns.vm	25 Nov 2003 16:57:14 -0000	1.4
  @@ -12,13 +12,12 @@
       #else
         #set ( $autoIncrement = " " )
       #end    
  -    #set ( $nullString = $strings.select($col.isNotNull(), $dbprops.get("NOTNULL"),"")
)
       #if ( $torquetype == "BINARY" )
  -        #set ( $entry = "$col.Name CHAR($rawsize) FOR BIT DATA $default $nullString $autoIncrement,"
)
  +        #set ( $entry = "$col.Name CHAR($rawsize) FOR BIT DATA $default $col.NotNullString
$autoIncrement," )
       #elseif ( $torquetype == "VARBINARY" )
  -        #set ( $entry = "$col.Name VARCHAR($rawsize) FOR BIT DATA $default $nullString
$autoIncrement," )
  +        #set ( $entry = "$col.Name VARCHAR($rawsize) FOR BIT DATA $default $col.NotNullString
$autoIncrement," )
       #else
  -        #set ( $entry = "$col.Name $type $size $default $nullString $autoIncrement," )
  +        #set ( $entry = "$col.Name $type $size $default $col.NotNullString $autoIncrement,"
)
       #end
       $strings.sub($strings.collapseSpaces($entry)," ,",",")
   #end
  
  
  
  1.5       +1 -2      db-torque/src/generator/src/templates/sql/base/mysql/columns.vm
  
  Index: columns.vm
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/templates/sql/base/mysql/columns.vm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- columns.vm	7 Aug 2003 21:27:46 -0000	1.4
  +++ columns.vm	25 Nov 2003 16:57:14 -0000	1.5
  @@ -6,12 +6,11 @@
   		#set ( $size = $col.printSize() )
   	#end
       #set ( $default = $col.DefaultSetting )
  -    #set ( $nullString = $strings.select($col.isNotNull(), $dbprops.get("NOTNULL"),"")
)
       #if ($col.isAutoIncrement() && $table.IdMethod == "native")
         #set ( $autoIncrement = $dbprops.get("AUTOINCREMENT") )
       #else
         #set ( $autoIncrement = " " )
       #end    
  -    #set ( $entry = "$col.Name $type $size $default $nullString $autoIncrement," )
  +    #set ( $entry = "$col.Name $type $size $default $col.NotNullString $autoIncrement,"
)
       $strings.sub($strings.collapseSpaces($entry)," ,",",")
   #end
  
  
  
  1.3       +1 -2      db-torque/src/generator/src/templates/sql/base/mssql/columns.vm
  
  Index: columns.vm
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/templates/sql/base/mssql/columns.vm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- columns.vm	7 Aug 2003 21:27:46 -0000	1.2
  +++ columns.vm	25 Nov 2003 16:57:14 -0000	1.3
  @@ -6,13 +6,12 @@
         #set ( $size = $col.printSize() )
       #end
       #set ( $default = $col.DefaultSetting )
  -    #set ( $nullString = $strings.select($col.isNotNull(), $dbprops.get("NOTNULL"),$dbprops.get("NULL"))
)
       #if ($col.isAutoIncrement() && $table.IdMethod == "native")
         #set ( $autoIncrement = $dbprops.get("AUTOINCREMENT") )
       #else
         #set ( $autoIncrement = " " )
       #end    
  -    #set ( $entry = "$col.Name $type $size $default $nullString $autoIncrement," )
  +    #set ( $entry = "$col.Name $type $size $default $col.NotNullString $autoIncrement,"
)
       $strings.sub($strings.collapseSpaces($entry)," ,",",")
   #end
   
  
  
  
  1.3       +1 -6      db-torque/src/generator/src/templates/sql/base/sybase/columns.vm
  
  Index: columns.vm
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/templates/sql/base/sybase/columns.vm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- columns.vm	7 Aug 2003 21:27:46 -0000	1.2
  +++ columns.vm	25 Nov 2003 16:57:14 -0000	1.3
  @@ -10,16 +10,11 @@
       #else
           #set ( $default = $col.DefaultSetting )
       #end
  -    #if ( ($dbprops.get("removeNotNullWithAutoIncrement") == "true") && $col.isAutoIncrement()
&& $col.isNotNull() )
  -       #set ( $nullString = "" )
  -    #else
  -       #set ( $nullString = $strings.select($col.isNotNull(), $dbprops.get("NOTNULL"),"NULL")
)
  -    #end
       #if ($col.isAutoIncrement() && $table.IdMethod == "native")
         #set ( $autoIncrement = $dbprops.get("AUTOINCREMENT") )
       #else
         #set ( $autoIncrement = " " )
       #end    
  -    #set ( $entry = "$col.Name $type $size $default $nullString $autoIncrement," )
  +    #set ( $entry = "$col.Name $type $size $default $col.NotNullString $autoIncrement,"
)
       $strings.sub($strings.collapseSpaces($entry)," ,",",")
   #end
  
  
  
  1.3       +5 -1      db-torque/src/generator/src/templates/sql/base/Control.vm
  
  Index: Control.vm
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/templates/sql/base/Control.vm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Control.vm	5 Oct 2003 14:14:04 -0000	1.2
  +++ Control.vm	25 Nov 2003 16:57:14 -0000	1.3
  @@ -5,7 +5,11 @@
   #set ( $idname = "sql/id-table/idtable.$targetDatabase" )
   
   #foreach ($database in $dataModels)
  -        
  +
  +  #set ( $platform = $database.Platform )
  +  
  +  Platform used: $platform.class.Name
  +  
     #set ( $outFile = "${database.FileName}.sql" )
   
     File to be created: $outFile
  
  
  

---------------------------------------------------------------------
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