Commit Graph

33 Commits

Author SHA1 Message Date
Mike Bayer da3d817f36 Added a new argument to :class:.Enum and its base
:class:`.SchemaType` ``inherit_schema``.  When set to ``True``,
the type will set its ``schema`` attribute of that of the
:class:`.Table` to which it is associated.  This also occurs
during a :meth:`.Table.tometadata` operation; the :class:`.SchemaType`
is now copied in all cases when :meth:`.Table.tometadata` happens,
and if ``inherit_schema=True``, the type will take on the new
schema name passed to the method.   The ``schema`` is important
when used with the Postgresql backend, as the type results in
a ``CREATE TYPE`` statement. [ticket:2657]
2013-02-01 20:47:02 -05:00
Mike Bayer e26b28224d Fixed bug where :meth:.Table.tometadata would fail if a
:class:`.Column` had both a foreign key as well as an
alternate ".key" name for the column.   Also in 0.7.10.
[ticket:2643]
2013-01-27 11:23:59 -05:00
Mike Bayer 3859742a91 Fixed bug where using server_onupdate=<FetchedValue|DefaultClause>
without passing the "for_update=True" flag would apply the default
object to the server_default, blowing away whatever was there.
The explicit for_update=True argument shouldn't be needed with this usage
(especially since the documentation shows an example without it being
used) so it is now arranged internally using a copy of the given default
object, if the flag isn't set to what corresponds to that argument.
Also in 0.7.10. [ticket:2631]
2012-12-08 20:28:43 -05:00
Mike Bayer 20cdc64588 trying different approaches to test layout. in this one, the testing modules
become an externally usable package but still remains within the main sqlalchemy parent package.
in this system, we use kind of an ugly hack to get the noseplugin imported outside of the
"sqlalchemy" package, while still making it available within sqlalchemy for usage by
third party libraries.
2012-09-27 02:37:33 -04:00
Mike Bayer 152163b333 - [bug] When the primary key column of a Table
is replaced, such as via extend_existing,
    the "auto increment" column used by insert()
    constructs is reset.  Previously it would
    remain referring to the previous primary
    key column.  [ticket:2525]
2012-09-23 12:51:24 -04:00
Mike Bayer e354dd10f8 - [feature] An explicit error is raised when
a ForeignKeyConstraint() that was
    constructed to refer to multiple remote tables
    is first used. [ticket:2455]
2012-09-23 12:42:38 -04:00
Mike Bayer 4da34b4cb7 - clean pyflakes 2012-09-23 12:31:41 -04:00
Mike Bayer 7e815c67a9 finished fixes for mxodbc; need to use at least version 3.2.1 2012-09-21 17:43:22 -04:00
Mike Bayer 1c325dc9c7 - [feature] Added a hook to the system of rendering
CREATE TABLE that provides access to the render for each
Column individually, by constructing a @compiles
function against the new schema.CreateColumn
construct.  [ticket:2463]
2012-09-09 14:39:25 -04:00
Mike Bayer f46f16d4c7 fixes to prevent the new MyISAM engine from breaking other tests 2012-08-29 12:16:18 -04:00
Mike Bayer 7a81ecc82c - adjustments for py3.3 unit tests, [ticket:2542] 2012-08-11 21:46:48 -04:00
Mike Bayer 22ba1c43b7 -whitespace bonanza, contd 2012-07-28 17:05:50 -04:00
Mike Bayer d50ea3eabf - [bug] Index will raise when arguments passed
cannot be interpreted as columns or expressions.
Will warn when Index is created
with no columns at all.  [ticket:2380]
2012-02-12 17:47:36 -05:00
Mike Bayer 96dce7686c - [feature] New reflection feature "autoload_replace";
when set to False on Table, the Table can be autoloaded
without existing columns being replaced.  Allows
more flexible chains of Table construction/reflection
to be constructed, including that it helps with
combining Declarative with table reflection.
See the new example on the wiki.  [ticket:2356]

- [bug] Improved the API for add_column() such that
if the same column is added to its own table,
an error is not raised and the constraints
don't get doubled up.  Also helps with some
reflection/declarative patterns. [ticket:2356]
2012-01-28 15:54:28 -05:00
Mike Bayer 8301651428 - [feature] Added new support for remote "schemas":
- MetaData() accepts "schema" and "quote_schema"
      arguments, which will be applied to the same-named
      arguments of a Table
      or Sequence which leaves these at their default
      of ``None``.
    - Sequence accepts "quote_schema" argument
    - tometadata() for Table will use the "schema"
      of the incoming MetaData for the new Table
      if the schema argument is explicitly "None"
    - Added CreateSchema and DropSchema DDL
      constructs - these accept just the string
      name of a schema and a "quote" flag.
    - When using default "schema" with MetaData,
      ForeignKey will also assume the "default" schema
      when locating remote table.  This allows the "schema"
      argument on MetaData to be applied to any
      set of Table objects that otherwise don't have
      a "schema".
    - a "has_schema" method has been implemented
      on dialect, but only works on Postgresql so far.
    Courtesy Manlio Perillo, [ticket:1679]
2011-10-23 16:57:48 -04:00
Mike Bayer e4c04590a6 - Modified Column.copy() to use _constructor(),
which defaults to self.__class__, in order to
    create the new object.  This allows easier support
    of subclassing Column.  [ticket:2284]
2011-09-23 20:51:58 -04:00
Mike Bayer 76a9219a1e - Added a slightly nicer __repr__() to SchemaItem
classes.  Note the repr here can't fully support
the "repr is the constructor" idea since schema
items can be very deeply nested/cyclical, have
late initialization of some things, etc.
[ticket:2223]
2011-08-14 12:20:54 -04:00
Mike Bayer c1295ce57b - Added an informative error message when
ForeignKeyConstraint refers to a column name in
    the parent that is not found.  Also in 0.6.9.
- add tests for [ticket:2226], as if we hit each @declared_attr
directly with obj.__get__(obj, name) instead of using
getattr(cls, name).  Basic inheritance mechanics are improperly
used in this case, so 2226 is invalid.
2011-07-21 11:44:31 -04:00
Mike Bayer 3452a2ba03 - Fixed bug whereby if FetchedValue was passed
to column server_onupdate, it would not
have its parent "column" assigned, added
test coverage for all column default assignment
patterns.  [ticket:2147]  also in 0.6.8
2011-04-23 12:34:17 -04:00
Mike Bayer 0c560edee7 - Added explicit check for when Column .name
is assigned as blank string [ticket:2140]
2011-04-20 15:49:33 -04:00
Mike Bayer ae363b0663 - Before/after attach events for PrimaryKeyConstraint
now function, tests added for before/after events
on all constraint types.  [ticket:2105]
2011-04-17 13:53:21 -04:00
Mike Bayer d34bc7da31 - The 'useexisting' flag on Table has been superceded
by a new pair of flags 'keep_existing' and
'extend_existing'.   'extend_existing' is equivalent
to 'useexisting' - the existing Table is returned,
and additional constructor elements are added.
With 'keep_existing', the existing Table is returned,
but additional constructor elements are not added -
these elements are only applied when the Table
is newly created.   [ticket:2109]
2011-04-05 12:04:42 -04:00
Mike Bayer 68a350d462 - remove test.sql._base, test.engine._base, test.orm._base, move those classes to a new test.lib.fixtures module
- move testing.TestBase to test.lib.fixtures
- massive search and replace
2011-03-27 16:27:27 -04:00
Mike Bayer ebd0fdad73 - convert @provide_metadata to use self access
- having occasional issues with BasicEntity grabbing, if it persists
may have to pass an explicit base class into setup_classes()/setup_mappers()
2011-03-26 21:40:05 -04:00
Mike Bayer de529fb81c - adjust the previous checkin a bit. need to transfer sequences over from pickle
even if they are *not* restated.  its necessary here to do a "replacement"
scheme when an incoming sequence replaces the previous.  Theoretically
we could do what Table does here, i.e. use a singleton constructor, but
this is heavyhanded.   The most recent sequence placed in is the winner
is likely the most expected behavior.
2011-03-23 17:38:54 -04:00
Mike Bayer 93da3087f1 - Fixed regression whereby MetaData() coming
back from unpickling did not keep track of
new things it keeps track of now, i.e.
collection of Sequence objects, list
of schema names.  [ticket:2104]
2011-03-23 17:25:57 -04:00
Mike Bayer cf51131150 - Added a fully descriptive error message for the
case where Column is subclassed and _make_proxy()
fails to make a copy due to TypeError on the
constructor.   The method _constructor should
be implemented in this case.
2011-02-28 12:47:04 -05:00
Mike Bayer 01cb94690d - The Column.references() method now returns True
if it has a foreign key referencing the
given column exactly, not just it's parent
table.  [ticket:2064]
2011-02-17 20:27:35 -05:00
Mike Bayer 12073e281e - SchemaItem, SchemaType now descend from common type
SchemaEventTarget, which supplies dispatch
- the dispatch now provides before_parent_attach(),
after_parent_attach(), events which generally bound the _set_parent()
event. [ticket:2037]
- the _on_table_attach mechanism now usually uses the
event dispatch
- fixed class-level event dispatch to propagate to all subclasses, not just
immediate subclasses
- fixed class-level event unpickling to handle more involved
inheritance hierarchies, needed by the new schema event dispatch.
- ForeignKeyConstraint doesn't re-call the column attach event
on ForeignKey objects that are already associated with the correct
Column
- we still need that ImportError on mysqldb CLIENT FLAGS to support
mock DBAPIs
2011-01-30 20:29:48 -05:00
Mike Bayer 1c1ff92fa9 - Column.copy(), as used in table.tometadata(), copies the
'doc' attribute.  [ticket:2028]
2011-01-30 13:09:45 -05:00
Mike Bayer 4e9e0f041c - merge r43460573c27a:4993c7eae8e5d117ff342bdc59f3b0635b898e2c of 0.6 branch 2011-01-08 16:14:47 -05:00
Mike Bayer 350aed3fdb - whitespace removal bonanza 2011-01-02 14:23:42 -05:00
Mike Bayer 71083b6977 combine test/engine/test_metadata.py and test/sql/test_columns.py into new
test/sql/test_metadata.py, [ticket:1970]
2010-11-28 15:34:41 -05:00