Sqlalchemy

Latest version: v2.0.31

Safety actively analyzes 640296 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 33 of 50

1.0.0b1

Not secure
:released: March 13, 2015

Version 1.0.0b1 is the first release of the 1.0 series. Many changes
described here are also present in the 0.9 and sometimes the 0.8
series as well. For changes that are specific to 1.0 with an emphasis
on compatibility concerns, see :doc:`/changelog/migration_10`.

.. change::
:tags: feature, ext
:tickets: 3054

Added a new extension suite :mod:`sqlalchemy.ext.baked`. This
simple but unusual system allows for a dramatic savings in Python
overhead for the construction and processing of orm :class:`_query.Query`
objects, from query construction up through rendering of a string
SQL statement.

.. seealso::

:ref:`baked_toplevel`

.. change::
:tags: bug, postgresql
:tickets: 3319

The PostgreSQL :class:`_postgresql.ENUM` type will emit a
DROP TYPE instruction when a plain ``table.drop()`` is called,
assuming the object is not associated directly with a
:class:`_schema.MetaData` object. In order to accommodate the use case of
an enumerated type shared between multiple tables, the type should
be associated directly with the :class:`_schema.MetaData` object; in this
case the type will only be created at the metadata level, or if
created directly. The rules for create/drop of
PostgreSQL enumerated types have been highly reworked in general.

.. seealso::

:ref:`change_3319`

.. change::
:tags: feature, orm
:tickets: 3317

Added a new event suite :class:`.QueryEvents`. The
:meth:`.QueryEvents.before_compile` event allows the creation
of functions which may place additional modifications to
:class:`_query.Query` objects before the construction of the SELECT
statement. It is hoped that this event be made much more
useful via the advent of a new inspection system that will
allow for detailed modifications to be made against
:class:`_query.Query` objects in an automated fashion.

.. seealso::

:class:`.QueryEvents`


.. change::
:tags: feature, orm
:tickets: 3249

The subquery wrapping which occurs when joined eager loading
is used with a one-to-many query that also features LIMIT,
OFFSET, or DISTINCT has been disabled in the case of a one-to-one
relationship, that is a one-to-many with
:paramref:`_orm.relationship.uselist` set to False. This will produce
more efficient queries in these cases.

.. seealso::

:ref:`change_3249`


.. change::
:tags: bug, orm
:tickets: 3301

Fixed bug where the session attachment error "object is already
attached to session X" would fail to prevent the object from
also being attached to the new session, in the case that execution
continued after the error raise occurred.

.. change::
:tags: bug, orm, declarative
:tickets: 3219, 3240

Fixed bug where using an ``__abstract__`` mixin in the middle
of a declarative inheritance hierarchy would prevent attributes
and configuration being correctly propagated from the base class
to the inheriting class.

.. change::
:tags: feature, sql
:tickets: 918

The SQL compiler now generates the mapping of expected columns
such that they are matched to the received result set positionally,
rather than by name. Originally, this was seen as a way to handle
cases where we had columns returned with difficult-to-predict names,
though in modern use that issue has been overcome by anonymous
labeling. In this version, the approach basically reduces function
call count per-result by a few dozen calls, or more for larger
sets of result columns. The approach still degrades into a modern
version of the old approach if any discrepancy in size exists between
the compiled set of columns versus what was received, so there's no
issue for partially or fully textual compilation scenarios where these
lists might not line up.

.. change::
:tags: feature, postgresql

The PG8000 dialect now supports the
:paramref:`_sa.create_engine.encoding` parameter, by setting up
the client encoding on the connection which is then intercepted
by pg8000. Pull request courtesy Tony Locke.

.. change::
:tags: feature, postgresql

Added support for PG8000's native JSONB feature. Pull request
courtesy Tony Locke.

.. change::
:tags: change, orm

Mapped attributes marked as deferred without explicit undeferral
will now remain "deferred" even if their column is otherwise
present in the result set in some way. This is a performance
enhancement in that an ORM load no longer spends time searching
for each deferred column when the result set is obtained. However,
for an application that has been relying upon this, an explicit
:func:`.undefer` or similar option should now be used.

.. change::
:tags: feature, orm
:tickets: 3307

Mapped state internals have been reworked to allow for a 50% reduction
in callcounts specific to the "expiration" of objects, as in
the "auto expire" feature of :meth:`.Session.commit` and
for :meth:`.Session.expire_all`, as well as in the "cleanup" step
which occurs when object states are garbage collected.

.. change::
:tags: bug, mysql

The MySQL dialect now supports CAST on types that are constructed
as :class:`.TypeDecorator` objects.

.. change::
:tags: bug, mysql
:tickets: 3237

A warning is emitted when :func:`.cast` is used with the MySQL
dialect on a type where MySQL does not support CAST; MySQL only
supports CAST on a subset of datatypes. SQLAlchemy has for a long
time just omitted the CAST for unsupported types in the case of
MySQL. While we don't want to change this now, we emit a warning
to show that it's taken place. A warning is also emitted when
a CAST is used with an older MySQL version (< 4) that doesn't support
CAST at all, it's skipped in this case as well.

.. change::
:tags: feature, sql
:tickets: 3087

Literal values within a :class:`.DefaultClause`, which is invoked
when using the :paramref:`_schema.Column.server_default` parameter, will
now be rendered using the "inline" compiler, so that they are rendered
as-is, rather than as bound parameters.

.. seealso::

:ref:`change_3087`

.. change::
:tags: feature, oracle

Added support for cx_oracle connections to a specific service
name, as opposed to a tns name, by passing ``?service_name=<name>``
to the URL. Pull request courtesy Sławomir Ehlert.

.. change::
:tags: feature, mysql
:tickets: 3155

The MySQL dialect now renders TIMESTAMP with NULL / NOT NULL in
all cases, so that MySQL 5.6.6 with the
``explicit_defaults_for_timestamp`` flag enabled will
will allow TIMESTAMP to continue to work as expected when
``nullable=False``. Existing applications are unaffected as
SQLAlchemy has always emitted NULL for a TIMESTAMP column that
is ``nullable=True``.

.. seealso::

:ref:`change_3155`

:ref:`mysql_timestamp_null`

.. change::
:tags: bug, schema
:tickets: 3299, 3067

The :class:`.CheckConstraint` construct now supports naming
conventions that include the token ``%(column_0_name)s``; the
constraint expression is scanned for columns. Additionally,
naming conventions for check constraints that don't include the
``%(constraint_name)s`` token will now work for :class:`.SchemaType`-
generated constraints, such as those of :class:`.Boolean` and
:class:`.Enum`; this stopped working in 0.9.7 due to :ticket:`3067`.

.. seealso::

:ref:`naming_check_constraints`

:ref:`naming_schematypes`


.. change::
:tags: feature, postgresql, pypy
:tickets: 3052

Added support for the psycopg2cffi DBAPI on pypy. Pull request
courtesy shauns.

.. seealso::

:mod:`sqlalchemy.dialects.postgresql.psycopg2cffi`

.. change::
:tags: feature, orm
:tickets: 3262

A warning is emitted when the same polymorphic identity is assigned
to two different mappers in the same hierarchy. This is typically a
user error and means that the two different mapping types cannot be
correctly distinguished at load time. Pull request courtesy
Sebastian Bank.

.. change::
:tags: feature, sql

The type of expression is reported when an object passed to a
SQL expression unit can't be interpreted as a SQL fragment;
pull request courtesy Ryan P. Kelly.

.. change::
:tags: bug, orm
:tickets: 3227, 3242, 1326

The primary :class:`_orm.Mapper` of a :class:`_query.Query` is now passed to the
:meth:`.Session.get_bind` method when calling upon
:meth:`_query.Query.count`, :meth:`_query.Query.update`, :meth:`_query.Query.delete`,
as well as queries against mapped columns,
:obj:`.column_property` objects, and SQL functions and expressions
derived from mapped columns. This allows sessions that rely upon
either customized :meth:`.Session.get_bind` schemes or "bound" metadata
to work in all relevant cases.

.. seealso::

:ref:`bug_3227`

.. change::
:tags: enhancement, sql
:tickets: 3074

Custom dialects that implement :class:`.GenericTypeCompiler` can
now be constructed such that the visit methods receive an indication
of the owning expression object, if any. Any visit method that
accepts keyword arguments (e.g. ``**kw``) will in most cases
receive a keyword argument ``type_expression``, referring to the
expression object that the type is contained within. For columns
in DDL, the dialect's compiler class may need to alter its
``get_column_specification()`` method to support this as well.
The ``UserDefinedType.get_col_spec()`` method will also receive
``type_expression`` if it provides ``**kw`` in its argument
signature.

.. change::
:tags: bug, sql
:tickets: 3288

The multi-values version of :meth:`_expression.Insert.values` has been
repaired to work more usefully with tables that have Python-
side default values and/or functions, as well as server-side
defaults. The feature will now work with a dialect that uses
"positional" parameters; a Python callable will also be
invoked individually for each row just as is the case with an
"executemany" style invocation; a server- side default column
will no longer implicitly receive the value explicitly
specified for the first row, instead refusing to invoke
without an explicit value.

.. seealso::

:ref:`bug_3288`

.. change::
:tags: feature, general

Structural memory use has been improved via much more significant use
of ``__slots__`` for many internal objects. This optimization is
particularly geared towards the base memory size of large applications
that have lots of tables and columns, and greatly reduces memory
size for a variety of high-volume objects including event listening
internals, comparator objects and parts of the ORM attribute and
loader strategy system.

.. seealso::

:ref:`feature_slots`

.. change::
:tags: bug, mysql
:tickets: 3283

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.

.. seealso::

:ref:`change_3283`


.. change::
:tags: feature, schema
:tickets: 3282

The DDL generation system of :meth:`_schema.MetaData.create_all`
and :meth:`_schema.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:`_schema.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.

.. seealso::

:ref:`feature_3282`

.. change::
:tags: feature, schema

Added a new accessor :attr:`_schema.Table.foreign_key_constraints`
to complement the :attr:`_schema.Table.foreign_keys` collection,
as well as :attr:`_schema.ForeignKeyConstraint.referred_table`.

.. change::
:tags: bug, sqlite
:tickets: 3244, 3261

UNIQUE and FOREIGN KEY constraints are now fully reflected on
SQLite both with and without names. Previously, foreign key
names were ignored and unnamed unique constraints were skipped.
Thanks to Jon Nelson for assistance with this.

.. change::
:tags: feature, examples

A new suite of examples dedicated to providing a detailed study
into performance of SQLAlchemy ORM and Core, as well as the DBAPI,
from multiple perspectives. The suite runs within a container
that provides built in profiling displays both through console
output as well as graphically via the RunSnake tool.

.. seealso::

:ref:`examples_performance`

.. change::
:tags: feature, orm
:tickets: 3100

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.

.. seealso::

:ref:`bulk_operations`

.. change::
:tags: feature, mssql
:tickets: 3039

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.

.. seealso::

:ref:`mssql_large_type_deprecation`

.. change::
:tags: bug, sqlite
:tickets: 3257

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.

.. seealso::

:ref:`sqlite_datetime`

.. change::
:tags: bug, engine
:tickets: 3266

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:`_sa.create_engine.creator` parameter, as well as when
the :class:`_engine.Connection` encounters a connection error on
revalidation.

.. seealso::

:ref:`change_3266`

.. change::
:tags: feature, oracle

New Oracle DDL features for tables, indexes: COMPRESS, BITMAP.
Patch courtesy Gabor Gombas.

.. change::
:tags: bug, oracle

An alias name will be properly quoted when referred to using the
``%(name)s`` token inside the :meth:`_expression.Select.with_hint` method.
Previously, the Oracle backend hadn't implemented this quoting.

.. change::
:tags: feature, oracle
:tickets: 3220

Added support for CTEs under Oracle. This includes some tweaks
to the aliasing syntax, as well as a new CTE feature
:meth:`_expression.CTE.suffix_with`, which is useful for adding in special
Oracle-specific directives to the CTE.

.. seealso::

:ref:`change_3220`

.. change::
:tags: feature, mysql
:tickets: 3121

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.

.. change::
:tags: bug, mysql
:tickets: 3263

The :meth:`.ColumnOperators.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.

.. seealso::

:ref:`change_3263`

.. change::
:tags: bug, postgresql
:tickets: 3264

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.

.. seealso::

:ref:`change_3264`

.. change::
:tags: bug, sql
:tickets: 3260

Fixed bug in :meth:`_schema.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.

.. change::
:tags: feature, orm
:tickets: 3217

Added a parameter :paramref:`.Query.join.isouter` which is synonymous
with calling :meth:`_query.Query.outerjoin`; this flag is to provide a more
consistent interface compared to Core :meth:`_expression.FromClause.join`.
Pull request courtesy Jonathan Vanasco.

.. change::
:tags: bug, sql
:tickets: 3243

The behavioral contract of the :attr:`_schema.ForeignKeyConstraint.columns`
collection has been made consistent; this attribute is now a
:class:`_expression.ColumnCollection` like that of all other constraints and
is initialized at the point when the constraint is associated with
a :class:`_schema.Table`.

.. seealso::

:ref:`change_3243`

.. change::
:tags: bug, orm
:tickets: 3256

The :meth:`.PropComparator.of_type` modifier has been
improved in conjunction with loader directives such as
:func:`_orm.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.

.. seealso::

:ref:`eagerloading_polymorphic_subtypes` - contains an updated
example illustrating the new format.

.. change::
:tags: bug, sql
:tickets: 3245

The :attr:`_schema.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:`_schema.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:`_sa.create_engine` in any case,
and most DBAPIs today support a named and positional style.

.. change::
:tags: bug, sql

Fixed the name of the :paramref:`.PoolEvents.reset.dbapi_connection`
parameter as passed to this event; in particular this affects
usage of the "named" argument style for this event. Pull request
courtesy Jason Goldberger.

.. change::
:tags: feature, sql

Added a new parameter :paramref:`.Table.tometadata.name` to
the :meth:`_schema.Table.tometadata` method. Similar to
:paramref:`.Table.tometadata.schema`, this argument causes the newly
copied :class:`_schema.Table` to take on the new name instead of
the existing one. An interesting capability this adds is that of
copying a :class:`_schema.Table` object to the *same* :class:`_schema.MetaData`
target with a new name. Pull request courtesy n.d. parker.

.. change::
:tags: bug, orm

Repaired support of the ``copy.deepcopy()`` call when used by the
:class:`.orm.util.CascadeOptions` argument, which occurs
if ``copy.deepcopy()`` is being used with :func:`_orm.relationship`
(not an officially supported use case). Pull request courtesy
duesenfranz.

.. change::
:tags: bug, sql
:tickets: 3170

Reversing a change that was made in 0.9, the "singleton" nature
of the "constants" :func:`.null`, :func:`.true`, and :func:`.false`
has been reverted. These functions returning a "singleton" object
had the effect that different instances would be treated as the
same regardless of lexical use, which in particular would impact
the rendering of the columns clause of a SELECT statement.

.. seealso::

:ref:`bug_3170`

.. change::
:tags: bug, orm
:tickets: 3139

Fixed bug where :meth:`.Session.expunge` would not fully detach
the given object if the object had been subject to a delete
operation that was flushed, but not committed. This would also
affect related operations like :func:`.make_transient`.

.. seealso::

:ref:`bug_3139`

.. change::
:tags: bug, orm
:tickets: 3230

A warning is emitted in the case of multiple relationships that
ultimately will populate a foreign key column in conflict with
another, where the relationships are attempting to copy values
from different source columns. This occurs in the case where
composite foreign keys with overlapping columns are mapped to
relationships that each refer to a different referenced column.
A new documentation section illustrates the example as well as how
to overcome the issue by specifying "foreign" columns specifically
on a per-relationship basis.

.. seealso::

:ref:`relationship_overlapping_foreignkeys`

.. change::
:tags: feature, sql
:tickets: 3172

Exception messages have been spiffed up a bit. The SQL statement
and parameters are not displayed if None, reducing confusion for
error messages that weren't related to a statement. The full
module and classname for the DBAPI-level exception is displayed,
making it clear that this is a wrapped DBAPI exception. The
statement and parameters themselves are bounded within a bracketed
sections to better isolate them from the error message and from
each other.

.. change::
:tags: bug, orm
:tickets: 3228

The :meth:`_query.Query.update` method will now convert string key
names in the given dictionary of values into mapped attribute names
against the mapped class being updated. Previously, string names
were taken in directly and passed to the core update statement without
any means to resolve against the mapped entity. Support for synonyms
and hybrid attributes as the subject attributes of
:meth:`_query.Query.update` are also supported.

.. seealso::

:ref:`bug_3228`

.. change::
:tags: bug, orm
:tickets: 3035

Improvements to the mechanism used by :class:`.Session` to locate
"binds" (e.g. engines to use), such engines can be associated with
mixin classes, concrete subclasses, as well as a wider variety
of table metadata such as joined inheritance tables.

.. seealso::

:ref:`bug_3035`

.. change::
:tags: bug, general
:tickets: 3218

The ``__module__`` attribute is now set for all those SQL and
ORM functions that are derived as "public factory" symbols, which
should assist with documentation tools being able to report on the
target module.

.. change::
:tags: feature, sql

:meth:`_expression.Insert.from_select` now includes Python and SQL-expression
defaults if otherwise unspecified; the limitation where non-
server column defaults aren't included in an INSERT FROM
SELECT is now lifted and these expressions are rendered as
constants into the SELECT statement.

.. seealso::

:ref:`feature_insert_from_select_defaults`

.. change::
:tags: bug, orm
:tickets: 3233

Fixed bug in single table inheritance where a chain of joins
that included the same single inh entity more than once
(normally this should raise an error) could, in some cases
depending on what was being joined "from", implicitly alias the
second case of the single inh entity, producing
a query that "worked". But as this implicit aliasing is not
intended in the case of single table inheritance, it didn't
really "work" fully and was very misleading, since it wouldn't
always appear.

.. seealso::

:ref:`bug_3233`


.. change::
:tags: bug, orm
:tickets: 3222

The ON clause rendered when using :meth:`_query.Query.join`,
:meth:`_query.Query.outerjoin`, or the standalone :func:`_orm.join` /
:func:`_orm.outerjoin` functions to a single-inheritance subclass will
now include the "single table criteria" in the ON clause even
if the ON clause is otherwise hand-rolled; it is now added to the
criteria using AND, the same way as if joining to a single-table
target using relationship or similar.

This is sort of in-between feature and bug.

.. seealso::

:ref:`migration_3222`

.. change::
:tags: feature, sql
:tickets: 3184

The :class:`.UniqueConstraint` construct is now included when
reflecting a :class:`_schema.Table` object, for databases where this
is applicable. In order to achieve this
with sufficient accuracy, MySQL and PostgreSQL now contain features
that correct for the duplication of indexes and unique constraints
when reflecting tables, indexes, and constraints.
In the case of MySQL, there is not actually a "unique constraint"
concept independent of a "unique index", so for this backend
:class:`.UniqueConstraint` continues to remain non-present for a
reflected :class:`_schema.Table`. For PostgreSQL, the query used to
detect indexes against ``pg_index`` has been improved to check for
the same construct in ``pg_constraint``, and the implicitly
constructed unique index is not included with a
reflected :class:`_schema.Table`.

In both cases, the :meth:`_reflection.Inspector.get_indexes` and the
:meth:`_reflection.Inspector.get_unique_constraints` methods return both
constructs individually, but include a new token
``duplicates_constraint`` in the case of PostgreSQL or
``duplicates_index`` in the case
of MySQL to indicate when this condition is detected.
Pull request courtesy Johannes Erdfelt.

.. seealso::

:ref:`feature_3184`

.. change::
:tags: feature, postgresql

Added support for the FILTER keyword as applied to aggregate
functions, supported by PostgreSQL 9.4. Pull request
courtesy Ilja Everilä.

.. seealso::

:ref:`feature_gh134`

.. change::
:tags: bug, sql, engine
:tickets: 3215

Fixed bug where a "branched" connection, that is the kind you get
when you call :meth:`_engine.Connection.connect`, would not share invalidation
status with the parent. The architecture of branching has been tweaked
a bit so that the branched connection defers to the parent for
all invalidation status and operations.

.. change::
:tags: bug, sql, engine
:tickets: 3190

Fixed bug where a "branched" connection, that is the kind you get
when you call :meth:`_engine.Connection.connect`, would not share transaction
status with the parent. The architecture of branching has been tweaked
a bit so that the branched connection defers to the parent for
all transactional status and operations.

.. change::
:tags: bug, orm, declarative
:tickets: 2670

A relationship set up with :class:`.declared_attr` on
a :class:`.AbstractConcreteBase` base class will now be configured
on the abstract base mapping automatically, in addition to being
set up on descendant concrete classes as usual.

.. seealso::

:ref:`feature_3150`

.. change::
:tags: feature, orm, declarative
:tickets: 3150

The :class:`.declared_attr` construct has newly improved
behaviors and features in conjunction with declarative. The
decorated function will now have access to the final column
copies present on the local mixin when invoked, and will also
be invoked exactly once for each mapped class, the returned result
being memoized. A new modifier :attr:`.declared_attr.cascading`
is added as well.

.. seealso::

:ref:`feature_3150`

.. change::
:tags: feature, ext
:tickets: 3210

The :mod:`sqlalchemy.ext.automap` extension will now set
``cascade="all, delete-orphan"`` automatically on a one-to-many
relationship/backref where the foreign key is detected as containing
one or more non-nullable columns. This argument is present in the
keywords passed to :func:`.automap.generate_relationship` in this
case and can still be overridden. Additionally, if the
:class:`_schema.ForeignKeyConstraint` specifies ``ondelete="CASCADE"``
for a non-nullable or ``ondelete="SET NULL"`` for a nullable set
of columns, the argument ``passive_deletes=True`` is also added to the
relationship. Note that not all backends support reflection of
ondelete, but backends that do include PostgreSQL and MySQL.

.. change::
:tags: feature, sql
:tickets: 3206

Added new method :meth:`_expression.Select.with_statement_hint` and ORM
method :meth:`_query.Query.with_statement_hint` to support statement-level
hints that are not specific to a table.

.. change::
:tags: bug, sqlite
:tickets: 3203

SQLite now supports reflection of unique constraints from
temp tables; previously, this would fail with a TypeError.
Pull request courtesy Johannes Erdfelt.

.. seealso::

:ref:`change_3204` - changes regarding SQLite temporary
table and view reflection.

.. change::
:tags: bug, sqlite
:tickets: 3204

Added :meth:`_reflection.Inspector.get_temp_table_names` and
:meth:`_reflection.Inspector.get_temp_view_names`; currently, only the
SQLite and Oracle dialects support these methods. The return of
temporary table and view names has been **removed** from SQLite and
Oracle's version of :meth:`_reflection.Inspector.get_table_names` and
:meth:`_reflection.Inspector.get_view_names`; other database backends cannot
support this information (such as MySQL), and the scope of operation
is different in that the tables can be local to a session and
typically aren't supported in remote schemas.

.. seealso::

:ref:`change_3204`

.. change::
:tags: feature, postgresql
:tickets: 2891

Support has been added for reflection of materialized views
and foreign tables, as well as support for materialized views
within :meth:`_reflection.Inspector.get_view_names`, and a new method
:meth:`.PGInspector.get_foreign_table_names` available on the
PostgreSQL version of :class:`_reflection.Inspector`. Pull request courtesy
Rodrigo Menezes.

.. seealso::

:ref:`feature_2891`


.. change::
:tags: feature, orm

Added new event handlers :meth:`.AttributeEvents.init_collection`
and :meth:`.AttributeEvents.dispose_collection`, which track when
a collection is first associated with an instance and when it is
replaced. These handlers supersede the :meth:`.collection.linker`
annotation. The old hook remains supported through an event adapter.

.. change::
:tags: bug, orm
:tickets: 3148, 3188

A major rework to the behavior of expression labels, most
specifically when used with ColumnProperty constructs with
custom SQL expressions and in conjunction with the "order by
labels" logic first introduced in 0.9. Fixes include that an
``order_by(Entity.some_col_prop)`` will now make use of "order by
label" rules even if Entity has been subject to aliasing,
either via inheritance rendering or via the use of the
``aliased()`` construct; rendering of the same column property
multiple times with aliasing (e.g. ``query(Entity.some_prop,
entity_alias.some_prop)``) will label each occurrence of the
entity with a distinct label, and additionally "order by
label" rules will work for both (e.g.
``order_by(Entity.some_prop, entity_alias.some_prop)``).
Additional issues that could prevent the "order by label"
logic from working in 0.9, most notably that the state of a
Label could change such that "order by label" would stop
working depending on how things were called, has been fixed.

.. seealso::

:ref:`bug_3188`


.. change::
:tags: bug, mysql
:tickets: 3186

MySQL boolean symbols "true", "false" work again. 0.9's change
in :ticket:`2682` disallowed the MySQL dialect from making use of the
"true" and "false" symbols in the context of "IS" / "IS NOT", but
MySQL supports this syntax even though it has no boolean type.
MySQL remains "non native boolean", but the :func:`.true`
and :func:`.false` symbols again produce the
keywords "true" and "false", so that an expression like
``column.is_(true())`` again works on MySQL.

.. seealso::

:ref:`bug_3186`

.. change::
:tags: changed, mssql
:tickets: 3182

The hostname-based connection format for SQL Server when using
pyodbc will no longer specify a default "driver name", and a warning
is emitted if this is missing. The optimal driver name for SQL Server
changes frequently and is per-platform, so hostname based connections
need to specify this. DSN-based connections are preferred.

.. seealso::

:ref:`change_3182`

.. change::
:tags: changed, sql

The :func:`_expression.column` and :func:`_expression.table`
constructs are now importable from the "from sqlalchemy" namespace,
just like every other Core construct.

.. change::
:tags: changed, sql
:tickets: 2992

The implicit conversion of strings to :func:`_expression.text` constructs
when passed to most builder methods of :func:`_expression.select` as
well as :class:`_query.Query` now emits a warning with just the
plain string sent. The textual conversion still proceeds normally,
however. The only method that accepts a string without a warning
are the "label reference" methods like order_by(), group_by();
these functions will now at compile time attempt to resolve a single
string argument to a column or label expression present in the
selectable; if none is located, the expression still renders, but
you get the warning again. The rationale here is that the implicit
conversion from string to text is more unexpected than not these days,
and it is better that the user send more direction to the Core / ORM
when passing a raw string as to what direction should be taken.
Core/ORM tutorials have been updated to go more in depth as to how text
is handled.

.. seealso::

:ref:`migration_2992`


.. change::
:tags: feature, engine
:tickets: 3178

A new style of warning can be emitted which will "filter" up to
N occurrences of a parameterized string. This allows parameterized
warnings that can refer to their arguments to be delivered a fixed
number of times until allowing Python warning filters to squelch them,
and prevents memory from growing unbounded within Python's
warning registries.

.. seealso::

:ref:`feature_3178`

.. change::
:tags: feature, orm

The :class:`_query.Query` will raise an exception when :meth:`_query.Query.yield_per`
is used with mappings or options where either
subquery eager loading, or joined eager loading with collections,
would take place. These loading strategies are
not currently compatible with yield_per, so by raising this error,
the method is safer to use. Eager loads can be disabled with
the ``lazyload('*')`` option or :meth:`_query.Query.enable_eagerloads`.

.. seealso::

:ref:`migration_yield_per_eager_loading`

.. change::
:tags: bug, orm
:tickets: 3177

Changed the approach by which the "single inheritance criterion"
is applied, when using :meth:`_query.Query.from_self`, or its common
user :meth:`_query.Query.count`. The criteria to limit rows to those
with a certain type is now indicated on the inside subquery,
not the outside one, so that even if the "type" column is not
available in the columns clause, we can filter on it on the "inner"
query.

.. seealso::

:ref:`migration_3177`

.. change::
:tags: changed, orm

The ``proc()`` callable passed to the ``create_row_processor()``
method of custom :class:`.Bundle` classes now accepts only a single
"row" argument.

.. seealso::

:ref:`bundle_api_change`

.. change::
:tags: changed, orm

Deprecated event hooks removed: ``populate_instance``,
``create_instance``, ``translate_row``, ``append_result``

.. seealso::

:ref:`migration_deprecated_orm_events`

.. change::
:tags: bug, orm
:tickets: 3145

Made a small adjustment to the mechanics of lazy loading,
such that it has less chance of interfering with a joinload() in the
very rare circumstance that an object points to itself; in this
scenario, the object refers to itself while loading its attributes
which can cause a mixup between loaders. The use case of
"object points to itself" is not fully supported, but the fix also
removes some overhead so for now is part of testing.

.. change::
:tags: feature, orm
:tickets: 3176

A new implementation for :class:`.KeyedTuple` used by the
:class:`_query.Query` object offers dramatic speed improvements when
fetching large numbers of column-oriented rows.

.. seealso::

:ref:`feature_3176`

.. change::
:tags: feature, orm
:tickets: 3008

The behavior of :paramref:`_orm.joinedload.innerjoin` as well as
:paramref:`_orm.relationship.innerjoin` is now to use "nested"
inner joins, that is, right-nested, as the default behavior when an
inner join joined eager load is chained to an outer join eager load.

.. seealso::

:ref:`migration_3008`

.. change::
:tags: bug, orm
:tickets: 3171

The "resurrect" ORM event has been removed. This event hook had
no purpose since the old "mutable attribute" system was removed
in 0.8.

.. change::
:tags: bug, sql
:tickets: 3169

Using :meth:`_expression.Insert.from_select` now implies ``inline=True``
on :func:`_expression.insert`. This helps to fix a bug where an
INSERT...FROM SELECT construct would inadvertently be compiled
as "implicit returning" on supporting backends, which would
cause breakage in the case of an INSERT that inserts zero rows
(as implicit returning expects a row), as well as arbitrary
return data in the case of an INSERT that inserts multiple
rows (e.g. only the first row of many).
A similar change is also applied to an INSERT..VALUES
with multiple parameter sets; implicit RETURNING will no longer emit
for this statement either. As both of these constructs deal
with variable numbers of rows, the
:attr:`_engine.ResultProxy.inserted_primary_key` accessor does not
apply. Previously, there was a documentation note that one
may prefer ``inline=True`` with INSERT..FROM SELECT as some databases
don't support returning and therefore can't do "implicit" returning,
but there's no reason an INSERT...FROM SELECT needs implicit returning
in any case. Regular explicit :meth:`_expression.Insert.returning` should
be used to return variable numbers of result rows if inserted
data is needed.

.. change::
:tags: bug, orm
:tickets: 3167

Fixed bug where attribute "set" events or columns with
``validates`` would have events triggered within the flush process,
when those columns were the targets of a "fetch and populate"
operation, such as an autoincremented primary key, a Python side
default, or a server-side default "eagerly" fetched via RETURNING.

.. change::
:tags: feature, oracle

Added support for the Oracle table option ON COMMIT.

.. change::
:tags: feature, postgresql
:tickets: 2051

Added support for PG table options TABLESPACE, ON COMMIT,
WITH(OUT) OIDS, and INHERITS, when rendering DDL via
the :class:`_schema.Table` construct. Pull request courtesy
malikdiarra.

.. seealso::

:ref:`postgresql_table_options`

.. change::
:tags: bug, orm, py3k

The :class:`.IdentityMap` exposed from :attr:`.Session.identity_map`
now returns lists for ``items()`` and ``values()`` in Py3K.
Early porting to Py3K here had these returning iterators, when
they technically should be "iterable views"..for now, lists are OK.

.. change::
:tags: orm, feature

UPDATE statements can now be batched within an ORM flush
into more performant executemany() call, similarly to how INSERT
statements can be batched; this will be invoked within flush
to the degree that subsequent UPDATE statements for the
same mapping and table involve the identical columns within the
VALUES clause, that no SET-level SQL expressions
are embedded, and that the versioning requirements for the mapping
are compatible with the backend dialect's ability to return
a correct rowcount for an executemany operation.

.. change::
:tags: engine, bug
:tickets: 3163

Removing (or adding) an event listener at the same time that the event
is being run itself, either from inside the listener or from a
concurrent thread, now raises a RuntimeError, as the collection used is
now an instance of ``collections.deque()`` and does not support changes
while being iterated. Previously, a plain Python list was used where
removal from inside the event itself would produce silent failures.

.. change::
:tags: orm, feature
:tickets: 2963

The ``info`` parameter has been added to the constructor for
:class:`.SynonymProperty` and :class:`.ComparableProperty`.

.. change::
:tags: sql, feature
:tickets: 2963

The ``info`` parameter has been added as a constructor argument
to all schema constructs including :class:`_schema.MetaData`,
:class:`.Index`, :class:`_schema.ForeignKey`, :class:`_schema.ForeignKeyConstraint`,
:class:`.UniqueConstraint`, :class:`.PrimaryKeyConstraint`,
:class:`.CheckConstraint`.

.. change::
:tags: orm, feature
:tickets: 2971

The :attr:`.InspectionAttr.info` collection is now moved down to
:class:`.InspectionAttr`, where in addition to being available
on all :class:`.MapperProperty` objects, it is also now available
on hybrid properties, association proxies, when accessed via
:attr:`_orm.Mapper.all_orm_descriptors`.

.. change::
:tags: sql, feature
:tickets: 3027

The :paramref:`_schema.Table.autoload_with` flag now implies that
:paramref:`_schema.Table.autoload` should be ``True``. Pull request
courtesy Malik Diarra.

.. change::
:tags: postgresql, feature

Added new method :meth:`.PGInspector.get_enums`, when using the
inspector for PostgreSQL will provide a list of ENUM types.
Pull request courtesy Ilya Pekelny.

.. change::
:tags: mysql, bug

The MySQL dialect will now disable :meth:`_events.ConnectionEvents.handle_error`
events from firing for those statements which it uses internally
to detect if a table exists or not. This is achieved using an
execution option ``skip_user_error_events`` that disables the handle
error event for the scope of that execution. In this way, user code
that rewrites exceptions doesn't need to worry about the MySQL
dialect or other dialects that occasionally need to catch
SQLAlchemy specific exceptions.

.. change::
:tags: mysql, bug
:tickets: 2515

Changed the default value of "raise_on_warnings" to False for
MySQLconnector. This was set at True for some reason. The "buffered"
flag unfortunately must stay at True as MySQLconnector does not allow
a cursor to be closed unless all results are fully fetched.

.. change::
:tags: bug, orm
:tickets: 3117

The "evaluator" for query.update()/delete() won't work with multi-table
updates, and needs to be set to `synchronize_session=False` or
`synchronize_session='fetch'`; this now raises an exception, with a
message to change the synchronize setting.
This is upgraded from a warning emitted as of 0.9.7.

.. change::
:tags: removed

The Drizzle dialect has been removed from the Core; it is now
available as `sqlalchemy-drizzle <https://bitbucket.org/zzzeek/sqlalchemy-drizzle>`_,
an independent, third party dialect. The dialect is still based
almost entirely off of the MySQL dialect present in SQLAlchemy.

.. seealso::

:ref:`change_2984`

.. change::
:tags: enhancement, orm
:tickets: 3061

Adjustment to attribute mechanics concerning when a value is
implicitly initialized to None via first access; this action,
which has always resulted in a population of the attribute,
no longer does so; the None value is returned but the underlying
attribute receives no set event. This is consistent with how collections
work and allows attribute mechanics to behave more consistently;
in particular, getting an attribute with no value does not squash
the event that should proceed if the value is actually set to None.

.. seealso::

:ref:`migration_3061`

.. change::
:tags: feature, sql
:tickets: 3034

The :meth:`_expression.Select.limit` and :meth:`_expression.Select.offset` methods
now accept any SQL expression, in addition to integer values, as
arguments. Typically this is used to allow a bound parameter to be
passed, which can be substituted with a value later thus allowing
Python-side caching of the SQL query. The implementation
here is fully backwards compatible with existing third party dialects,
however those dialects which implement special LIMIT/OFFSET systems
will need modification in order to take advantage of the new
capabilities. Limit and offset also support "literal_binds" mode,
where bound parameters are rendered inline as strings based on
a compile-time option.
Work on this feature is courtesy of Dobes Vandermeer.


.. seealso::

:ref:`feature_3034`.


=============
1.1 Changelog
=============

.. changelog_imports::

.. include:: changelog_10.rst
:start-line: 5


.. include:: changelog_09.rst
:start-line: 5


.. include:: changelog_08.rst
:start-line: 5


.. include:: changelog_07.rst
:start-line: 5


.. changelog::

0.9.10

Not secure
:released: July 22, 2015

.. change::
:tags: bug, sqlite
:tickets: 3495
:versions: 1.0.8

Fixed bug in SQLite dialect where reflection of UNIQUE constraints
that included non-alphabetic characters in the names, like dots or
spaces, would not be reflected with their name.

.. change::
:tags: feature, sql
:tickets: 3418
:versions: 1.0.5

Added official support for a CTE used by the SELECT present
inside of :meth:`_expression.Insert.from_select`. This behavior worked
accidentally up until 0.9.9, when it no longer worked due to
unrelated changes as part of :ticket:`3248`. Note that this
is the rendering of the WITH clause after the INSERT, before the
SELECT; the full functionality of CTEs rendered at the top
level of INSERT, UPDATE, DELETE is a new feature targeted for a
later release.

.. change::
:tags: bug, ext
:tickets: 3408
:versions: 1.0.4

Fixed bug where when using extended attribute instrumentation system,
the correct exception would not be raised when :func:`.class_mapper`
were called with an invalid input that also happened to not
be weak referencable, such as an integer.

.. change::
:tags: bug, tests, pypy
:tickets: 3406
:versions: 1.0.4

Fixed an import that prevented "pypy setup.py test" from working
correctly.

.. change::
:tags: bug, engine
:tickets: 3375
:versions: 1.0.1

Added the string value ``"none"`` to those accepted by the
:paramref:`_pool.Pool.reset_on_return` parameter as a synonym for ``None``,
so that string values can be used for all settings, allowing
utilities like :func:`.engine_from_config` to be usable without
issue.

.. change::
:tags: bug, sql
:tickets: 3362
:versions: 1.0.0

Fixed issue where a :class:`_schema.MetaData` object that used a naming
convention would not properly work with pickle. The attribute was
skipped leading to inconsistencies and failures if the unpickled
:class:`_schema.MetaData` object were used to base additional tables
from.

.. change::
:tags: bug, postgresql
:tickets: 3354
:versions: 1.0.0

Fixed a long-standing bug where the :class:`.Enum` type as used
with the psycopg2 dialect in conjunction with non-ascii values
and ``native_enum=False`` would fail to decode return results properly.
This stemmed from when the PG :class:`_postgresql.ENUM` type used
to be a standalone type without a "non native" option.

.. change::
:tags: bug, orm
:tickets: 3349

:class:`_query.Query` doesn't support joins, subselects, or special
FROM clauses when using the :meth:`_query.Query.update` or
:meth:`_query.Query.delete` methods; instead of silently ignoring these
fields if methods like :meth:`_query.Query.join` or
:meth:`_query.Query.select_from` has been called, a warning is emitted.
As of 1.0.0b5 this will raise an error.

.. change::
:tags: bug, orm
:tickets: 3352
:versions: 1.0.0b5

Fixed bug where the state tracking within multiple, nested
:meth:`.Session.begin_nested` operations would fail to propagate
the "dirty" flag for an object that had been updated within
the inner savepoint, such that if the enclosing savepoint were
rolled back, the object would not be part of the state that was
expired and therefore reverted to its database state.

.. change::
:tags: bug, mysql, pymysql
:tickets: 3337
:versions: 1.0.0b4

Fixed unicode support for PyMySQL when using an "executemany"
operation with unicode parameters. SQLAlchemy now passes both
the statement as well as the bound parameters as unicode
objects, as PyMySQL generally uses string interpolation
internally to produce the final statement, and in the case of
executemany does the "encode" step only on the final statement.

.. change::
:tags: bug, py3k, mysql
:tickets: 3333
:versions: 1.0.0b2

Fixed the :class:`.mysql.BIT` type on Py3K which was not using the
``ord()`` function correctly. Pull request courtesy David Marin.

.. change::
:tags: bug, ext
:tickets: 3324

Fixed regression from 0.9.9 where the :func:`.as_declarative`
symbol was removed from the ``sqlalchemy.ext.declarative``
namespace.

.. change::
:tags: feature, orm
:tickets: 3320
:versions: 1.0.0b1

Added a new entry ``"entity"`` to the dictionaries returned by
:attr:`_query.Query.column_descriptions`. This refers to the primary ORM
mapped class or aliased class that is referred to by the expression.
Compared to the existing entry for ``"type"``, it will always be
a mapped entity, even if extracted from a column expression, or
None if the given expression is a pure core expression.
See also :ticket:`3403` which repaired a regression in this feature
which was unreleased in 0.9.10 but was released in the 1.0 version.


.. changelog::

0.9.9

Not secure
:released: March 10, 2015

.. change::
:tags: feature, postgresql
:versions: 1.0.0b1

Added support for the ``CONCURRENTLY`` keyword with PostgreSQL
indexes, established using ``postgresql_concurrently``. Pull
request courtesy Iuri de Silvio.

.. seealso::

:ref:`postgresql_index_concurrently`

.. change::
:tags: bug, ext, py3k
:versions: 1.0.0b1

Fixed bug where the association proxy list class would not interpret
slices correctly under Py3K. Pull request courtesy
Gilles Dartiguelongue.

.. change::
:tags: feature, sqlite
:versions: 1.0.0b1

Added support for partial indexes (e.g. with a WHERE clause) on
SQLite. Pull request courtesy Kai Groner.

.. seealso::

:ref:`sqlite_partial_index`

.. change::
:tags: bug, orm
:tickets: 3310
:versions: 1.0.0b1

Fixed bugs in ORM object comparisons where comparison of
many-to-one ``!= None`` would fail if the source were an aliased
class, or if the query needed to apply special aliasing to the
expression due to aliased joins or polymorphic querying; also fixed
bug in the case where comparing a many-to-one to an object state
would fail if the query needed to apply special aliasing
due to aliased joins or polymorphic querying.

.. change::
:tags: bug, orm
:tickets: 3309
:versions: 1.0.0b1

Fixed bug where internal assertion would fail in the case where
an ``after_rollback()`` handler for a :class:`.Session` incorrectly
adds state to that :class:`.Session` within the handler, and the task
to warn and remove this state (established by :ticket:`2389`) attempts
to proceed.

.. change::
:tags: bug, orm
:versions: 1.0.0b1

Fixed bug where TypeError raised when :meth:`_query.Query.join` called
with unknown kw arguments would raise its own TypeError due
to broken formatting. Pull request courtesy Malthe Borch.

.. change::
:tags: bug, engine
:tickets: 3302
:versions: 1.0.0b1

Fixed bug in :class:`_engine.Connection` and pool where the
:meth:`_engine.Connection.invalidate` method, or an invalidation due
to a database disconnect, would fail if the
``isolation_level`` parameter had been used with
:meth:`_engine.Connection.execution_options`; the "finalizer" that resets
the isolation level would be called on the no longer opened connection.

.. change::
:tags: feature, orm
:tickets: 3296
:versions: 1.0.0b1

Added new parameter :paramref:`.Session.connection.execution_options`
which may be used to set up execution options on a :class:`_engine.Connection`
when it is first checked out, before the transaction has begun.
This is used to set up options such as isolation level on the
connection before the transaction starts.

.. seealso::

:ref:`session_transaction_isolation` - new documentation section
detailing best practices for setting transaction isolation with
sessions.

.. change::
:tags: bug, engine
:tickets: 3296
:versions: 1.0.0b1

A warning is emitted if the ``isolation_level`` parameter is used
with :meth:`_engine.Connection.execution_options` when a :class:`.Transaction`
is in play; DBAPIs and/or SQLAlchemy dialects such as psycopg2,
MySQLdb may implicitly rollback or commit the transaction, or
not change the setting til next transaction, so this is never safe.

.. change::
:tags: bug, orm
:tickets: 3300
:versions: 1.0.0b1

Fixed bug in lazy loading SQL construction whereby a complex
primaryjoin that referred to the same "local" column multiple
times in the "column that points to itself" style of self-referential
join would not be substituted in all cases. The logic to determine
substitutions here has been reworked to be more open-ended.

.. change::
:tags: bug, postgresql
:tickets: 2940
:versions: 1.0.0b1

Repaired support for PostgreSQL UUID types in conjunction with
the ARRAY type when using psycopg2. The psycopg2 dialect now
employs use of the psycopg2.extras.register_uuid() hook
so that UUID values are always passed to/from the DBAPI as
UUID() objects. The :paramref:`.UUID.as_uuid` flag is still
honored, except with psycopg2 we need to convert returned
UUID objects back into strings when this is disabled.

.. change::
:tags: bug, postgresql
:versions: 1.0.0b1

Added support for the :class:`postgresql.JSONB` datatype when
using psycopg2 2.5.4 or greater, which features native conversion
of JSONB data so that SQLAlchemy's converters must be disabled;
additionally, the newly added psycopg2 extension
``extras.register_default_jsonb`` is used to establish a JSON
deserializer passed to the dialect via the ``json_deserializer``
argument. Also repaired the PostgreSQL integration tests which
weren't actually round-tripping the JSONB type as opposed to the
JSON type. Pull request courtesy Mateusz Susik.

.. change::
:tags: bug, postgresql
:versions: 1.0.0b1

Repaired the use of the "array_oid" flag when registering the
HSTORE type with older psycopg2 versions < 2.4.3, which does not
support this flag, as well as use of the native json serializer
hook "register_default_json" with user-defined ``json_deserializer``
on psycopg2 versions < 2.5, which does not include native json.

.. change::
:tags: bug, schema
:tickets: 3298, 1765

Fixed bug in 0.9's foreign key setup system, such that
the logic used to link a :class:`_schema.ForeignKey` to its parent could fail
when the foreign key used "link_to_name=True" in conjunction with
a target :class:`_schema.Table` that would not receive its parent column until
later, such as within a reflection + "useexisting" scenario,
if the target column in fact had a key value different from its name,
as would occur in reflection if column reflect events were used to
alter the .key of reflected :class:`_schema.Column` objects so that the
link_to_name becomes significant. Also repaired support for column
type via FK transmission in a similar way when target columns had a
different key and were referenced using link_to_name.

.. change::
:tags: feature, engine
:versions: 1.0.0b1

Added new user-space accessors for viewing transaction isolation
levels; :meth:`_engine.Connection.get_isolation_level`,
:attr:`_engine.Connection.default_isolation_level`.

.. change::
:tags: bug, postgresql
:versions: 1.0.0b1
:tickets: 3174

Fixed bug where PostgreSQL dialect would fail to render an
expression in an :class:`.Index` that did not correspond directly
to a table-bound column; typically when a :func:`_expression.text` construct
was one of the expressions within the index; or could misinterpret the
list of expressions if one or more of them were such an expression.

.. change::
:tags: bug, orm
:versions: 1.0.0b1
:tickets: 3287

The "wildcard" loader options, in particular the one set up by
the :func:`_orm.load_only` option to cover all attributes not
explicitly mentioned, now takes into account the superclasses
of a given entity, if that entity is mapped with inheritance mapping,
so that attribute names within the superclasses are also omitted
from the load. Additionally, the polymorphic discriminator column
is unconditionally included in the list, just in the same way that
primary key columns are, so that even with load_only() set up,
polymorphic loading of subtypes continues to function correctly.

.. change::
:tags: bug, sql
:versions: 1.0.0b1

Added the ``native_enum`` flag to the ``__repr__()`` output
of :class:`.Enum`, which is mostly important when using it with
Alembic autogenerate. Pull request courtesy Dimitris Theodorou.

.. change::
:tags: bug, orm, pypy
:versions: 1.0.0b1
:tickets: 3285

Fixed bug where if an exception were thrown at the start of a
:class:`_query.Query` before it fetched results, particularly when
row processors can't be formed, the cursor would stay open with
results pending and not actually be closed. This is typically only
an issue on an interpreter like PyPy where the cursor isn't
immediately GC'ed, and can in some circumstances lead to transactions/
locks being open longer than is desirable.

.. change::
:tags: change, mysql
:versions: 1.0.0b1
:tickets: 3275

The ``gaerdbms`` dialect is no longer necessary, and emits a
deprecation warning. Google now recommends using the MySQLdb
dialect directly.

.. change::
:tags: bug, sql
:versions: 1.0.0b1
:tickets: 3278

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.

.. change::
:tags: bug, mysql
:versions: 1.0.0b1
:tickets: 3274

Added a version check to the MySQLdb dialect surrounding the
check for 'utf8_bin' collation, as this fails on MySQL server < 5.0.

.. change::
:tags: feature, orm
:versions: 1.0.0b1

Added new method :meth:`.Session.invalidate`, functions similarly
to :meth:`.Session.close`, except also calls
:meth:`_engine.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.

.. change::
:tags: bug, examples
:versions: 1.0.0b1

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.

.. change::
:tags: bug, examples
:versions: 1.0.0b1

Fixed a bug in the examples/generic_associations/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.

.. change::
:tags: bug, orm
:versions: 1.0.0b1
:tickets: 3251

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.

.. change::
:tags: bug, sql
:versions: 1.0.0b1
:tickets: 3248

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.

.. change::
:tags: bug, orm, sqlite
:versions: 1.0.0b1
:tickets: 3241

Fixed bug regarding expression mutations which could express
itself as a "Could not locate column" error when using
:class:`_query.Query` to select from multiple, anonymous column
entities when querying against SQLite, as a side effect of the
"join rewriting" feature used by the SQLite dialect.

.. change::
:tags: feature, sqlite
:versions: 1.0.0b1

Added a new SQLite backend for the SQLCipher backend. This backend
provides for encrypted SQLite databases using the pysqlcipher Python
driver, which is very similar to the pysqlite driver.

.. seealso::

:mod:`~sqlalchemy.dialects.sqlite.pysqlcipher`

.. change::
:tags: bug, orm
:tickets: 3232
:versions: 1.0.0b1

Fixed bug where the ON clause for :meth:`_query.Query.join`,
and :meth:`_query.Query.outerjoin` to a single-inheritance subclass
using ``of_type()`` would not render the "single table criteria" in
the ON clause if the ``from_joinpoint=True`` flag were set.

.. changelog::

0.9.8

Not secure
:released: October 13, 2014

.. change::
:tags: bug, mysql, mysqlconnector
:versions: 1.0.0b1

Mysqlconnector as of version 2.0, probably as a side effect of
the python 3 merge, now does not expect percent signs (e.g.
as used as the modulus operator and others) to be doubled,
even when using the "pyformat" bound parameter format (this
change is not documented by Mysqlconnector). The dialect now
checks for py2k and for mysqlconnector less than version 2.0
when detecting if the modulus operator should be rendered as
``%%`` or ``%``.

.. change::
:tags: bug, mysql, mysqlconnector
:versions: 1.0.0b1

Unicode SQL is now passed for MySQLconnector version 2.0 and above;
for Py2k and MySQL < 2.0, strings are encoded.


.. change::
:tags: bug, oracle
:versions: 1.0.0b1
:tickets: 2138

Fixed long-standing bug in Oracle dialect where bound parameter
names that started with numbers would not be quoted, as Oracle
doesn't like numerics in bound parameter names.

.. change::
:tags: bug, sql
:versions: 1.0.0b1
:tickets: 3195

Fixed bug where a fair number of SQL elements within
the sql package would fail to ``__repr__()`` successfully,
due to a missing ``description`` attribute that would then invoke
a recursion overflow when an internal AttributeError would then
re-invoke ``__repr__()``.

.. change::
:tags: bug, declarative, orm
:versions: 1.0.0b1
:tickets: 3185

Fixed "'NoneType' object has no attribute 'concrete'" error
when using :class:`.AbstractConcreteBase` in conjunction with
a subclass that declares ``__abstract__``.

.. change::
:tags: bug, engine
:versions: 1.0.0b1
:tickets: 3200

The execution options passed to an :class:`_engine.Engine` either via
:paramref:`_sa.create_engine.execution_options` or
:meth:`_engine.Engine.update_execution_options` are not passed to the
special :class:`_engine.Connection` used to initialize the dialect
within the "first connect" event; dialects will usually
perform their own queries in this phase, and none of the
current available options should be applied here. In
particular, the "autocommit" option was causing an attempt to
autocommit within this initial connect which would fail with
an AttributeError due to the non-standard state of the
:class:`_engine.Connection`.

.. change::
:tags: bug, sqlite
:versions: 1.0.0b1
:tickets: 3211

When selecting from a UNION using an attached database file,
the pysqlite driver reports column names in cursor.description
as 'dbname.tablename.colname', instead of 'tablename.colname' as
it normally does for a UNION (note that it's supposed to just be
'colname' for both, but we work around it). The column translation
logic here has been adjusted to retrieve the rightmost token, rather
than the second token, so it works in both cases. Workaround
courtesy Tony Roberts.

.. change::
:tags: bug, postgresql
:versions: 1.0.0b1
:tickets: 3021

A revisit to this issue first patched in 0.9.5, apparently
psycopg2's ``.closed`` accessor is not as reliable as we assumed,
so we have added an explicit check for the exception messages
"SSL SYSCALL error: Bad file descriptor" and
"SSL SYSCALL error: EOF detected" when detecting an
is-disconnect scenario. We will continue to consult psycopg2's
connection.closed as a first check.

.. change::
:tags: bug, orm, engine
:versions: 1.0.0b1
:tickets: 3197

Fixed bug that affected generally the same classes of event
as that of :ticket:`3199`, when the ``named=True`` parameter
would be used. Some events would fail to register, and others
would not invoke the event arguments correctly, generally in the
case of when an event was "wrapped" for adaption in some other way.
The "named" mechanics have been rearranged to not interfere with
the argument signature expected by internal wrapper functions.

.. change::
:tags: bug, declarative
:versions: 1.0.0b1
:tickets: 3208

Fixed an unlikely race condition observed in some exotic end-user
setups, where the attempt to check for "duplicate class name" in
declarative would hit upon a not-totally-cleaned-up weak reference
related to some other class being removed; the check here now ensures
the weakref still references an object before calling upon it further.

.. change::
:tags: bug, orm
:versions: 1.0.0b1
:tickets: 3199

Fixed bug that affected many classes of event, particularly
ORM events but also engine events, where the usual logic of
"de duplicating" a redundant call to :func:`.event.listen`
with the same arguments would fail, for those events where the
listener function is wrapped. An assertion would be hit within
registry.py. This assertion has now been integrated into the
deduplication check, with the added bonus of a simpler means
of checking deduplication across the board.

.. change::
:tags: bug, mssql
:versions: 1.0.0b1
:tickets: 3151

Fixed the version string detection in the pymssql dialect to
work with Microsoft SQL Azure, which changes the word "SQL Server"
to "SQL Azure".

.. change::
:tags: bug, orm
:versions: 1.0.0b1
:tickets: 3194

Fixed warning that would emit when a complex self-referential
primaryjoin contained functions, while at the same time remote_side
was specified; the warning would suggest setting "remote side".
It now only emits if remote_side isn't present.

.. change::
:tags: bug, ext
:versions: 1.0.0b1
:tickets: 3191

Fixed bug in ordering list where the order of items would be
thrown off during a collection replace event, if the
reorder_on_append flag were set to True. The fix ensures that the
ordering list only impacts the list that is explicitly associated
with the object.

.. change::
:tags: bug, sql
:versions: 1.0.0b1
:tickets: 3180

An adjustment to table/index reflection such that if an index
reports a column that isn't found to be present in the table,
a warning is emitted and the column is skipped. This can occur
for some special system column situations as has been observed
with Oracle.

.. change::
:tags: bug, ext
:versions: 1.0.0b1

Fixed bug where :class:`.ext.mutable.MutableDict`
failed to implement the ``update()`` dictionary method, thus
not catching changes. Pull request courtesy Matt Chisholm.

.. change::
:tags: bug, ext
:versions: 1.0.0b1

Fixed bug where a custom subclass of :class:`.ext.mutable.MutableDict`
would not show up in a "coerce" operation, and would instead
return a plain :class:`.ext.mutable.MutableDict`. Pull request
courtesy Matt Chisholm.

.. change::
:tags: bug, pool
:versions: 1.0.0b1
:tickets: 3168

Fixed bug in connection pool logging where the "connection checked out"
debug logging message would not emit if the logging were set up using
``logging.setLevel()``, rather than using the ``echo_pool`` flag.
Tests to assert this logging have been added. This is a
regression that was introduced in 0.9.0.

.. change::
:tags: feature, postgresql, pg8000
:versions: 1.0.0b1

Support is added for "sane multi row count" with the pg8000 driver,
which applies mostly to when using versioning with the ORM.
The feature is version-detected based on pg8000 1.9.14 or greater
in use. Pull request courtesy Tony Locke.

.. change::
:tags: bug, engine
:versions: 1.0.0b1
:tickets: 3165

The string keys that are used to determine the columns impacted
for an INSERT or UPDATE are now sorted when they contribute towards
the "compiled cache" cache key. These keys were previously not
deterministically ordered, meaning the same statement could be
cached multiple times on equivalent keys, costing both in terms of
memory as well as performance.

.. change::
:tags: bug, postgresql
:versions: 1.0.0b1
:tickets: 3159

Fixed bug where PostgreSQL JSON type was not able to persist or
otherwise render a SQL NULL column value, rather than a JSON-encoded
``'null'``. To support this case, changes are as follows:

* The value :func:`.null` can now be specified, which will always
result in a NULL value resulting in the statement.

* A new parameter :paramref:`_types.JSON.none_as_null` is added, which
when True indicates that the Python ``None`` value should be
persisted as SQL NULL, rather than JSON-encoded ``'null'``.

Retrieval of NULL as None is also repaired for DBAPIs other than
psycopg2, namely pg8000.

.. change::
:tags: bug, sql
:versions: 1.0.0b1
:tickets: 3154

Fixed bug in CTE where ``literal_binds`` compiler argument would not
be always be correctly propagated when one CTE referred to another
aliased CTE in a statement.

.. change::
:tags: bug, postgresql
:versions: 1.0.0b1
:tickets: 3075

The exception wrapping system for DBAPI errors can now accommodate
non-standard DBAPI exceptions, such as the psycopg2
TransactionRollbackError. These exceptions will now be raised
using the closest available subclass in ``sqlalchemy.exc``, in the
case of TransactionRollbackError, ``sqlalchemy.exc.OperationalError``.

.. change::
:tags: bug, sql
:versions: 1.0.0b1
:tickets: 3144, 3067

Fixed 0.9.7 regression caused by :ticket:`3067` in conjunction with
a mis-named unit test such that so-called "schema" types like
:class:`.Boolean` and :class:`.Enum` could no longer be pickled.

.. change::
:tags: bug, postgresql
:versions: 1.0.0b1
:tickets: 3141

Fixed bug in :class:`_postgresql.array` object where comparison
to a plain Python list would fail to use the correct array constructor.
Pull request courtesy Andrew.

.. change::
:tags: bug, postgresql
:versions: 1.0.0b1
:tickets: 3137

Added a supported :meth:`.FunctionElement.alias` method to functions,
e.g. the ``func`` construct. Previously, behavior for this method
was undefined. The current behavior mimics that of pre-0.9.4,
which is that the function is turned into a single-column FROM
clause with the given alias name, where the column itself is
anonymously named.

.. changelog::

0.9.7

Not secure
:released: July 22, 2014

.. change::
:tags: bug, postgresql, pg8000
:tickets: 3134
:versions: 1.0.0b1

Fixed bug introduced in 0.9.5 by new pg8000 isolation level feature
where engine-level isolation level parameter would raise an error
on connect.

.. change::
:tags: bug, oracle, tests
:tickets: 3128
:versions: 1.0.0b1

Fixed bug in oracle dialect test suite where in one test,
'username' was assumed to be in the database URL, even though
this might not be the case.

.. change::
:tags: bug, orm, eagerloading
:tickets: 3131
:versions: 1.0.0b1

Fixed a regression caused by :ticket:`2976` released in 0.9.4 where
the "outer join" propagation along a chain of joined eager loads
would incorrectly convert an "inner join" along a sibling join path
into an outer join as well, when only descendant paths should be
receiving the "outer join" propagation; additionally, fixed related
issue where "nested" join propagation would take place inappropriately
between two sibling join paths.

.. change::
:tags: bug, sqlite
:tickets: 3130
:versions: 1.0.0b1

Fixed a SQLite join rewriting issue where a subquery that is embedded
as a scalar subquery such as within an IN would receive inappropriate
substitutions from the enclosing query, if the same table were present
inside the subquery as were in the enclosing query such as in a
joined inheritance scenario.

.. change::
:tags: bug, sql
:tickets: 3067
:versions: 1.0.0b1

Fix bug in naming convention feature where using a check
constraint convention that includes ``constraint_name`` would
then force all :class:`.Boolean` and :class:`.Enum` types to
require names as well, as these implicitly create a
constraint, even if the ultimate target backend were one that does
not require generation of the constraint such as PostgreSQL.
The mechanics of naming conventions for these particular
constraints has been reorganized such that the naming
determination is done at DDL compile time, rather than at
constraint/table construction time.

.. change::
:tags: bug, mssql
:tickets: 3025

Fixed a regression from 0.9.5 caused by :ticket:`3025` where the
query used to determine "default schema" is invalid in SQL Server 2000.
For SQL Server 2000 we go back to defaulting to the "schema name"
parameter of the dialect, which is configurable but defaults
to 'dbo'.

.. change::
:tags: bug, orm
:tickets: 3083, 2736
:versions: 1.0.0b1

Fixed a regression from 0.9.0 due to :ticket:`2736` where the
:meth:`_query.Query.select_from` method no longer set up the "from
entity" of the :class:`_query.Query` object correctly, so that
subsequent :meth:`_query.Query.filter_by` or :meth:`_query.Query.join`
calls would fail to check the appropriate "from" entity when
searching for attributes by string name.

.. change::
:tags: bug, sql
:tickets: 3090
:versions: 1.0.0b1

Fixed bug in common table expressions whereby positional bound
parameters could be expressed in the wrong final order
when CTEs were nested in certain ways.

.. change::
:tags: bug, sql
:tickets: 3069
:versions: 1.0.0b1

Fixed bug where multi-valued :class:`_expression.Insert` construct would fail
to check subsequent values entries beyond the first one given
for literal SQL expressions.

.. change::
:tags: bug, sql
:tickets: 3123
:versions: 1.0.0b1

Added a "str()" step to the dialect_kwargs iteration for
Python version < 2.6.5, working around the
"no unicode keyword arg" bug as these args are passed along as
keyword args within some reflection processes.

.. change::
:tags: bug, sql
:tickets: 3122
:versions: 1.0.0b1

The :meth:`.TypeEngine.with_variant` method will now accept a
type class as an argument which is internally converted to an
instance, using the same convention long established by other
constructs such as :class:`_schema.Column`.

.. change::
:tags: bug, orm
:tickets: 3117

The "evaluator" for query.update()/delete() won't work with multi-table
updates, and needs to be set to `synchronize_session=False` or
`synchronize_session='fetch'`; a warning is now emitted. In
1.0 this will be promoted to a full exception.

.. change::
:tags: bug, tests
:versions: 1.0.0b1

Fixed bug where "python setup.py test" wasn't calling into
distutils appropriately, and errors would be emitted at the end
of the test suite.

.. change::
:tags: feature, postgresql
:versions: 1.0.0b1
:tickets: 3078

Added kw argument ``postgresql_regconfig`` to the
:meth:`.ColumnOperators.match` operator, allows the "reg config" argument
to be specified to the ``to_tsquery()`` function emitted.
Pull request courtesy Jonathan Vanasco.

.. change::
:tags: feature, postgresql
:versions: 1.0.0b1

Added support for PostgreSQL JSONB via :class:`_postgresql.JSONB`. Pull request
courtesy Damian Dimmich.

.. change::
:tags: feature, mssql
:versions: 1.0.0b1

Enabled "multivalues insert" for SQL Server 2008. Pull request
courtesy Albert Cervin. Also expanded the checks for "IDENTITY INSERT"
mode to include when the identity key is present in the
VALUEs clause of the statement.

.. change::
:tags: feature, engine
:tickets: 3076
:versions: 1.0.0b1

Added new event :meth:`_events.ConnectionEvents.handle_error`, a more
fully featured and comprehensive replacement for
:meth:`_events.ConnectionEvents.dbapi_error`.

.. change::
:tags: bug, orm
:tickets: 3108
:versions: 1.0.0b1

Fixed bug where items that were persisted, deleted, or had a
primary key change within a savepoint block would not
participate in being restored to their former state (not in
session, in session, previous PK) after the outer transaction
were rolled back.

.. change::
:tags: bug, orm
:tickets: 3106
:versions: 1.0.0b1

Fixed bug in subquery eager loading in conjunction with
:func:`.with_polymorphic`, the targeting of entities and columns
in the subquery load has been made more accurate with respect
to this type of entity and others.

.. change::
:tags: bug, orm
:tickets: 3099

Fixed bug involving dynamic attributes, that was again a regression
of :ticket:`3060` from version 0.9.5. A self-referential relationship
with lazy='dynamic' would raise a TypeError within a flush operation.

.. change::
:tags: bug, declarative
:tickets: 3097
:versions: 1.0.0b1

Fixed bug when the declarative ``__abstract__`` flag was not being
distinguished for when it was actually the value ``False``.
The ``__abstract__`` flag needs to actually evaluate to a True
value at the level being tested.

.. changelog::

0.9.6

Not secure
:released: June 23, 2014

.. change::
:tags: bug, orm
:tickets: 3060

Reverted the change for :ticket:`3060` - this is a unit of work
fix that is updated more comprehensively in 1.0 via :ticket:`3061`.
The fix in :ticket:`3060` unfortunately produces a new issue whereby
an eager load of a many-to-one attribute can produce an event
that is interpreted into an attribute change.

.. changelog::

Page 33 of 50

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.