Permalink
Commits on Aug 26, 2011
  1. Update release files for 0.3.1.

    jmafc committed Aug 26, 2011
Commits on Aug 25, 2011
  1. More fixes for quoting non-regular identifiers. Partial fix of issue #5.

     * pyrseas/dbobject/__init__.py (split_schema_table): If table name is
       quoted, strip the quotes.  (DbSchemaObject.set_search_path): Use
       quote_id.
     * pyrseas/dbobject/column.py (Column.set_sequence_default): Use
       quote_id.
     * pyrseas/dbobject/table.py (Sequence.add_owner): Use quote_id.
    jmafc committed Aug 25, 2011
  2. The 'public' schema need not exist. Workaround for issue #4.

     * pyrseas/dbconn.py (DbConnection.connect): If set search_path fails
       with public schema, try again without it.
    jmafc committed Aug 25, 2011
Commits on Aug 24, 2011
  1. Quote non-regular identifiers (except SQL keywords). Partial fix of i…

    …ssue #5.
    
     * pyrseas/dbobject/__init__.py (quote_id): New function to quote
       identifiers if needed.  (DbObject.identifier,
       DbSchemaObject.qualname): Use new quote_id function.
     * pyrseas/dbobject/column.py (Column.add): Use quote_id.
     * pyrseas/dbobject/constraint.py (Constraint.{key_columns,create}):
       Use quote_id.
     * pyrseas/dbobject/index.py (Index.create): Use quote_id.
     * pyrseas/dbobject/language.py (Language.create): Use quote_id.
       (LanguageDict.from_map): Replace str.split() by str.find(' ') to
       correctly separate the name.
     * pyrseas/dbobject/rule.py (Rule.{identifier,create}): Use quote_id.
     * pyrseas/dbobject/schema.py (Schema.create): Use quote_id.
       (SchemaDict.from_map): Replace str.split() by str.find(' ') to
       correctly separate the name.
     * pyrseas/dbobject/table.py (Sequence.get_attrs): Use quote_id.
     * pyrseas/dbobject/trigger.py (Trigger.{identifier,create}): Use
       quote_id.
    jmafc committed Aug 24, 2011
Commits on Jun 30, 2011
  1. Update release files for 0.3.0.

    jmafc committed Jun 30, 2011
  2. Add support for SECURITY DEFINER functions.

     * pyrseas/dbobject/function.py (Function.create): Output SECURITY
       DEFINER if needed.  (ProcDict.query): Retrieve prosecdef.
     * tests/dbobject/test_function.py: New tests for SECURITY DEFINER
       functions.
    jmafc committed Jun 30, 2011
Commits on Jun 29, 2011
  1. Add support for functions returning table row types.

     * docs/table.rst: Add automethod for Table.drop.
     * pyrseas/dbobject/function.py (Function.to_map): Don't expose
       dependent_table.  (Function.create): If function has a dependent
       table, create that first.
     * pyrseas/dbobject/schema.py (SchemaDict.link_refs): Add
       dependent_table attribute to functions returning row types, and
       link back the tables to the function.
     * pyrseas/dbobject/table.py (Table.create): Add a created attribute
       to bypass duplicate creation.  (Table.drop): New method so any
       dependent functions can be dropped before the table itself.
     * tests/dbobject/test_function.py: New tests for void function and
       functions returning a set of rows.
    jmafc committed Jun 29, 2011
Commits on Jun 24, 2011
  1. Correct order of dropping certain database objects.

     * pyrseas/database.py (Database.diff_map): Drop functions before
       schemas and add dropping of types.
     * pyrseas/dbobject/column.py (ColumnDict.query): Use pg_get_expr() to
       get DEFAULT.
     * pyrseas/dbobject/constraint.py (ConstraintDict.diff_map): Skip
       domains when dropping CHECK constraints.
     * pyrseas/dbobject/dbtype.py (TypeDict.diff_map): Don'd drop types
       yet.  (TypeDict._drop): New method to actually drop the types.
     * pyrseas/dbobject/table.py (Sequence.get_dependent_table): Renamed
       from get_owner. Add query against pg_depend and pg_attrdef to
       determine the dependent table (when an owner table isn't present).
       (Sequence.to_map): Don't map dependent_table.
       (ClassDict._from_catalog): Change get_owner to get_dependent_table.
       (ClassDict.diff_map): Drop rules. If a sequence has a dependent
       table, postpone dropping it until after the tables are dropped.
    jmafc committed Jun 24, 2011
Commits on Jun 23, 2011
  1. Add support for creation of indexes using expressions.

     * pyrseas/dbobject/index.py (Index.create): Use key_columns() or
       expression depending on existence of keycols.
       (IndexDict.from_map): Check whether columns or expression is
       present.
     * tests/dbobject/test_index.py: New test to verify creation of
       indexes on expressions and failing when neither column or
       expression is in the input map.
    jmafc committed Jun 23, 2011
Commits on Jun 22, 2011
  1. Add support for indexes on expressions. Fixes issue #3.

     * pyrseas/dbobject/index.py (Index.to_map): Make key columns
       specification conditional.  (IndexDict.query): Add expression to
       target list.  (IndexDict._from_catalog): Eliminate keycols if array
       is zero.
     * tests/dbobject/test_index.py
       (IndexToMapTestCase.test_index_function): New test for indexes on
       expressions.
    jmafc committed Jun 22, 2011
  2. Triggers should be dropped before the corresponding functions.

     * pyrseas/database.py (Database.diff_map): Add call to
       functions._drop.
     * pyrseas/dbobject/function.py (ProcDict.diff_map): Only mark
       functions for dropping.  (ProcDict._drop): New function to actually
       drop the functions.
    jmafc committed Jun 22, 2011
  3. Add support for rewrite rules.

     * docs/index.rst: Add rule.rst.
     * docs/rule.rst: New page to document rule objects.
     * pyrseas/database.py (Database.Dicts.__init__): Initialize RuleDict.
       (Database._link_refs): Add rules argument to tables.link_refs.
       (Database.diff_map): Add call to rules.diff_map.
     * pyrseas/dbobject/rule.py: New module to implement rule support.
     * pyrseas/dbobject/table.py (Table.to_map, ClassDict.from_map):
       Handle rules if present.  (ClassDict.link_refs): Add dbrules
       argument and process it.  (ClassDict.diff_map): Handle dropping of
       rules.
     * tests/dbobject/__init__.py: Invoke rule tests.
     * tests/dbobject/test_rule.py: New test module.
    jmafc committed Jun 22, 2011
Commits on Jun 17, 2011
  1. Add support for AGGREGATE functions and enhance regular functions.

     * docs/function.rst: Add documentation for Procedure and Aggregate,
       change FunctionDict to ProcDict.
     * pyrseas/database.py (Database.Dicts.__init__): Change FunctionDict
       to ProcDict.  (Database._link_refs): Add call to
       languages.link_refs.  (Database.diff_map): Move call to diff_map
       for functions before the one for tables.
     * pyrseas/dbobject/constraint.py (ConstraintDict.diff_map): Skip
       DOMAIN constraints.
     * pyrseas/dbobject/function.py (Proc): New class to inherit from
       DbSchemaObject, have Function and new class Aggregate derive from
       Proc.  (Aggregate): New class to implement AGGREGATE functions.
       (ProcDict): Renamed from FunctionDict and changed to support
       AGGREGATEs.
     * pyrseas/dbobject/language.py (Language.to_map): Don't expose
       functions in the language, they'll show up under the schema.
       (LanguageDict.link_refs): Get language for functions and properly
       link them.
     * pyrseas/dbobject/schema.py (SchemaDict.from_map): Handle aggregates
       when present.
     * pyrseas/dbobject/table.py (Sequence): Remove redundant keylist.
     * tests/dbobject/test_function.py: Add tests for AGGREGATEs and
       adjust function tests for possible SET check_function_bodies.
     * tests/dbobject/test_language.py: Add test for dropping function and
       language together.
     * tests/dbobject/test_trigger.py: Adjust tests for possible SET
       check_function_bodies statement.
    jmafc committed Jun 17, 2011
Commits on Jun 10, 2011
  1. Add support for enumerated types.

     * docs/type.rst: Add Enum documentation.
     * pyrseas/dbobject/dbtype.py (Enum): New class.  (TypeDict.query):
       Fetch enum labels from pg_enum.  (TypeDict._fromCatalog):
       Reinitialize Enum's.  (TypeDict.from_map): Map input enumerated
       types.  (TypeDict.diff_map): Remove limitation to domains.
     * pyrseas/dbobject/schema.py (Schema.to_map): Map types if present.
       (SchemaDict.from_map): Handle types.  (SchemaDict.link_refs): Link
       enums to schema.types and fix schema.domains.
     * tests/dbobject/__init__.py: Invoke type tests.
     * tests/dbobject/test_type.py: New test module.
     * tests/dbobject/utils.py (PostgresDb.clear): Drop types.
    jmafc committed Jun 10, 2011
Commits on Jun 8, 2011
  1. Add support for domains.

     * docs/index.rst: Add type.rst.
     * docs/table.rst: Remove note about views.
     * docs/type.rst: New page to document types and domains.
     * pyrseas/database.py (Database.Dicts.__init__): Add dictionary for
       types.  (Database._link_refs): Add types argument when calling
       schemas.link_refs.  (Database.diff_map): Call types.diff_map.
     * pyrseas/dbobject/constraint.py (CheckConstraint.to_map): Delete
       target attribute if present. Dbcols argument may be None.
       (ConstraintDict.query): Adjust 'table' to cover both tables and
       domains and add 'target' to differentiate domains from tables.
       (ConstraintDict.from_map): New argument 'target' for domains.
     * pyrseas/dbobject/dbtype.py: New module to implement domains.
     * pyrseas/dbobject/schema.py (Schema.to_map): Map domains if present.
       (SchemaDict.from_map): Handle domains and types.
       (SchemaDict.link_refs): Add dbtypes argument and traverse it to
       link domains.
     * pyrseas/dbobject/table.py (ClassDict.link_refs): Use 'target'
       attribute to skip over domains.
     * tests/dbobject/__init__.py: Invoke domain tests.
     * tests/dbobject/test_domain.py: New test module.
     * tests/dbobject/utils.py ((PostgresDb.clear): Drop domains.
    jmafc committed Jun 8, 2011
Commits on Jun 7, 2011
  1. Merge branch 'r0.2'

    jmafc committed Jun 7, 2011
  2. Update NEWS for release 0.2.1.

    jmafc committed Jun 7, 2011
  3. Deal with dropped columns by retrieving attisdropped. Fixes issue #2.

     * pyrseas/dbobject/column.py (Column.to_map): Return None if column
       has been dropped.  (Column.drop): Return empty statement if column
       dropped. (ColumnDict.query): Retrieve attisdropped instead of
       restricting on it.
     * pyrseas/dbobject/table.py (Table.to_map): Skip columns that have
       been dropped.
     * tests/dbobject/test_constraint.py (ForeignKeyToMapTestCase): Two
       new test cases, for multiple foreign keys and foreign keys where
       columns have been dropped.
    jmafc committed Jun 7, 2011
Commits on May 27, 2011
  1. Don't provide host/port defaults in order to use sockets for local te…

    …sting.
    
     * pyrseas/dbconn.py (DbConnection.__init__): If host is None,
       127.0.0.1 or localhost, and if port is None or 5432, don't include
       them in the connection string.  (DbConnection.connect): self.host
       and self.port now have part of the connection string.
     * tests/dbobject/utils.py (pgconnect): If host is None, 127.0.0.1 or
       localhost, and if port is None or 5432, don't include them in the
       connection string. (TEST_HOST, TEST_PORT): Use None as defaults.
       (PostgresDb.__init__): Adjust for possible port being None.
    jmafc committed May 27, 2011
Commits on May 26, 2011
  1. Add support for triggers.

     * docs/index.rst: Add trigger.rst.
     * docs/trigger.rst: New page to document triggers.
     * pyrseas/database.py (Database.Dicts.__init__): Add dictionary for
       triggers.  (Database._link_refs): Add triggers argument when
       calling tables.link_refs.  (Database.diff_map): Call
       triggers.diff_map.
     * pyrseas/dbconn.py (DbConnection.connect): Convert version to int.
     * pyrseas/dbobject/function.py: Miscellaneous cleanup.
     * pyrseas/dbobject/table.py (Table.to_map, ClassDict.from_map):
       Handle triggers if present.  (ClassDict.link_refs): New dbtriggers
       argument.  (ClassDict.diff_map): Drop triggers before dropping
       tables.
     * pyrseas/dbobject/trigger.py: New module to implement feature.
     * tests/dbobject/__init__.py: Invoke trigger tests.
     * tests/dbobject/test_function.py
       (FunctionToMapTestCase.test_map_function_with_args): Remove
       'arguments' from map.
     * tests/dbobject/test_trigger.py: New test module.
     * tests/dbobject/utils.py (PostgresDb.clear): Drop PL/pgSQL if
       installed and version before 9.0.
       (PostgresDb.is_plpgsql_installed): New method.
    jmafc committed May 26, 2011
Commits on May 19, 2011
  1. Update NEWS for release 0.2.0.

    jmafc committed May 19, 2011
  2. Changes for release 0.2.0 and distribution via PGXN.

     * .gitignore: Add 'build' subdirectory.
     * MANIFEST.in: Include Makefile and META.json.
     * META.json: New file required by PGXN.
     * Makefile: New file needed by PGXN.
     * docs/conf.py: Change version/release identifiers.
     * docs/index.rst: Add install.rst.
     * docs/install.rst: New file documenting installation procedures.
     * setup.py: Change version.
    jmafc committed May 19, 2011
Commits on May 17, 2011
  1. Add support for testing against multiple PostgreSQL versions.

     * docs/dbconn.rst: Document new version property.
     * pyrseas/database.py (Database.diff_map): Pass version as argument
       to languagues.diff_map.
     * pyrseas/dbconn.py (DbConnection): Add version as property, fetch on
       connect.
     * pyrseas/dbobject/language.py (LanguageDict.diff_map): Add dbversion
       parameter and use it to special case plpgsql.
       (LanguageDict._drop): Fix leftover code pasted from SchemaDict.
     * tests/dbobject/test_constraint.py
       (ForeignKeyToMapTestCase.test_cross_schema_foreign_key): Split
       expected maps to version diffs due to plpgsql.
       (UniqueConstraintToMapTestCase): Adjust map_unique2 for different
       default constraint naming between versions.
     * tests/dbobject/utils.py (pgconnect): Do not specify parameter
       defaults.  (PostgresDb.__init__): New arguments/attributes user,
       host and port and internal attribute _version.
       (PostgresDb.connect): Always close the admin connection. Fetch
       server_version_num.  (PostgresDb.version): New property.
       (PostgresDb.{connect,create,drop}): Add new arguments to pgconnect
       calls.  (PostgresDb.{execute_and_map,process_map}): Pass user, host
       and port to DbConnection.  (PyrseasTestCase.setUp): Parameterize
       PostgresDb creation using environment variables.
    jmafc committed May 17, 2011
Commits on May 13, 2011
  1. Add basic support for functions.

     * docs/dbobject.rst: Add new automethods and remove refactored
       automethod.
     * docs/function.rst: New file to document functions.
     * docs/index.rst: Add function.rst.
     * pyrseas/database.py (Database.Dicts.__init__): Add functions.
       (Database.{_link_refs,from_catalog,from_map}): Refactor code into
       new internal method.  (Database.diff_map): Call functions.diff_map.
     * pyrseas/dbobject/__init__.py (DbObject.{identifier,comment,drop}):
       New identifier method for use by comment and drop.
       (DbObject.diff_description): Refactored from table.py.
       (DbSchemaObject.identifier): New method override.
       (DbSchemaObject.comment): Removed.  (DbSchemaObject.drop): Updated
       to use new identifier method.
     * pyrseas/dbobject/function.py: New module for added functionality.
     * pyrseas/dbobject/schema.py (Schema.to_map): Handler functions.
       (Schema.from_map): Split input schema into table-related objects
       and functions.  (Schema.link_refs): Add dbfunctions argument and
       handle it.
     * pyrseas/dbobject/table.py (DbClass.diff_description): Removed.
     * tests/dbobject/__init__.py: Invoke function tests.
     * tests/dbobject/test_function.py: New test module.
     * tests/dbobject/utils.py (PostgresDb.clear): Add code to drop
       existing functions.
    jmafc committed May 13, 2011
Commits on May 11, 2011
  1. Add basic support for procedural languages.

     * docs/dbobject.rst: Add refactored automethods for DbObject.
     * docs/index.rst: Add language entry.
     * docs/language.rst: New file to document language classes.
     * docs/schema.rst: Remove refactored automethods from Schema.
     * pyrseas/database.py (Database.Dicts.__init__): Initialize a
       LanguageDict. (Database.from_map): Split input map into schemas and
       languages.  (Database.to_map): Construct the output map in two
       stages.  (Database.diff_map): Add support for languages.
     * pyrseas/dbobject/__init__.py: Refactor extern_key from
       DbSchemaObject (and Schema) to DbObject. Refactor comment, drop and
       rename methods from Schema into DbObject.
     * pyrseas/dbobject/language.py: New module for procedural languages.
     * pyrseas/dbobject/schema.py (Schema): Remove extern_key, comment,
       drop and rename methods.
     * tests/dbobject/__init__.py: Invoke language tests.
     * tests/dbobject/test_language.py: New test module.
    jmafc committed May 11, 2011
Commits on May 6, 2011
  1. Add support for inherited tables.

     * pyrseas/dbobject/__init__.py (split_schema_table): New utility
       function split schema-qualified names.  (DbSchemaObject.unqualify):
       Use new function.
     * pyrseas/dbobject/column.py (Column.to_map): Map inherited columns.
       (ColumnDict.query): Retrieve attinhcount as 'inherited'.
     * pyrseas/dbobject/constraint.py (ConstraintDict._from_catalog):
       Recall code by call to split_schema_table.
     * pyrseas/dbobject/table.py (Sequence.get_owner): Replace code by
       call to split_schema_table.  (Table.to_map): Map inherited tables.
       (Table.create): Add INHERITS clause and deal with inherited
       columns.  (ClassDict.inhquery): New query from pg_inherits.
       (ClassDict._from_catalog): Fetch inheritance info.
       (ClassDict.from_map): Map 'inherits' info.  (ClassDict.link_refs):
       Add links for descendant tables.  (ClassDict.diff_map): Deal with
       inherited tables, both for create and drop.
     * tests/dbobject/test_table.py:  Add tests for inherited tables.
     * tests/dbobject/utils.py (PostgresDb.clear): Use IF EXISTS for
       dropping tables.
    jmafc committed May 6, 2011
Commits on Apr 29, 2011
  1. Add support for views.

     * docs/database.rst: Add view entry to example map. Add and correct
       references to lower level maps.
     * docs/table.rst: Add autoclass/method under Database Class. Fix
       example table map. Add section for class View.
     * pyrseas/dbobject/schema.py (Schema.to_map, SchemaDict.link_refs):
       Add code for dealing with views.
     * pyrseas/dbobject/table.py (DbClass.diff_description): New method to
       abstract handling of comments for tables, sequences or views.
       (Table.diff_map): Call new method (to which the code was moved).
       (View): New class for views.  (ClassDict.query): Add view
       definition to target list and include relkind == 'v' in
       restriction.  (ClassDict._from_catalog): Instantiate View objects.
       (ClassDict.from_map): Handle view objects.  (ClassDict.diff_map):
       Add handling for views.
     * tests/dbobject/__init__.py: Call test_view suite.
     * tests/dbobject/test_schema.py (SchemaToSqlTestCase.
       test_drop_schema): Late fix to remove CASCADE.
     * tests/dbobject/test_sequence.py: Correct header comment.
     * tests/dbobject/test_view.py: New module to test new functionality.
     * tests/dbobject/utils.py (fix_indent): Ensure strings of multiple
       spaces are handled correctly.  (PostgresDb.clear): Include views in
       objects to drop.  (PostgresDb.execute): Remove leftover print.
    jmafc committed Apr 29, 2011
Commits on Apr 26, 2011
  1. Correct dropping of PRIMARY KEYs that are still being referenced.

     * pyrseas/dbobject/table.py (ClassDict.diff_map): Drop all FOREIGN
       KEYs separately first, then drop all other subordinate objects
       and the table itself.
    jmafc committed Apr 26, 2011
Commits on Apr 22, 2011
  1. Possibly temporary solution to dropping schemas.

     * pyrseas/database.py (Database.diff_map): Call new SchemaDict._drop
       before returning.
     * pyrseas/dbobject/schema.py (Schema.drop): Don't use CASCADE.
       (SchemaDict.diff_map): Only mark schemas to be dropped.
       (SchemaDict._drop): New method to actually DROP the schemas.
    jmafc committed Apr 22, 2011
Commits on Apr 21, 2011
Commits on Apr 20, 2011
  1. Add support for RENAME COLUMN.

     * docs/column.rst: Add automethod Column.rename.
     * pyrseas/dbobject/__init__.py (DbSchemaObject.rename): Document
       missing parameter newname.
     * pyrseas/dbobject/column.py (Column.to_map): Delete _table from the
       external dictionary.  (Column.comment): Eliminate tbl argument and
       use internal _table link argument instead.  (Column.rename): New
       method to return ALTER TABLE RENAME COLUMN.  (ColumnDict.diff_map):
       Correct for loop to use all key values.
     * pyrseas/dbobject/table.py (Table.create): Don't pass self as
       argument to Column.comment.  (Table.diff_map): Check for and
       process possible column RENAME.  (ClassDict.link_refs): Add a
       _table back link from each column to the containing table.
       (ClassDict._rename): Copy the old table/sequence to the new one
       before deleting the old.
     * tests/dbobject/test_constraint.py (ForeignKeyToSqlTestCase.
       test_drop_foreign_key): Correct column specs.
     * tests/dbobject/test_table.py: New test to check column RENAME.
    jmafc committed Apr 20, 2011
Commits on Apr 18, 2011
  1. Add support for FOREIGN KEY ON UPDATE/ON DELETE actions.

     * docs/constraint.rst: Add example map including on_update/on_delete.
     * pyrseas/dbobject/constraint.py (ForeignKey.add): Tack on actions to
       SQL statement if on_update/on_delete are present.
       (ConstraintDict.query): Retrieve confupdtype and confdeltype as
       on_update and on_delete, respectively.
       (ConstraintDict._from_catalog): Handle on_update/on_delete when
       constructing a ForeignKey.  (ConstraintDict.from_map): Handle and
       validate on_update/on_delete actions in input.
     * tests/dbobject/test_constraint.py: Add tests to check mapping and
       SQL generation of ON UPDATE/ON DELETE actions.
    jmafc committed Apr 18, 2011
Commits on Apr 15, 2011
  1. Add support for comments on schemas, tables and columns.

      * docs/column.rst docs/dbobject.rst, docs/schema.rst: Add new
        automethods.
      * pyrseas/dbobject/__init__.py (DbObject.__init__): Only discard
        non-key attributes without a value.  (DbSchemaObject.comment): New
        method to return a COMMENT.
      * pyrseas/dbobject/column.py (Column.comment): New method.
        (ColumnDict.query): Add description.
      * pyrseas/dbobject/schema.py (Schema._to_map): Add description if
        present.  (Schema.comment): New method to return a COMMENT.
        (Schema.create): Return comment if self has description.
        (Schema.diff_map): New method, mainly to deal with descriptions.
        (SchemaDict.query): Add description.  (SchemaDict.from_map): Add
        description if present.  (SchemaDict.diff_map): Add comparison of
        input and db maps.
      * pyrseas/dbobject/table.py (Table.create): Return comment if self
        has description and do the same for each column.
        (Table.diff_map): Deal with descriptions.  (ClassDict.query): Add
        description.  (ClassDict.from_map): Disregard description at
        schema level, handle description at table level.
      * tests/dbobject/test_constraints.py: Don't validate public schema,
        except where absolutely necessary (to avoid its comments). Use
        new_std_map to create input maps.
      * tests/dbobject/test_index.py: Use new_std_map to create input
        maps.
      * tests/dbobject/test_schema.py: Don't validate public schema (to
        avoid its comments). New test cases for comments on schemas.
      * tests/dbobject/test_sequence.py: Use new_std_map to create input
        maps.
      * tests/dbobject/test_table.py: Use new_std_map to create input
        maps. New test cases for comments on tables and columns.
      * tests/dbobject/utils.py: New function new_std_map.
    jmafc committed Apr 15, 2011