specified. This makes it more compatible with Postgresql's
VARCHAR type which is similarly unbounded when no length
or collections taken into account when deleting
objects, despite passive_deletes remaining at
its default of False. [ticket:2002]
- A warning is emitted when version_id_col is specified
on an inheriting mapper when the inherited mapper
already has one, if those column expressions are not
- "innerjoin" flag doesn't take effect along the chain
of joinedload() joins if a previous join in that chain
is an outer join, thus allowing primary rows without
- The mapper argument "primary_key" can be passed as a
single column as well as a list or tuple. [ticket:1971]
The documentation examples that illustrated it as a
- scalar value have been changed to lists.
+ scalar value have been changed to lists.
- Added active_history flag to relationship()
and column_property(), forces attribute events to
always load the "old" value, so that it's available to
- Query.get() will raise if the number of params
in a composite key is too large, as well as too
and foreign_keys wasn't used - adds "foreign_keys" to
the suggestion. Also add "foreign_keys" to the
suggestion for the generic "direction" error.
- Fixed operator precedence rules for multiple
chains of a single non-associative operator.
and not "x - y - z". Also works with labels,
i.e. "x - (y - z).label('foo')"
- The 'info' attribute of Column is copied during
Column.copy(), i.e. as occurs when using columns
in declarative mixins. [ticket:1967]
- Added a bind processor for booleans which coerces
to int, for DBAPIs such as pymssql that naively call
- The "unicode warning" against non-unicode bind data
is now raised only when the
Unicode type is used explictly; not when
convert_unicode=True is used on the engine
- Fixed memory leak in C version of Decimal result
- Implemented sequence check capability for the C
version of RowProxy, as well as 2.7 style
"collections.Sequence" registration for RowProxy.
- Threadlocal engine methods rollback(), commit(),
prepare() won't raise if no transaction is in progress;
this was a regression introduced in 0.6. [ticket:1998]
- Single element tuple expressions inside an IN clause
parenthesize correctly, also from [ticket:1984]
- Ensured every numeric, float, int code, scalar + array,
are recognized by psycopg2 and pg8000's "numeric"
- Fixed bug whereby KeyError would occur with non-ENUM
supported PG versions after a pool dispose+recreate
would occur, [ticket:1989]
- Fixed error handling for Jython + zxjdbc, such that
has_table() property works again. Regression from
this character. cx_oracle 5.0.3 or greater is also required
when using a non-period-decimal-point NLS_LANG setting.
- An error is raised if __table_args__ is not in tuple
or dict format, and is not None. [ticket:1972]
- The versioning example now supports detection of changes
in an associated relationship().
- - Added a new "lazyload" option "immediateload".
+ - Added a new "lazyload" option "immediateload".
Issues the usual "lazy" load operation automatically
as the object is populated. The use case
here is when loading objects to be placed in
the session isn't available, and straight 'select'
loading, not 'joined' or 'subquery', is desired.
- New Query methods: query.label(name), query.as_scalar(),
return the query's statement as a scalar subquery
with /without label [ticket:1920];
Roughly equivalent to a generative form of query.values()
which accepts mapped entities as well as column
- Fixed recursion bug which could occur when moving
an object from one reference to another, with
backrefs involved, where the initiating parent
- Fixed a regression in 0.6.4 which occurred if you
passed an empty list to "include_properties" on
- Fixed labeling bug in Query whereby the NamedTuple
would mis-apply labels if any of the column
expressions were un-labeled.
- Patched a case where query.join() would adapt the
right side to the right side of the left's join
a mapped entity and not a plain selectable,
as the default "left" side, not the first entity
in the Query object's list of entities.
- The exception raised by Session when it is used
subsequent to a subtransaction rollback (which is what
happens when a flush fails in autocommit=False mode) has
expiration would fail if the column expression key was
a class attribute with a different keyname as the
actual column name. [ticket:1935]
- Added an assertion during flush which ensures
that no NULL-holding identity keys were generated
on "newly persistent" objects.
is not triggered on these loads when the attributes are
determined and the "committed" state may not be
- A new flag on relationship(), load_on_pending, allows
the lazy loader to fire off on pending objects without a
flush taking place, as well as a transient object that's
object is loaded, so backrefs aren't available until
after a flush. The flag is only intended for very
- Another new flag on relationship(), cascade_backrefs,
disables the "save-update" cascade when the event was
initiated on the "reverse" side of a bidirectional
it getting sucked into the child object's session,
while still allowing the forward collection to
cascade. We *might* default this to False in 0.7.
- Slight improvement to the behavior of
"passive_updates=False" when placed only on the
many-to-one side of a relationship; documentation has
- Placing passive_deletes=True on a many-to-one emits
a warning, since you probably intended to put it on
- Fixed bug that would prevent "subqueryload" from
working correctly with single table inheritance
for a relationship from a subclass - the "where
type in (x, y, z)" only gets placed on the inside,
- When using from_self() with single table inheritance,
the "where type in (x, y, z)" is placed on the outside
of the query only, instead of repeatedly. May make
- reworked the internals of mapper.cascade_iterator() to
cut down method calls by about 9% in some circumstances.
- Fixed bug in TypeDecorator whereby the dialect-specific
type was getting pulled in to generate the DDL for a
given type, which didn't always return the correct result.
- TypeDecorator can now have a fully constructed type
specified as its "impl", in addition to a type class.
- TypeDecorator.load_dialect_impl() returns "self.impl" by
default, i.e. not the dialect implementation type of
- "self.impl". This to support compilation correctly.
+ "self.impl". This to support compilation correctly.
Behavior can be user-overridden in exactly the same way
as before to the same effect.
- - Added type_coerce(expr, type_) expression element.
+ - Added type_coerce(expr, type_) expression element.
Treats the given expression as the given type when evaluating
expressions and processing result rows, but does not
affect the generation of SQL, other than an anonymous
- Table.tometadata() now copies Index objects associated
- Fixed recursion overflow which could occur when operating
with two expressions both of type "NullType", but
not the singleton NULLTYPE instance. [ticket:1907]
- @classproperty (soon/now @declared_attr) takes effect for
__mapper_args__, __table_args__, __tablename__ on
- A mixin can now specify a column that overrides
a column of the same name associated with a superclass.
Thanks to Oystein Haaland.
- Fixed a regression in 0.6.4 whereby the change that
allowed cursor errors to be raised consistently broke
the result.lastrowid accessor. Test coverage has
been added for result.lastrowid. Note that lastrowid
is only supported by Pysqlite and some MySQL drivers,
so isn't super-useful in the general case.
- the logging message emitted by the engine when
a connection is first used is now "BEGIN (implicit)"
to emphasize that DBAPI has no explicit begin().
- added "views=True" option to metadata.reflect(),
will add the list of available views to those
being reflected. [ticket:1936]
- engine_from_config() now accepts 'debug' for
'echo', 'echo_pool', 'force' for 'convert_unicode',
- boolean values for 'use_native_unicode'.
+ boolean values for 'use_native_unicode'.
Oracle. Previously, the flag would be forced
to False if server version info was < 10.
- Fixed reflection bug which did not properly handle
reflection of unknown types. [ticket:1946]
- Fixed bug where aliasing of tables with "schema" would
fail to compile properly. [ticket:1943]
(spaces, embedded commas, etc.) can be reflected.
Note that reflection of indexes requires SQL
Server 2005 or greater. [ticket:1770]
- mssql+pymssql dialect now honors the "port" portion
of the URL instead of discarding it. [ticket:1952]
- *Major* cleanup / modernization of the Informix
dialect for 0.6, courtesy Florian Apolloner.
--with-coverage option to turn on coverage before
SQLAlchemy modules are imported, allowing coverage
- CircularDependencyError now has .cycles and .edges
members, which are the set of elements involved in
- one or more cycles, and the set of edges as 2-tuples.
+ one or more cycles, and the set of edges as 2-tuples.
iterable. This because asyncrhonous gc
can remove items via the gc thread at any time.
- The Session class is now present in sqlalchemy.orm.*.
We're moving away from the usage of create_session(),
which has non-standard defaults, for those situations
where a one-step Session constructor is desired. Most
users should stick with sessionmaker() for general use,
- query.with_parent() now accepts transient objects
and will use the non-persistent values of their pk/fk
- attributes in order to formulate the criterion.
+ attributes in order to formulate the criterion.
Docs are also clarified as to the purpose of with_parent().
- The include_properties and exclude_properties arguments
to mapper() now accept Column objects as members in
addition to strings. This so that same-named Column
In 0.7 this warning will be an exception. Note that
this warning is not emitted when the combination occurs
as a result of inheritance, so that attributes
- still allow being overridden naturally.
+ still allow being overridden naturally.
[ticket:1896]. In 0.7 this will be improved further.
- The primary_key argument to mapper() can now specify
a series of columns that are only a subset of
the calculated "primary key" columns of the mapped
in the selectable that are actually marked as
"primary_key", such as a join against two
tables on their primary key columns [ticket:1896].
- An object that's been deleted now gets a flag
'deleted', which prohibits the object from
being re-add()ed to the session, as previously
- make_transient() can be safely called on an
already transient instance.
- a warning is emitted in mapper() if the polymorphic_on
column is not present either in direct or derived
form in the mapped selectable or in the
the foreign keys to be elsewhere in any case.
A warning is now emitted instead of an error,
and the mapping succeeds. [ticket:1877]
- Moving an o2m object from one collection to
another, or vice versa changing the referenced
object by an m2o, where the foreign key is also a
at the "old", assuming passive_updates=True,
unless we know it was a PK switch that
triggered the change. [ticket:1856]
- The value of version_id_col can be changed
manually, and this will result in an UPDATE
of the row. Versioned UPDATEs and DELETEs
expressions are enforced - lists of strings
are explicitly disallowed since this is a
- Dynamic attributes don't support collection
population - added an assertion for when
set_committed_value() is called, as well as
- the versioning example works correctly now
if versioning on a col that was formerly
- Calling execute() on an alias() construct is pending
deprecation for 0.7, as it is not itself an
"executable" construct. It currently "proxies" its
inner element and is conditionally "executable" but
this is not the kind of ambiguity we like these days.
- The execute() and scalar() methods of ClauseElement
are now moved appropriately to the Executable
subclass. ClauseElement.execute()/ scalar() are still
these would always raise an error anyway if you were
not an Executable (unless you were an alias(), see
- Added basic math expression coercion for
so that resulting type is Numeric regardless
of the direction of the expression.
- Changed the scheme used to generate truncated
"auto" index names when using the "index=True"
flag on Column. The truncation only takes
upon the base "SET SESSION ISOLATION" command,
as psycopg2 resets the isolation level on each new
- Fixed "default schema" query to work with
- Fixed bug whereby a column default would fail to
reflect if the "default" keyword were lower case.
- Added ROWID type to the Oracle dialect, for those
cases where an explicit CAST might be needed.
"SQLAlchemy ORM" sections, mapper/relationship docs
have been broken out. Lots of sections rewritten
- The beaker_caching example has been reorgnized
such that the Session, cache manager,
when copying columns, so that the versioning
table handles multiple rows with repeating values.
themselves + a selectable (i.e. from_self(),
union(), etc.), so that join() and such have the
correct state to work from. [ticket:1853]
- Fixed bug where Query.join() would fail if
querying a non-ORM column then joining without
an on clause when a FROM clause is already
but the subclass is not. Any attempts to access
cls._sa_class_manager.mapper now raise
- Added "column_descriptions" accessor to Query,
returns a list of dictionaries containing
naming/typing information about the entities
the Query will return. Can be helpful for
building GUIs on top of ORM queries.
- The _extract_error_code() method now works
come back as ints without SQLA type
objects being involved and without needless
conversion to Decimal first.
Unfortunately, some exotic subquery cases
can even see different types between
individual result rows, so the Numeric
form query.join(target, clause_expression),
i.e. missing the tuple, and raise an informative
error message that this is the wrong calling form.
- Fixed bug regarding flushes on self-referential
bi-directional many-to-many relationships, where
two objects made to mutually reference each other
in one flush would fail to insert a row for both
sides. Regression from 0.5. [ticket:1824]
- the post_update feature of relationship() has been
reworked architecturally to integrate more closely
with the new 0.6 unit of work. The motivation
statement per column per row. Multiple row
updates are also batched into executemany()s as
possible, while maintaining consistent row ordering.
- Query.statement, Query.subquery(), etc. now transfer
the values of bind parameters, i.e. those specified
by query.params(), into the resulting SQL expression.
Previously the values would not be transferred
and bind parameters would come out as None.
- Subquery-eager-loading now works with Query objects
which include params(), as well as get() Queries.
- The make_transient() function is now in the generated
- make_transient() removes all "loader" callables from
the state being made transient, removing any
"expired" state - all unloaded attributes reset back
to undefined, None/empty on access.
- The warning emitted by the Unicode and String types
with convert_unicode=True no longer embeds the actual
- Fixed bug that would prevent overridden clause
compilation from working for "annotated" expression
elements, which are often generated by the ORM.
- The argument to "ESCAPE" of a LIKE operator or similar
is passed through render_literal_value(), which may
implement escaping of backslashes. [ticket:1400]
- Fixed bug in Enum type which blew away native_enum
flag when used with TypeDecorators or other adaption
- Inspector hits bind.connect() when invoked to ensure
initialize has been called. the internal name ".conn"
is changed to ".bind", since that's what it is.
- Modified the internals of "column annotation" such that
a custom Column subclass can safely override
_constructor to return Column, for the purposes of
- render_literal_value() is overridden which escapes
backslashes, currently applies to the ESCAPE clause
- of LIKE and similar expressions.
+ of LIKE and similar expressions.
Ultimately this will have to detect the value of
- "standard_conforming_strings" for full behavior.
+ "standard_conforming_strings" for full behavior.
- Won't generate "CREATE TYPE" / "DROP TYPE" if
using types.Enum on a PG version prior to 8.3 -
the supports_native_enum flag is fully
- MySQL dialect doesn't emit CAST() for MySQL version
detected < 4.0.2. This allows the unicode
check on connect to proceed. [ticket:1826]
- MySQL dialect now detects NO_BACKSLASH_ESCAPES sql
- mode, in addition to ANSI_QUOTES.
+ mode, in addition to ANSI_QUOTES.
- render_literal_value() is overridden which escapes
backslashes, currently applies to the ESCAPE clause
of LIKE and similar expressions. This behavior
is derived from detecting the value of
- Fixed ora-8 compatibility flags such that they
don't cache a stale value from before the first
which suggests checking that the FreeTDS version
configuration is using 7.0 or 8.0, not 4.2.
- Fixed incorrect signature in do_execute(), error
introduced in 0.6.1. [ticket:1823]
- Firebird dialect adds CHAR, VARCHAR types which
accept a "charset" flag, to support Firebird
"CHARACTER SET" clause. [ticket:1813]
- Added support for @classproperty to provide
any kind of schema/mapping construct from a
An error is raised if any MapperProperty subclass
is specified on a mixin without using @classproperty.
[ticket:1751] [ticket:1796] [ticket:1805]
- a mixin class can now define a column that matches
one which is present on a __table__ defined on a
subclass. It cannot, however, define one that is
user-defined compiler is specific to certain
backends and compilation for a different backend
is invoked. [ticket:1838]
- Added documentation for the Inspector. [ticket:1820]
decorators so that Sphinx documentation picks up
these attributes and methods, such as
- Fixed regression introduced in 0.6.0 involving improper
history accounting on mutable attributes. [ticket:1782]
- Fixed regression introduced in 0.6.0 unit of work refactor
that broke updates for bi-directional relationship()
with post_update=True. [ticket:1807]
- session.merge() will not expire attributes on the returned
instance if that instance is "pending". [ticket:1789]
the related Engine. The cache is an LRUCache for the
rare case that a mapper receives an extremely
high number of different column patterns as UPDATEs.
- expr.in_() now accepts a text() construct as the argument.
Grouping parenthesis are added automatically, i.e. usage
will coerce a "basestring" on the right side into a
_Binary as well so that required DBAPI processing
- Added table.add_is_dependent_on(othertable), allows manual
placement of dependency rules between two Table objects
for use within create_all(), drop_all(), sorted_tables.
- Fixed bug that prevented implicit RETURNING from functioning
properly with composite primary key that contained zeroes.
- Fixed errant space character when generating ADD CONSTRAINT
for a named UNIQUE constraint.
- Pool classes will reuse the same "pool_logging_name" setting
after a dispose() occurs.
- Engine gains an "execution_options" argument and
update_execution_options() method, which will apply to
all connections generated by this engine.
- func.sysdate() emits "SYSDATE()", i.e. with the ending
parenthesis, on MySQL. [ticket:1794]
- Fixed concatenation of constraints when "PRIMARY KEY"
constraint gets moved to column level due to SQLite
AUTOINCREMENT keyword being rendered. [ticket:1812]
- Added a check for cx_oracle versions lower than version 5,
in which case the incompatible "output type handler" won't
"native unicode" check doesn't fail, cx_oracle
"native unicode" mode is disabled, VARCHAR() is emitted
with bytes count instead of char count. [ticket:1808]
- oracle_xe 5 doesn't accept a Python unicode object in
its connect string in normal Python 2.x mode - so we coerce
to str() directly. non-ascii characters aren't supported
or with subqueries, so its still not very usable, but at
least SQLA gets the SQL past the Oracle parser.
- Added a label to the query used within has_table() and
has_sequence() to work with older versions of Firebird
that don't provide labels for result columns. [ticket:1521]
- Added integer coercion to the "type_conv" attribute when
passed via query string, so that it is properly interpreted
by Kinterbasdb. [ticket:1779]
would cause a version check to occur. Since the instance
is first expired, refresh() always upgrades the object
to the most recent version.
- The 'refresh-expire' cascade, when reaching a pending object,
will expunge the object if the cascade also includes
"delete-orphan", or will simply detach it otherwise.
- The ORM will set the docstring of all generated descriptors
to None by default. This can be overridden using 'doc'
(or if using Sphinx, attribute docstrings work too).
- Added kw argument 'doc' to all mapper property callables
as well as Column(). Will assemble the string 'doc' as
- the '__doc__' attribute on the descriptor.
+ the '__doc__' attribute on the descriptor.
- Usage of version_id_col on a backend that supports
cursor.rowcount for execute() but not executemany() now works
objects of all the same class, thereby avoiding redundant
compilation per individual INSERT/UPDATE within an
- internal getattr(), setattr(), getcommitted() methods
on ColumnProperty, CompositeProperty, RelationshipProperty
have been underscored (i.e. are private), signature has
- The C extension now also works with DBAPIs which use custom
sequences as row (and not only tuples). [ticket:1757]
- somejoin.select(fold_equivalents=True) is no longer
deprecated, and will eventually be rolled into a more
comprehensive version of the feature for [ticket:1729].
- the Numeric type raises an *enormous* warning when expected
to convert floats to Decimal from a DBAPI that returns floats.
This includes SQLite, Sybase, MS-SQL. [ticket:1759]
- Fixed an error in expression typing which caused an endless
loop for expressions with two NULL types.
- Fixed bug in execution_options() feature whereby the existing
Transaction and other state information from the parent
connection would not be propagated to the sub-connection.
corresponding to the dialect, clause element, the column
names within the VALUES or SET clause of an INSERT or UPDATE,
as well as the "batch" mode for an INSERT or UPDATE statement.
- Added get_pk_constraint() to reflection.Inspector, similar
to get_primary_keys() except returns a dict that includes the
name of the constraint, for supported backends (PG so far).
- Table.create() and Table.drop() no longer apply metadata-
level create/drop events. [ticket:1771]
- the compiler extension now allows @compiles decorators
on base classes that extend to child classes, @compiles
decorators on child classes that aren't broken by a
@compiles decorator on the base class.
- Declarative will raise an informative error message
if a non-mapped class attribute is referenced in the
string-based relationship() arguments.
SERIAL columns correctly, after the name of of the sequence
has been changed. Thanks to Kumar McMillan for the patch.
- Repaired missing import in psycopg2._PGNumeric type when
unknown numeric is received.
- Postgresql reflects the name of primary key constraints,
if one exists. [ticket:1769]
- Now using cx_oracle output converters so that the
DBAPI returns natively the kinds of values we prefer:
call is slightly expensive however so it can be disabled.
To re-enable on a per-execution basis, the
'enable_rowcount=True' execution option may be used.
- Updated attribute_shard.py example to use a more robust
method of searching a Query for binary expressions which
compare columns against literal values.
loading available, the new names for eagerload() and
eagerload_all() are joinedload() and joinedload_all(). The
old names will remain as synonyms for the foreseeable future.
- The "lazy" flag on the relationship() function now accepts
a string argument for all kinds of loading: "select", "joined",
"subquery", "noload" and "dynamic", where the default is now
directly down to select().with_hint() and also accepts
entities as well as tables and aliases. See with_hint() in the
SQL section below. [ticket:921]
- Fixed bug in Query whereby calling q.join(prop).from_self(...).
join(prop) would fail to render the second join outside the
subquery, when joining on the same criterion as was on the
would fail if the underlying table (but not the actual alias)
were referenced inside the subquery generated by
q.from_self() or q.select_from().
- Fixed bug which affected all eagerload() and similar options
such that "remote" eager loads, i.e. eagerloads off of a lazy
load such as query(A).options(eagerload(A.b, B.c))
carefully that "Cls" is compatible with the current joinpoint,
and act the same way as Query.join("propname", from_joinpoint=True)
- Added with_hint() method to select() construct. Specify
a table/alias, hint text, and optional dialect name, and
"hints" will be rendered in the appropriate place in the
statement. Works for Oracle, Sybase, MySQL. [ticket:921]
- Fixed bug introduced in 0.6beta2 where column labels would
render inside of column expressions already assigned a label.
when reflecting - TINYINT(1) is returned. Use Boolean/
BOOLEAN in table definition to get boolean conversion
- The Oracle dialect will issue VARCHAR type definitions
using character counts, i.e. VARCHAR2(50 CHAR), so that
__tablename__, __table_args__, etc. now works if
the method references attributes on the ultimate
- relationships and columns with foreign keys aren't
allowed on declarative mixins, sorry. [ticket:1751]
- The sqlalchemy.orm.shard module now becomes an extension,
sqlalchemy.ext.horizontal_shard. The old import
works with a deprecation warning.
now that Distribute runs on Py3k. distribute_setup.py
is now included. See README.py3k for Python 3 installation/
- The official name for the relation() function is now
relationship(), to eliminate confusion over the relational
callable that, given the current value of the "version_id_col",
returns the next version number. Can be used for alternate
versioning schemes such as uuid, timestamps. [ticket:1692]
- added "lockmode" kw argument to Session.refresh(), will
- pass through the string value to Query the same as
+ pass through the string value to Query the same as
in with_lockmode(), will also do version check for a
- Fixed bug in session.merge() which prevented dict-like
collections from merging.
- session.merge() works with relations that specifically
don't include "merge" in their cascade options - the target
- session.merge() will not expire existing scalar attributes
on an existing target if the target has a value for that
attribute, even if the incoming merged doesn't have
it also is implemented within merge() such that a SELECT
won't be issued for an incoming instance with partially
NULL primary key if the flag is False. [ticket:1680]
- Fixed bug in 0.6-reworked "many-to-one" optimizations
such that a many-to-one that is against a non-primary key
column on the remote table (i.e. foreign key against a
we will need it for proper history/backref accounting,
and we can't pull from the local identity map on a
non-primary key column. [ticket:1737]
- fixed internal error which would occur if calling has()
or similar complex expression on a single-table inheritance
- query.one() no longer applies LIMIT to the query, this to
ensure that it fully counts all object identities present
in the result, even in the case where joins may conceal
- query.get() now returns None if queried for an identifier
that is present in the identity map with a different class
- than the one requested, i.e. when using polymorphic loading.
+ than the one requested, i.e. when using polymorphic loading.
- A major fix in query.join(), when the "on" clause is an
attribute of an aliased() construct, but there is already
an existing join made out to a compatible target, query properly
joins to the right aliased() construct instead of sticking
onto the right side of the existing join. [ticket:1706]
- Slight improvement to the fix for [ticket:1362] to not issue
needless updates of the primary key column during a so-called
"row switch" operation, i.e. add + delete of two objects
attribute load or refresh action fails due to object
being detached from any Session. UnboundExecutionError
is specific to engines bound to sessions and statements.
- Query called in the context of an expression will render
disambiguating labels in all cases. Note that this does
not apply to the existing .statement and .subquery()
accessor/method, which still honors the .with_labels()
- setting that defaults to False.
+ setting that defaults to False.
- Query.union() retains disambiguating labels within the
returned statement, thus avoiding various SQL composition
errors which can result from column name conflicts.
query.select_from(), query.with_polymorphic(), or
query.from_statement() raises an exception now instead of
silently dropping those criterion. [ticket:1736]
- query.scalar() now raises an exception if more than one
row is returned. All other behavior remains the same.
- Fixed bug which caused "row switch" logic, that is an
INSERT and DELETE replaced by an UPDATE, to fail when
version_id_col was in use. [ticket:1692]
- join() will now simulate a NATURAL JOIN by default. Meaning,
if the left side is a join, it will attempt to join the right
any exceptions about ambiguous join conditions if successful
even if there are further join targets across the rest of
- The most common result processors conversion function were
moved to the new "processors" module. Dialect authors are
encouraged to use those functions whenever they correspond
Dialects can also expand upon the areas where binds are not
accepted, such as within argument lists of functions
(which don't work on MS-SQL when native SQL binding is used).
- Added "unicode_errors" parameter to String, Unicode, etc.
Behaves like the 'errors' keyword argument to
the standard library's string.decode() functions. This flag
in the first place (i.e. MySQL. *not* PG, Sqlite, etc.)
- Added math negation operator support, -x.
- FunctionElement subclasses are now directly executable the
same way any func.foo() construct is, with automatic
SELECT being applied when passed to execute().
- The "type" and "bind" keyword arguments of a func.foo()
construct are now local to "func." constructs and are
not part of the FunctionElement base class, allowing
a "type" to be handled in a custom constructor or
- Restored the keys() method to ResultProxy.
- The type/expression system now does a more complete job
of determining the return type from an expression
as well as the adaptation of the Python operator into
- Column() requires a type if it has no foreign keys (this is
not new). An error is now raised if a Column() has no type
and no foreign keys. [ticket:1705]
- the "scale" argument of the Numeric() type is honored when
coercing a returned floating point value into a string
on its way to Decimal - this allows accuracy to function
- the copy() method of Column now copies over uninitialized
"on table attach" events. Helps with the new declarative
- Added an optional C extension to speed up the sql layer by
reimplementing RowProxy and the most common result processors.
info from the cursor before commit() is called on the
DBAPI connection in an "autocommit" scenario. This helps
mxodbc with rowcount and is probably a good idea overall.
- Opened up logging a bit such that isEnabledFor() is called
more often, so that changes to the log level for engine/pool
will be reflected on next connect. This adds a small
life a lot easier for all those situations when logging
just happens to be configured after create_engine() is called.
- The assert_unicode flag is deprecated. SQLAlchemy will raise
a warning in all cases where it is asked to encode a non-unicode
Python string, as well as when a Unicode or UnicodeType type
filters down to that of Pool. Issues the given string name
within the "name" field of logging messages instead of the default
hex identifier string. [ticket:1555]
- The visit_pool() method of Dialect is removed, and replaced with
connect(). This method returns a callable which receives
the raw DBAPI connection after each one is created. The callable
is assembled into a first_connect/connect pool listener by the
connection strategy if non-None. Provides a simpler interface
- StaticPool now initializes, disposes and recreates without
opening a new connection - the connection is only opened when
first requested. dispose() also works on AssertionPool now.
- Added the ability to strip schema information when using
"tometadata" by passing "schema=None" as an argument. If schema
- declarative now accepts mixin classes directly, as a means
to provide common functional and column-based elements on
all subclasses, as well as a means to propagate a fixed
- set of __table_args__ or __mapper_args__ to subclasses.
+ set of __table_args__ or __mapper_args__ to subclasses.
For custom combinations of __table_args__/__mapper_args__ from
an inherited mixin to local, descriptors can now be used.
New details are all up in the Declarative documentation.
Thanks to Chris Withers for putting up with my strife
- the __mapper_args__ dict is copied when propagating to a subclass,
and is taken straight off the class __dict__ to avoid any
propagation from the parent. mapper inheritance already
- An exception is raised when a single-table subclass specifies
a column that is already present on the base class.
- Fixed reflection bug whereby when COLLATE was present,
nullable flag and server defaults would not be reflected.
integer flags like UNSIGNED.
- Further fixes for the mysql-connector dialect. [ticket:1668]
- Composite PK table on InnoDB where the "autoincrement" column
isn't first will emit an explicit "KEY" phrase within
CREATE TABLE thereby avoiding errors, [ticket:1496]
- Added reflection/create table support for a wide range
of MySQL keywords. [ticket:1634]
- Fixed import error which could occur reflecting tables on
a Windows host [ticket:1580]
- Re-established support for the pymssql dialect.
- Various fixes for implicit returning, reflection,
etc. - the MS-SQL dialects aren't quite complete
in 0.6 yet (but are close)
- Added basic support for mxODBC [ticket:1710].
- Removed the text_as_varchar option.
is emitted asking that the user seriously consider
the usage of this difficult mode of operation.
- The except_() method now renders as MINUS on Oracle,
which is more or less equivalent on that platform.
- Added support for rendering and reflecting
TIMESTAMP WITH TIME ZONE, i.e. TIMESTAMP(timezone=True).
- Oracle INTERVAL type can now be reflected.
- Added "native_datetime=True" flag to create_engine().
This will cause the DATE and TIMESTAMP types to skip
creates/drops and basic round trip functionality.
Does not yet include reflection or comprehensive
support of unicode/special expressions/etc.
- Changed the beaker cache example a bit to have a separate
RelationCache option for lazyload caching. This object
- Platforms targeted now include Python 2.4/2.5/2.6, Python
- Changes to query.update() and query.delete():
- the 'expire' option on query.update() has been renamed to
- 'fetch', thus matching that of query.delete().
+ 'fetch', thus matching that of query.delete().
'expire' is deprecated and issues a warning.
- query.update() and query.delete() both default to
- Enhancements / Changes on Session.merge():
- the "dont_load=True" flag on Session.merge() is deprecated
- Session.merge() is performance optimized, using half the
call counts for "load=False" mode compared to 0.5 and
significantly fewer SQL queries in the case of collections
- merge() will not issue a needless merge of attributes if the
given instance is the same instance which is already present.
- merge() now also merges the "options" associated with a given
state, i.e. those passed through query.options() which follow
along with an instance, such as options to eagerly- or
lazyily- load various attributes. This is essential for
the construction of highly integrated caching schemes. This
is a subtle behavioral change vs. 0.5.
- A bug was fixed regarding the serialization of the "loader
path" present on an instance's state, which is also necessary
when combining the usage of merge() with serialized state
- and associated options that should be preserved.
+ and associated options that should be preserved.
- The all new merge() is showcased in a new comprehensive
example of how to integrate Beaker with SQLAlchemy. See
the notes in the "examples" note below.
- Primary key values can now be changed on a joined-table inheritance
object, and ON UPDATE CASCADE will be taken into account when
the flush happens. Set the new "passive_updates" flag to False
on mapper() when using SQLite or MySQL/MyISAM. [ticket:1362]
- flush() now detects when a primary key column was updated by
an ON UPDATE CASCADE operation from another primary key, and
can then locate the row for a subsequent UPDATE on the new PK
value. This occurs when a relation() is there to establish
the relationship as well as passive_updates=True. [ticket:1671]
- the "save-update" cascade will now cascade the pending *removed*
values from a scalar or collection attribute into the new session
during an add() operation. This so that the flush() operation
will also delete or modify rows of those disconnected items.
- Using a "dynamic" loader with a "secondary" table now produces
a query where the "secondary" table is *not* aliased. This
allows the secondary Table object to be used in the "order_by"
the row. This may be due to primaryjoin/secondaryjoin
conditions which aren't appropriate for an eager LEFT OUTER
JOIN or for other conditions. [ticket:1643]
- an explicit check occurs when a synonym() is used with
map_column=True, when a ColumnProperty (deferred or otherwise)
exists separately in the properties dictionary sent to mapper
with the same keyname. Instead of silently replacing
the existing property (and possible options on that property),
an error is raised. [ticket:1633]
- a "dynamic" loader sets up its query criterion at construction
time so that the actual query is returned from non-cloning
accessors like "statement".
- the "named tuple" objects returned when iterating a
Query() are now pickleable.
- mapping to a select() construct now requires that you
make an alias() out of it distinctly. This to eliminate
confusion over such issues as [ticket:1542]
- query.join() has been reworked to provide more consistent
behavior and more flexibility (includes [ticket:1537])
- query.get() can be used with a mapping to an outer join
where one or more of the primary key values are None.
- query.from_self(), query.union(), others which do a
"SELECT * from (SELECT...)" type of nesting will do
a better job translating column expressions within the subquery
may break queries with literal expressions that do not have labels
applied (i.e. literal('foo'), etc.)
- relation primaryjoin and secondaryjoin now check that they
are column-expressions, not just clause elements. this prohibits
things like FROM expressions being placed there directly.
- `expression.null()` is fully understood the same way
None is when comparing an object/collection-referencing
attribute within query.filter(), filter_by(), etc.
subclasses of RelationProperty) into the reverse reference.
The internal BackRef() is gone and backref() returns a plain
tuple that is understood by RelationProperty.
- The version_id_col feature on mapper() will raise a warning when
used with dialects that don't support "rowcount" adequately.
Select-statements have these options, and the only option
used is "stream_results", and the only dialect which knows
"stream_results" is psycopg2.
- Query.yield_per() will set the "stream_results" statement
* 'allow_null_pks' flag on mapper() is deprecated. It does
nothing now and the setting is "on" in all cases.
expect a regular mapped object instance.
* the 'engine' parameter to declarative_base() is removed.
Use the 'bind' keyword argument.
- the "autocommit" flag on select() and text() as well
as select().autocommit() are deprecated - now call
.execution_options(autocommit=True) on either of those
- the autoincrement flag on column now indicates the column
which should be linked to cursor.lastrowid, if that method
is used. See the API docs for details.
- an executemany() now requires that all bound parameter
sets require that all keys are present which are
present in the first bound parameter set. The structure
is not impacted. For this reason defaults would otherwise
silently "fail" for missing parameters, so this is now guarded
- returning() support is native to insert(), update(),
delete(). Implementations of varying levels of
functionality exist for Postgresql, Firebird, MSSQL and
version in use supports it (a version number check is
performed). This occurs if no end-user returning() was
- union(), intersect(), except() and other "compound" types
of statements have more consistent behavior w.r.t.
parenthesizing. Each compound element embedded within
when nesting compound elements, the first one usually needs
".alias().select()" called on it to wrap it inside
of a subquery. [ticket:1665]
- insert() and update() constructs can now embed bindparam()
objects using names that match the keys of columns. These
bind parameters will circumvent the usual route to those
keys showing up in the VALUES or SET clause of the generated
- the Binary type now returns data as a Python string
(or a "bytes" type in Python 3), instead of the built-
in "buffer" type. This allows symmetric round trips
of binary data. [ticket:1524]
- Added a tuple_() construct, allows sets of expressions
to be compared to another set, typically with IN against
composite primary keys or similar. Also accepts an
have only one column" error message is removed - will
rely upon the database to report problems with
- User-defined "default" and "onupdate" callables which
accept a context should now call upon
"context.current_parameters" to get at the dictionary
with underscores for dots, i.e. "dbo_master_table_column".
This is a "friendly" label that behaves better
in result sets. [ticket:1428]
- removed needless "counter" behavior with select()
labelnames that match a column name in the table,
i.e. generates "tablename_id" for "id", instead of
named "tablename_id" - this is because
the labeling logic is always applied to all columns
so a naming conflict will never occur.
- calling expr.in_(), i.e. with an empty list, emits a warning
before issuing the usual "expr != expr" clause. The
"expr != expr" can be very expensive, and it's preferred
- Added "execution_options()" to select()/text(), which set the
default options for the Connection. See the note in "engines".
* "scalar" flag on select() is removed, use
the new returning() method.
* fold_equivalents flag on join is deprecated (will remain
until [ticket:1131] is implemented)
- transaction isolation level may be specified with
create_engine(... isolation_level="..."); available on
postgresql and sqlite. [ticket:443]
- Connection has execution_options(), generative method
which accepts keywords that affect how the statement
is executed w.r.t. the DBAPI. Currently supports
option from select() and text(). select() and
text() also have .execution_options() as well as
- fixed the import for entrypoint-driven dialects to
not rely upon silly tb_info trick to determine import
error status. [ticket:1630]
- added first() method to ResultProxy, returns first row and
closes result set immediately.
- RowProxy no longer has a close() method, as the row no longer
maintains a reference to the parent. Call close() on
the parent ResultProxy instead, or use autoclose.
- ResultProxy internals have been overhauled to greatly reduce
method call counts when fetching columns. Can provide a large
speed improvement (up to more than 100%) when fetching large
- the last_inserted_ids() method has been renamed to the
- setting echo=False on create_engine() now sets the loglevel
to WARN instead of NOTSET. This so that logging can be
disabled for a particular engine even if logging
for "sqlalchemy.engine" is enabled overall. Note that the
default setting of "echo" is `None`. [ticket:1554]
- ConnectionProxy now has wrapper methods for all transaction
lifecycle events, including begin(), rollback(), commit()
begin_nested(), begin_prepared(), prepare(), release_savepoint(),
- Connection pool logging now uses both INFO and DEBUG
log levels for logging. INFO is for major events such
as invalidated connections, DEBUG for all the acquire/return
logging. `echo_pool` can be False, None, True or "debug"
the same way as `echo` works.
- All pyodbc-dialects now support extra pyodbc-specific
kw arguments 'ansi', 'unicode_results', 'autocommit'.
- the "threadlocal" engine has been rewritten and simplified
and now supports SAVEPOINT operations.
* result.last_inserted_ids() is deprecated. Use
now has those methods. All four methods accept
*args and **kwargs which are passed to the given callable,
as well as the operating connection.
- the `__contains__()` method of `MetaData` now accepts
strings or `Table` objects as arguments. If given
a `Table`, the argument is converted to `table.key` first,
i.e. "[schemaname.]<tablename>" [ticket:1541]
- deprecated MetaData.connect() and
ThreadLocalMetaData.connect() have been removed - send
the "bind" attribute to bind a metadata.
- deprecated metadata.table_iterator() method removed (use
- deprecated PassiveDefault - use DefaultClause.
- the "metadata" argument is removed from DefaultGenerator
and subclasses, but remains locally present on Sequence,
which is a standalone construct in DDL.
These should be constructed declaratively (i.e. in one
- The "start" and "increment" attributes on Sequence now
generate "START WITH" and "INCREMENT BY" by default,
on Oracle and Postgresql. Firebird doesn't support
these keywords right now. [ticket:1545]
- UniqueConstraint, Index, PrimaryKeyConstraint all accept
lists of column names or column objects as arguments.
- Column.metadata (get via column.table.metadata)
- Column.sequence (use column.default)
- ForeignKey(constraint=some_parent) (is now private _constraint)
- The use_alter flag on ForeignKey is now a shortcut option
for operations that can be hand-constructed using the
DDL() event system. A side effect of this refactor is
that ForeignKeyConstraint objects with use_alter=True
will *not* be emitted on SQLite, which does not support
- ForeignKey and ForeignKeyConstraint objects now correctly
copy() all their public keyword arguments. [ticket:1605]
- Table reflection has been expanded and generalized into
a new API called "sqlalchemy.engine.reflection.Inspector".
The Inspector object provides fine-grained information about
a wide variety of schema information, with room for expansion,
including table names, column names, view definitions, sequences,
- Views are now reflectable as ordinary Table objects. The same
Table constructor is used, with the caveat that "effective"
primary and foreign key constraints aren't part of the reflection
results; these have to be specified explicitly if desired.
- The existing autoload=True system now uses Inspector underneath
so that each dialect need only return "raw" data about tables
and other objects - Inspector is the single place that information
is compiled into Table objects so that consistency is at a maximum.
- the DDL system has been greatly expanded. the DDL() class
now extends the more generic DDLElement(), which forms the basis
These support "on" and "execute-at()" just like plain DDL()
does. User-defined DDLElement subclasses can be created and
linked to a compiler using the sqlalchemy.ext.compiler extension.
- The signature of the "on" callable passed to DDL() and
DDLElement() is revised as follows:
"ddl" - the DDLElement object itself.
"event" - the string event name.
"target" - previously "schema_item", the Table or
- the setuptools entrypoint for external dialects is now
- the "owner" keyword argument is removed from Table. Use
"schema" to represent any namespaces to be prepended to
- cached TypeEngine classes are cached per-dialect class
- new UserDefinedType should be used as a base class for
new types, which preserves the 0.5 behavior of
- The result_processor() method of all type classes now
accepts a second argument "coltype", which is the DBAPI
type argument from cursor.description. This argument
can help some types decide on the most efficient processing
- Deprecated Dialect.get_params() removed.
- Dialect.get_rowcount() has been renamed to a descriptor
ExecutionContext. Dialects which support sequences should
add a `fire_sequence()` method to their execution context
- Functions and operators generated by the compiler now use
(almost) regular dispatch functions of the form
"visit_<opname>" and "visit_<funcname>_fn" to provide
- New dialects: pg8000, zxjdbc, and pypostgresql
- The "postgres" dialect is now named "postgresql" !
Connection strings look like:
the older "postgres_returning" and
"postgres_where" names still work with a
- "postgresql_where" now accepts SQL expressions which
can also include literals, which will be quoted as needed.
- The psycopg2 dialect now uses psycopg2's "unicode extension"
on all new connections, which allows all String/Text/etc.
types to skip the need to post-process bytestrings into
unicode (an expensive step due to its volume). Other
dialects which return unicode natively (pg8000, zxjdbc)
also skip unicode post-processing.
- Added new ENUM type, which exists as a schema-level
construct and extends the generic Enum type. Automatically
associates itself with tables and their parent metadata
to issue the appropriate CREATE TYPE/DROP TYPE
commands as needed, supports unicode labels, supports
- INTERVAL supports an optional "precision" argument
corresponding to the argument that PG accepts.
%(foobar)s however and SQLA doesn't want to add overhead
just to treat that one non-existent use case.
- Inserting NULL into a primary key + foreign key column
will allow the "not null constraint" error to raise,
not an attempt to execute a nonexistent "col_id_seq"
- autoincrement SELECT statements, i.e. those which
select from a procedure that modifies rows, now work
with server-side cursor mode (the named cursor isn't
used for such statements.)
- postgresql dialect can properly detect pg "devel" version
strings, i.e. "8.5devel" [ticket:1636]
used for the statement. If false, they will not be used, even
if "server_side_cursors" is true on the
- New dialects: oursql, a new native dialect,
MySQL Connector/Python, a native Python port of MySQLdb,
and of course zxjdbc on Jython.
- VARCHAR/NVARCHAR will not render without a length, raises
an error before passing to MySQL. Doesn't impact
CAST since VARCHAR is not allowed in MySQL CAST anyway,
the dialect renders CHAR/NCHAR in those cases.
- all the _detect_XXX() functions now run once underneath
MySQLdb can't handle % signs in SQL when executemany() is used,
and SQLA doesn't want to add overhead just to treat that one
non-existent use case. [ticket:1279]
- the BINARY and MSBinary types now generate "BINARY" in all
cases. Omitting the "length" parameter will generate
"BINARY" with no length. Use BLOB to generate an unlengthed
- the "quoting='quoted'" argument to MSEnum/ENUM is deprecated.
It's best to rely upon the automatic quoting.
- ENUM now subclasses the new generic Enum type, and also handles
unicode values implicitly, if the given labelnames are unicode
- a column of type TIMESTAMP now defaults to NULL if
"nullable=False" is not passed to Column(), and no default
is present. This is now consistent with all other types,
and in the case of TIMESTAMP explictly renders "NULL"
due to MySQL's "switching" of default nullability
for TIMESTAMP columns. [ticket:1539]
- unit tests pass 100% with cx_oracle !
- an NCLOB type is added to the base types.
- use_ansi=False won't leak into the FROM/WHERE clause of
a statement that's selecting from a subquery that also
- added native INTERVAL type to the dialect. This supports
only the DAY TO SECOND interval type so far due to lack
of support in cx_oracle for YEAR TO MONTH. [ticket:1467]
- usage of the CHAR type results in cx_oracle's
FIXED_CHAR dbapi type being bound to statements.
- the Oracle dialect now features NUMBER which intends
to act justlike Oracle's NUMBER type. It is the primary
numeric type returned by table reflection and attempts
to return Decimal()/float/int based on the precision/scale
- func.char_length is a generic function for LENGTH
- ForeignKey() which includes onupdate=<value> will emit a
- using new dialect.initialize() feature to set up
- using types.BigInteger with Oracle will generate
- "case sensitivity" feature will detect an all-lowercase
case-sensitive column name during reflect and add
"quote=True" to the generated Column, so that proper