commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thorha...@apache.org
Subject cvs commit: jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/builder PostgreSqlBuilder.java
Date Mon, 23 Sep 2002 16:53:25 GMT
thorhauer    2002/09/23 09:53:24

  Modified:    sql/src/java/org/apache/commons/sql/builder
                        PostgreSqlBuilder.java
  Log:
  - adding support for postgres oid type since they dont support blob or varbinary
  
  - fixing serial column creation so that postgres takes care of most of the work
  
  Revision  Changes    Path
  1.2       +53 -3     jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/builder/PostgreSqlBuilder.java
  
  Index: PostgreSqlBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/builder/PostgreSqlBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PostgreSqlBuilder.java	20 Sep 2002 20:50:51 -0000	1.1
  +++ PostgreSqlBuilder.java	23 Sep 2002 16:53:24 -0000	1.2
  @@ -58,6 +58,7 @@
   
   package org.apache.commons.sql.builder;
   
  +import org.apache.commons.sql.model.Column;
   import java.io.IOException;
   
   /**
  @@ -74,6 +75,55 @@
       } 
   
       protected void printAutoIncrementColumn() throws IOException { 
  -        print( "DEFAULT NEXTVAL('serial')" );
  +        print(" ");
  +        print("serial");
  +        print(" ");
  +
  +    }
  +
  +    /** 
  +     * Outputs the DDL to add a column to a table.
  +     */
  +    public void createColumn(Column column) throws IOException {
  +        this.column = column;
  +        print(column.getName());
  +        print(" ");
  +        if (column.isAutoIncrement()) {
  +            printAutoIncrementColumn();
  +        }
  +        else
  +        {
  +
  +            print(getSqlType(column));
  +            print(" ");
  +
  +            if (column.getDefaultValue() != null)
  +            {
  +              print("DEFAULT '" + column.getDefaultValue() + "' ");
  +            }
  +            if (column.isRequired()) {
  +                printNotNullable();
  +            }
  +            else {
  +                printNullable();
  +            }
  +            print(" ");
  +        }
       }
  +
  +    /**
  +     * @return the full SQL type string including the size
  +     */
  +    protected String getSqlType(Column column) {
  +
  +        if (column.getTypeString().equalsIgnoreCase("VARBINARY"))
  +        {
  +            return "OID";
  +        }
  +        else
  +        {
  +            return column.getTypeString();
  +        }
  +    }
  +
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message