Package Modeling :: Package DatabaseAdaptors :: Package PostgresqlAdaptorLayer :: Module PostgresqlSchemaGeneration :: Class PostgresqlSchemaGeneration
[show private | hide private]
[frames | no frames]

Class PostgresqlSchemaGeneration

SchemaGeneration --+
                   |
                  PostgresqlSchemaGeneration


Concrete SchemaGeneration for Postgresql [module psycopg or pgdb]

See Modeling.interfaces.SchemaGeneration for further details


Method Summary
  createDatabaseStatementsForConnectionDictionary(self, connectionDictionary, administrativeConnectionDictionary, createUserFlag)
See also: interfaces.SchemaGeneration for details
  dropDatabaseStatementsForConnectionDictionary(self, connectionDictionary, administrativeConnectionDictionary, dropUserFlag)
See Modeling.interfaces.SchemaGeneration for details
  dropForeignKeyConstraintStatementsForRelationship(self, relationship)
Return a SQLExpression object designed to remove the foreign key constraints built by foreignKeyConstraintStatementsForRelationship().
  dropPrimaryKeyConstraintStatementsForEntityGroup(self, entityGroup)
Returns the SQL statement used to drop the primary key constraint.
  dropPrimaryKeySupportStatementsForEntityGroup(self, entityGroup)
Returns a list containing a single SQLExpression statement, which takes the following form: 'DROP SEQUENCE <SEQUENCE_NAME>', where '<SEQUENCE_NAME>' is:
  foreignKeyConstraintStatementsForRelationship(self, relationship)
Returns Modeling.SchemaGeneration.foreignKeyConstraintStatementsForRelationship()
  primaryKeySupportStatementsForEntityGroup(self, entityGroup)
Returns a list containing a single SQLExpression statement, which takes the following form: 'CREATE SEQUENCE <SEQUENCE_NAME> START 1', where '<SEQUENCE_NAME>' is:
    Inherited from SchemaGeneration
  __init__(self, anAdaptor)
See interfaces.SchemaGeneration for details
  appendExpressionToScript(self, expression, script)
Appends the expression to the StringIO script, prepended with a semi-colon (';') and a newline if the StringIO is not empty.
  createTableStatementsForEntityGroup(self, entityGroup)
Returns a list of SQLExpressions needed to create the tables defined by the supplied 'entityGroup', or an empty list if 'entityGroup' is empty.
  createTableStatementsForEntityGroups(self, entityGroups)
Invokes createTableStatementsForEntityGroup() for each entityGroup in 'entityGroups', and returns the list of SQLExpressions needed to create the necessary table.
  defaultOrderingsForSchemaCreation()
Used in method SchemaGeneration.schemaCreationScriptForEntities() to order the schema creation statements produced (Static method)
  dropPrimaryKeyConstraintStatementsForEntityGroups(self, entityGroups)
Iterates on each entityGroup in 'entityGroups', sends the message 'dropPrimaryKeyConstraintStatementsForEntityGroup' to each of them, collects the results and returns them in a sequence.
  dropPrimaryKeySupportStatementsForEntityGroups(self, entityGroups)
Iterates on each entityGroup in 'entityGroups', sends the message 'dropPrimaryKeySupportStatementsForEntityGroup' to each of them, collects the results and returns them in a sequence.
  dropTableStatementsForEntityGroup(self, entityGroup)
Parameter:
  dropTableStatementsForEntityGroups(self, entityGroups)
Iterates on each entityGroup in 'entityGroups', sends the message 'dropPrimaryKeySupportStatementsForEntityGroup()' to each of them, collects the results and returns them in a sequence.
  primaryKeyConstraintStatementsForEntityGroup(self, entityGroup)
Default implementation returns an empty list.
  primaryKeyConstraintStatementsForEntityGroups(self, entityGroups)
Iterates on each entityGroup in 'entityGroups', sends the message 'primaryKeyConstraintStatementsForEntityGroup' to each of them, collects the results and returns them in a sequence.
  primaryKeySupportStatementsForEntityGroups(self, entityGroups)
Iterates on each entityGroup in 'entityGroups', sends the message 'primaryKeySupportStatementsForEntityGroup' to each of them, collects the results and returns them in a sequence.
  schemaCreationScriptForEntities(self, allEntities, options, keyOrderings)
__TBD
  schemaCreationStatementsForEntities(self, allEntities, options, keyOrderings)
__TBD doc.
  schemaCreationStatementsForEntitiesByOptions(self, allEntities, options)
__TBD doc.
  setDefaultOrderingsForSchemaCreation(keyOrderings)
Sets the default ordering. (Static method)
  tableEntityGroupsForEntities(self, entities)
Returns a list of entityGroups ; each entityGroup consists of the entities in parameter 'entities' which share the same externalName(), and wich answered positively to the definesTableColumns() message.

Class Variable Summary
    Inherited from SchemaGeneration
tuple __implements__ = (<class Modeling.interfaces.SchemaGener...

Instance Method Details

createDatabaseStatementsForConnectionDictionary(self, connectionDictionary, administrativeConnectionDictionary, createUserFlag=1)

See also: interfaces.SchemaGeneration for details
Overrides:
Modeling.SchemaGeneration.SchemaGeneration.createDatabaseStatementsForConnectionDictionary

dropDatabaseStatementsForConnectionDictionary(self, connectionDictionary, administrativeConnectionDictionary, dropUserFlag=1)

See Modeling.interfaces.SchemaGeneration for details
Overrides:
Modeling.SchemaGeneration.SchemaGeneration.dropDatabaseStatementsForConnectionDictionary

dropForeignKeyConstraintStatementsForRelationship(self, relationship)

Return a SQLExpression object designed to remove the foreign key constraints built by foreignKeyConstraintStatementsForRelationship().

Returned statement depends on the pg_utils.postgresql_server_version():

  • for pg-server v7.2: returns nothing: the procedure is not simple,

    cf.http://www.freebsddiary.org/postgresql-dropping-constraints.php

    However this is not a problem since postgresql 7.2 implicitly drops referential integrity trigger when a table is dropped (including: primary and foreign key constraints).

  • For pg-server v7.3 the returned statement is:

    ALTER TABLE <table_name> DROP CONSTRAINT <constraint_name>
    

    where 'table_name' equals to 'entityGroup[0].externaleName()' and '<contraint_name'> is the relationship's name.

    Note: pg v7.3 does not implicitly drops any bound referential constraints anymore (except when issuing a 'DROP TABLE xxx CASCADE').

See also: foreignKeyConstraintStatementsForRelationship()

Overrides:
Modeling.SchemaGeneration.SchemaGeneration.dropForeignKeyConstraintStatementsForRelationship

dropPrimaryKeyConstraintStatementsForEntityGroup(self, entityGroup)

Returns the SQL statement used to drop the primary key constraint.

That statements depends on pg_utils.postgresql_server_version():

  • when v7.2 of the postgresql server is used, returned statement is:

    DROP INDEX <PKname>_pkey
    
where '<PK_name>' is 'entityGroup[0].primaryKeyRootName()'.
  • For v7.3, the returned statement is:

    ALTER TABLE <TABLE_NAME> DROP CONSTRAINT <PKname>_pkey
    
where '<TABLE_NAME>' equals to 'entityGroup[0].externaleName()' and '<PK_name>==entityGroup[0].primaryKeyRootName()'

See Modeling.interfaces.SchemaGeneration for further details

See also: primaryKeyConstraintStatementsForEntityGroup()

Overrides:
Modeling.SchemaGeneration.SchemaGeneration.dropPrimaryKeyConstraintStatementsForEntityGroup

dropPrimaryKeySupportStatementsForEntityGroup(self, entityGroup)

Returns a list containing a single SQLExpression statement, which takes the following form: 'DROP SEQUENCE <SEQUENCE_NAME>', where '<SEQUENCE_NAME>' is:

'PK_SEQ_%s'%entityGroup[0].primaryKeyRootName()

See Modeling.interfaces.SchemaGeneration for further details

See also: PostgresqlAdaptorChannel.primaryKeysForNewRowsWithEntity()

Overrides:
Modeling.SchemaGeneration.SchemaGeneration.dropPrimaryKeySupportStatementsForEntityGroup

foreignKeyConstraintStatementsForRelationship(self, relationship)

Returns Modeling.SchemaGeneration.foreignKeyConstraintStatementsForRelationship()
Overrides:
Modeling.SchemaGeneration.SchemaGeneration.foreignKeyConstraintStatementsForRelationship

primaryKeySupportStatementsForEntityGroup(self, entityGroup)

Returns a list containing a single SQLExpression statement, which takes the following form: 'CREATE SEQUENCE <SEQUENCE_NAME> START 1', where '<SEQUENCE_NAME>' is:

'PK_SEQ_%s'%entityGroup[0].primaryKeyRootName()

See Modeling.interfaces.SchemaGeneration for further details

See also:
dropPrimaryKeySupportStatementsForEntityGroup() PostgresqlAdaptorChannel.primaryKeysForNewRowsWithEntity()
Overrides:
Modeling.SchemaGeneration.SchemaGeneration.primaryKeySupportStatementsForEntityGroup

Generated by Epydoc 2.1 on Sat Mar 4 13:36:27 2006 http://epydoc.sf.net