Mike Bayer [Sun, 4 Jan 2015 01:43:45 +0000 (20:43 -0500)]
- The :class:`.mysql.SET` type has been overhauled to no longer
assume that the empty string, or a set with a single empty string
value, is in fact a set with a single empty string; instead, this
is by default treated as the empty set. In order to handle persistence
of a :class:`.mysql.SET` that actually wants to include the blank
value ``''`` as a legitimate value, a new bitwise operational mode
is added which is enabled by the
:paramref:`.mysql.SET.retrieve_as_bitwise` flag, which will persist
and retrieve values unambiguously using their bitflag positioning.
Storage and retrieval of unicode values for driver configurations
that aren't converting unicode natively is also repaired.
fixes #3283
Mike Bayer [Thu, 1 Jan 2015 18:47:08 +0000 (13:47 -0500)]
- restate sort_tables in terms of a more fine grained
sort_tables_and_constraints function.
- The DDL generation system of :meth:`.MetaData.create_all`
and :meth:`.Metadata.drop_all` has been enhanced to in most
cases automatically handle the case of mutually dependent
foreign key constraints; the need for the
:paramref:`.ForeignKeyConstraint.use_alter` flag is greatly
reduced. The system also works for constraints which aren't given
a name up front; only in the case of DROP is a name required for
at least one of the constraints involved in the cycle.
fixes #3282
Mike Bayer [Thu, 1 Jan 2015 18:24:32 +0000 (13:24 -0500)]
- Added a new accessor :attr:`.Table.foreign_key_constraints`
to complement the :attr:`.Table.foreign_keys` collection,
as well as :attr:`.ForeignKeyConstraint.referred_table`.
Mike Bayer [Tue, 30 Dec 2014 01:01:21 +0000 (20:01 -0500)]
- fix some RST whitespace syntactical issues in toctrees
- have the topmost toctree only include page names
- add glossary to toctree, remove search by itself
Mike Bayer [Fri, 19 Dec 2014 17:14:52 +0000 (12:14 -0500)]
- Fixed bug where using a :class:`.TypeDecorator` that implemented
a type that was also a :class:`.TypeDecorator` would fail with
Python's "Cannot create a consistent method resolution order (MRO)"
error, when any kind of SQL comparison expression were used against
an object using this type.
Mike Bayer [Wed, 17 Dec 2014 22:24:23 +0000 (17:24 -0500)]
- squash-merge the improve_toc branch, which moves all the Sphinx styling
and extensions into an external library, and also reorganizes most large documentation
pages into many small areas to reduce scrolling and better present the context
into a more fine-grained hierarchy.
Mike Bayer [Sat, 13 Dec 2014 23:04:11 +0000 (18:04 -0500)]
- rework sqlite FK and unique constraint system to combine both PRAGMA
and regexp parsing of SQL in order to form a complete picture of
constraints + their names. fixes #3244 fixes #3261
- factor various PRAGMA work to be centralized into one call
Mike Bayer [Sat, 13 Dec 2014 00:59:11 +0000 (19:59 -0500)]
- Added new method :meth:`.Session.invalidate`, functions similarly
to :meth:`.Session.close`, except also calls
:meth:`.Connection.invalidate`
on all connections, guaranteeing that they will not be returned to
the connection pool. This is useful in situations e.g. dealing
with gevent timeouts when it is not safe to use the connection further,
even for rollbacks.
references #3258
Mike Bayer [Mon, 8 Dec 2014 20:15:02 +0000 (15:15 -0500)]
- identify another spot where _handle_dbapi_error() needs to do something
differently for the case where it is called in an already-invalidated state;
don't call upon self.connection
Mike Bayer [Mon, 8 Dec 2014 19:05:20 +0000 (14:05 -0500)]
- simplify the "noconnection" error handling, setting
_handle_dbapi_exception_noconnection() to only invoke in the case
of raw_connection() in the constructor of Connection. in all other
cases the Connection proceeds with _handle_dbapi_exception() including
revalidate.
Mike Bayer [Mon, 8 Dec 2014 06:10:30 +0000 (01:10 -0500)]
- A new series of :class:`.Session` methods which provide hooks
directly into the unit of work's facility for emitting INSERT
and UPDATE statements has been created. When used correctly,
this expert-oriented system can allow ORM-mappings to be used
to generate bulk insert and update statements batched into
executemany groups, allowing the statements to proceed at
speeds that rival direct use of the Core.
fixes #3100
Mike Bayer [Sun, 7 Dec 2014 23:54:52 +0000 (18:54 -0500)]
- rework the assert_sql system so that we have a context manager to work with,
use events that are local to the engine and to the run and are removed afterwards.
Mike Bayer [Sat, 6 Dec 2014 18:30:51 +0000 (13:30 -0500)]
- SQL Server 2012 now recommends VARCHAR(max), NVARCHAR(max),
VARBINARY(max) for large text/binary types. The MSSQL dialect will
now respect this based on version detection, as well as the new
``deprecate_large_types`` flag.
fixes #3039
Mike Bayer [Sat, 6 Dec 2014 00:08:47 +0000 (19:08 -0500)]
- adjust _revalidate_connection() again such that we pass a _wrap=False
to it, so that we say we will do the wrapping just once right here
in _execute_context() / _execute_default(). An adjustment is made
to _handle_dbapi_error() to not assume self.__connection in case
we are already in an invalidated state
Mike Bayer [Fri, 5 Dec 2014 21:34:43 +0000 (16:34 -0500)]
- move inner calls to _revalidate_connection() outside of existing
_handle_dbapi_error(); these are now handled already and the reentrant
call is not needed / breaks things. Adjustment to 41e7253dee168b8c26c49 /
Mike Bayer [Fri, 5 Dec 2014 19:46:43 +0000 (14:46 -0500)]
- The SQLite dialect, when using the :class:`.sqlite.DATE`,
:class:`.sqlite.TIME`,
or :class:`.sqlite.DATETIME` types, and given a ``storage_format`` that
only renders numbers, will render the types in DDL as
``DATE_CHAR``, ``TIME_CHAR``, and ``DATETIME_CHAR``, so that despite the
lack of alpha characters in the values, the column will still
deliver the "text affinity". Normally this is not needed, as the
textual values within the default storage formats already
imply text.
fixes #3257
Mike Bayer [Fri, 5 Dec 2014 17:12:44 +0000 (12:12 -0500)]
- The engine-level error handling and wrapping routines will now
take effect in all engine connection use cases, including
when user-custom connect routines are used via the
:paramref:`.create_engine.creator` parameter, as well as when
the :class:`.Connection` encounters a connection error on
revalidation.
fixes #3266
Mike Bayer [Fri, 5 Dec 2014 00:35:00 +0000 (19:35 -0500)]
- Added support for CTEs under Oracle. This includes some tweaks
to the aliasing syntax, as well as a new CTE feature
:meth:`.CTE.suffix_with`, which is useful for adding in special
Oracle-specific directives to the CTE.
fixes #3220
Mike Bayer [Fri, 5 Dec 2014 00:12:52 +0000 (19:12 -0500)]
- Updated the "supports_unicode_statements" flag to True for MySQLdb
and Pymysql under Python 2. This refers to the SQL statements
themselves, not the parameters, and affects issues such as table
and column names using non-ASCII characters. These drivers both
appear to support Python 2 Unicode objects without issue in modern
versions.
fixes #3121
Mike Bayer [Thu, 4 Dec 2014 23:29:56 +0000 (18:29 -0500)]
- The :meth:`.Operators.match` operator is now handled such that the
return type is not strictly assumed to be boolean; it now
returns a :class:`.Boolean` subclass called :class:`.MatchType`.
The type will still produce boolean behavior when used in Python
expressions, however the dialect can override its behavior at
result time. In the case of MySQL, while the MATCH operator
is typically used in a boolean context within an expression,
if one actually queries for the value of a match expression, a
floating point value is returned; this value is not compatible
with SQLAlchemy's C-based boolean processor, so MySQL's result-set
behavior now follows that of the :class:`.Float` type.
A new operator object ``notmatch_op`` is also added to better allow
dialects to define the negation of a match operation.
fixes #3263
Mike Bayer [Thu, 4 Dec 2014 17:01:19 +0000 (12:01 -0500)]
- The :meth:`.PGDialect.has_table` method will now query against
``pg_catalog.pg_table_is_visible(c.oid)``, rather than testing
for an exact schema match, when the schema name is None; this
so that the method will also illustrate that temporary tables
are present. Note that this is a behavioral change, as Postgresql
allows a non-temporary table to silently overwrite an existing
temporary table of the same name, so this changes the behavior
of ``checkfirst`` in that unusual scenario.
fixes #3264
Mike Bayer [Sat, 29 Nov 2014 19:44:26 +0000 (14:44 -0500)]
- Fixed bug in :meth:`.Table.tometadata` method where the
:class:`.CheckConstraint` associated with a :class:`.Boolean`
or :class:`.Enum` type object would be doubled in the target table.
The copy process now tracks the production of this constraint object
as local to a type object.
fixes #3260
Mike Bayer [Wed, 26 Nov 2014 19:58:44 +0000 (14:58 -0500)]
- Updated the :ref:`examples_versioned_history` example such that
mapped columns are re-mapped to
match column names as well as grouping of columns; in particular,
this allows columns that are explicitly grouped in a same-column-named
joined inheritance scenario to be mapped in the same way in the
history mappings, avoiding warnings added in the 0.9 series
regarding this pattern and allowing the same view of attribute
keys.
Mike Bayer [Tue, 25 Nov 2014 23:01:31 +0000 (18:01 -0500)]
- The behavioral contract of the :attr:`.ForeignKeyConstraint.columns`
collection has been made consistent; this attribute is now a
:class:`.ColumnCollection` like that of all other constraints and
is initialized at the point when the constraint is associated with
a :class:`.Table`.
fixes #3243
Mike Bayer [Mon, 24 Nov 2014 23:49:32 +0000 (18:49 -0500)]
- The :meth:`.PropComparator.of_type` modifier has been
improved in conjunction with loader directives such as
:func:`.joinedload` and :func:`.contains_eager` such that if
two :meth:`.PropComparator.of_type` modifiers of the same
base type/path are encountered, they will be joined together
into a single "polymorphic" entity, rather than replacing
the entity of type A with the one of type B. E.g.
a joinedload of ``A.b.of_type(BSub1)->BSub1.c`` combined with
joinedload of ``A.b.of_type(BSub2)->BSub2.c`` will create a
single joinedload of ``A.b.of_type((BSub1, BSub2)) -> BSub1.c, BSub2.c``,
without the need for the ``with_polymorphic`` to be explicit
in the query.
fixes #3256
Mike Bayer [Mon, 24 Nov 2014 17:33:56 +0000 (12:33 -0500)]
- Fixed a bug in the examples/generic_assocaitions/discriminator_on_association.py
example, where the subclasses of AddressAssociation were not being
mapped as "single table inheritance", leading to problems when trying
to use the mappings further.
Mike Bayer [Thu, 13 Nov 2014 18:17:38 +0000 (13:17 -0500)]
- Fixed a leak which would occur in the unsupported and highly
non-recommended use case of replacing a relationship on a fixed
mapped class many times, referring to an arbitrarily growing number of
target mappers. A warning is emitted when the old relationship is
replaced, however if the mapping were already used for querying, the
old relationship would still be referenced within some registries.
fixes #3251
Mike Bayer [Tue, 11 Nov 2014 17:34:00 +0000 (12:34 -0500)]
- Fixed issue where the columns from a SELECT embedded in an
INSERT, either through the values clause or as a "from select",
would pollute the column types used in the result set produced by
the RETURNING clause when columns from both statements shared the
same name, leading to potential errors or mis-adaptation when
retrieving the returning rows.
fixes #3248
Mike Bayer [Mon, 10 Nov 2014 22:58:09 +0000 (17:58 -0500)]
- in lieu of adding a new system of translating bound parameter names
for psycopg2 and others, encourage users to take advantage of positional
styles by documenting "paramstyle". A section is added to psycopg2
specifically as this is a pretty common spot for named parameters
that may be unusually named. fixes #3246.
Mike Bayer [Mon, 10 Nov 2014 22:37:26 +0000 (17:37 -0500)]
- The :attr:`.Column.key` attribute is now used as the source of
anonymous bound parameter names within expressions, to match the
existing use of this value as the key when rendered in an INSERT
or UPDATE statement. This allows :attr:`.Column.key` to be used
as a "substitute" string to work around a difficult column name
that doesn't translate well into a bound parameter name. Note that
the paramstyle is configurable on :func:`.create_engine` in any case,
and most DBAPIs today support a named and positional style.
fixes #3245