|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectca.sqlpower.architect.ddl.GenericDDLGenerator
ca.sqlpower.architect.ddl.PostgresDDLGenerator
public class PostgresDDLGenerator
DDL Generator for Postgres 8.x (does not support e.g., ALTER COLUMN operations 7.[34]).
| Field Summary | |
|---|---|
static java.lang.String |
GENERATOR_VERSION
|
| Fields inherited from class ca.sqlpower.architect.ddl.GenericDDLGenerator |
|---|
allowConnection, con, EOL, profileFunctionMap, targetCatalog, targetSchema, topLevelNames, typeMap, warnings |
| Constructor Summary | |
|---|---|
PostgresDDLGenerator()
|
|
| Method Summary | |
|---|---|
void |
addIndex(SQLIndex index)
create index ddl in postgresql syntax |
void |
addTable(SQLTable t)
Appends the DDL statements for creating a table in this DDL Generator's current catalog and schema using SQLTable t as a template. |
protected java.lang.String |
columnDefinition(SQLColumn c,
java.util.Map colNameMap)
Augments the default columnDefinition behaviour by adding the correct default value clause for auto-increment columns. |
protected void |
createTypeMap()
Creates and populates typeMap using
DatabaseMetaData, but ignores nullability as reported by the
driver's type map (because all types are reported as
non-nullable). |
java.lang.String |
getCatalogTerm()
Returns null, even though Postgres calls this "Database." The reason is, you can't refer to objects in a different database than the default database for your current connection. |
java.lang.String |
getName()
Returns the name of this DDL Generator, which should be a human-readable string with the vendor and/or product name (and version if the generator doesn't work with all versions) of the database platform this generator targets. |
java.lang.String |
getSchemaTerm()
Returns "Schema". |
java.lang.String |
getTargetSchema()
Returns the previously-set target schema name, or "public" if there is no current setting. |
boolean |
isReservedWord(java.lang.String word)
Check to see if the word word is on the list of reserved words for this database |
java.lang.String |
makeDropForeignKeySQL(java.lang.String fkTable,
java.lang.String fkName)
Generates a command for dropping a foreign key. |
void |
modifyColumn(SQLColumn c)
Appends the DDL statement for modifying the given column's datatype and nullability in its parent table in this DDL Generator's target schema/catalog. |
java.lang.String |
toIdentifier(java.lang.String name)
Converts space to underscore in name and returns
the possibly-modified string. |
void |
writeHeader()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String GENERATOR_VERSION
| Constructor Detail |
|---|
public PostgresDDLGenerator()
throws java.sql.SQLException
java.sql.SQLException| Method Detail |
|---|
public java.lang.String getName()
DDLGenerator
getName in interface DDLGeneratorgetName in class GenericDDLGeneratorpublic boolean isReservedWord(java.lang.String word)
GenericDDLGenerator
isReservedWord in interface DDLGeneratorisReservedWord in class GenericDDLGeneratorpublic void writeHeader()
writeHeader in class GenericDDLGenerator
protected void createTypeMap()
throws java.sql.SQLException
typeMap using
DatabaseMetaData, but ignores nullability as reported by the
driver's type map (because all types are reported as
non-nullable).
createTypeMap in class GenericDDLGeneratorjava.sql.SQLExceptionpublic java.lang.String toIdentifier(java.lang.String name)
GenericDDLGeneratorname and returns
the possibly-modified string. This will not be completely
sufficient because it leaves ".", "%", and lots of other
non-alphanumeric characters alone. Subclasses might choose to
quote and leave everything alone, or whatever.
toIdentifier in interface DDLGeneratortoIdentifier in class GenericDDLGenerator
public java.lang.String makeDropForeignKeySQL(java.lang.String fkTable,
java.lang.String fkName)
ALTER TABLE ONLY $fktable DROP CONSTRAINT $fkname.
makeDropForeignKeySQL in interface DDLGeneratormakeDropForeignKeySQL in class GenericDDLGeneratorfkTable - The name of the FK table whose relationship should be dropped.fkName - The name of the key to drop.
public void modifyColumn(SQLColumn c)
DDLGenerator
modifyColumn in interface DDLGeneratormodifyColumn in class GenericDDLGeneratorc - The column to create a MODIFY or ALTER COLUMN statement for.public java.lang.String getCatalogTerm()
getCatalogTerm in interface DDLGeneratorgetCatalogTerm in class GenericDDLGeneratorpublic java.lang.String getSchemaTerm()
getSchemaTerm in interface DDLGeneratorgetSchemaTerm in class GenericDDLGeneratorpublic java.lang.String getTargetSchema()
getTargetSchema in interface DDLGeneratorgetTargetSchema in class GenericDDLGenerator
public void addIndex(SQLIndex index)
throws ArchitectException
addIndex in interface DDLGeneratoraddIndex in class GenericDDLGeneratorindex - The specification of the index to create. Note,
if the index type is STATISTIC, no DDL will be generated because
STATISTIC indices are just artificial JDBC constructs to describe
table statistics (you can't create or drop them).
ArchitectException
public void addTable(SQLTable t)
throws java.sql.SQLException,
ArchitectException
DDLGenerator
addTable in interface DDLGeneratoraddTable in class GenericDDLGeneratorjava.sql.SQLException
ArchitectException
protected java.lang.String columnDefinition(SQLColumn c,
java.util.Map colNameMap)
GenericDDLGenerator.columnDefinition(SQLColumn, Map).
columnDefinition in class GenericDDLGeneratorc - The column to generate the DDL snippet for.colNameMap - Dirty hack for coming up with unique physical names.
The final physical name generated in the SQL snippet will be stored
in this map. If you don't care about producing unique column names, just
pass in a freshly-created map. See GenericDDLGenerator.createPhysicalName(Map, SQLObject)
for more information.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||