py-sqlalchemy/CHANGES

5800 lines
222 KiB
Plaintext

-*- coding: utf-8; fill-column: 68 -*-
=======
CHANGES
=======
0.7.10
======
- changelog
- The changelog has been moved to the documentation.
This file will be maintained throughout remaining
0.7 maintenance for backwards compabitility, but
is removed in 0.8.
- orm
- [bug] Fixed Session accounting bug whereby replacing
a deleted object in the identity map with another
object of the same primary key would raise a
"conflicting state" error on rollback(),
if the replaced primary key were established either
via non-unitofwork-established INSERT statement
or by primary key switch of another instance.
[ticket:2583]
- oracle
- [bug] changed the list of cx_oracle types that are
excluded from the setinputsizes() step to only include
STRING and UNICODE; CLOB and NCLOB are removed. This
is to work around cx_oracle behavior which is broken
for the executemany() call. In 0.8, this same change
is applied however it is also configurable via the
exclude_setinputsizes argument. [ticket:2561]
- mysql
- [feature] Added "raise_on_warnings" flag to OurSQL
dialect. [ticket:2523]
- [feature] Added "read_timeout" flag to MySQLdb
dialect. [ticket:2554]
0.7.9
=====
- orm
- [bug] Fixed bug mostly local to new
AbstractConcreteBase helper where the "type"
attribute from the superclass would not
be overridden on the subclass to produce the
"reserved for base" error message, instead placing
a do-nothing attribute there. This was inconsistent
vs. using ConcreteBase as well as all the behavior
of classical concrete mappings, where the "type"
column from the polymorphic base would be explicitly
disabled on subclasses, unless overridden
explicitly.
- [bug] A warning is emitted when lazy='dynamic'
is combined with uselist=False. This is an
exception raise in 0.8.
- [bug] Fixed bug whereby user error in related-object
assignment could cause recursion overflow if the
assignment triggered a backref of the same name
as a bi-directional attribute on the incorrect
class to the same target. An informative
error is raised now.
- [bug] Fixed bug where incorrect type information
would be passed when the ORM would bind the
"version" column, when using the "version" feature.
Tests courtesy Daniel Miller. [ticket:2539]
- [bug] Extra logic has been added to the "flush"
that occurs within Session.commit(), such that the
extra state added by an after_flush() or
after_flush_postexec() hook is also flushed in a
subsequent flush, before the "commit" completes.
Subsequent calls to flush() will continue until
the after_flush hooks stop adding new state.
An "overflow" counter of 100 is also in place,
in the event of a broken after_flush() hook
adding new content each time. [ticket:2566]
- sql
- [bug] Fixed the DropIndex construct to support
an Index associated with a Table in a remote
schema. [ticket:2571]
- [bug] Fixed bug in over() construct whereby
passing an empty list for either partition_by
or order_by, as opposed to None, would fail
to generate correctly.
Courtesy Gunnlaugur Þór Briem.
[ticket:2574]
- [bug] Fixed CTE bug whereby positional
bound parameters present in the CTEs themselves
would corrupt the overall ordering of
bound parameters. This primarily
affected SQL Server as the platform with
positional binds + CTE support.
[ticket:2521]
- [bug] Fixed more un-intuitivenesses in CTEs
which prevented referring to a CTE in a union
of itself without it being aliased.
CTEs now render uniquely
on name, rendering the outermost CTE of a given
name only - all other references are rendered
just as the name. This even includes other
CTE/SELECTs that refer to different versions
of the same CTE object, such as a SELECT
or a UNION ALL of that SELECT. We are
somewhat loosening the usual link between object
identity and lexical identity in this case.
A true name conflict between two unrelated
CTEs now raises an error.
- [bug] quoting is applied to the column names
inside the WITH RECURSIVE clause of a
common table expression according to the
quoting rules for the originating Column.
[ticket:2512]
- [bug] Fixed regression introduced in 0.7.6
whereby the FROM list of a SELECT statement
could be incorrect in certain "clone+replace"
scenarios. [ticket:2518]
- [bug] Fixed bug whereby usage of a UNION
or similar inside of an embedded subquery
would interfere with result-column targeting,
in the case that a result-column had the same
ultimate name as a name inside the embedded
UNION. [ticket:2552]
- [bug] Fixed a regression since 0.6 regarding
result-row targeting. It should be possible
to use a select() statement with string
based columns in it, that is
select(['id', 'name']).select_from('mytable'),
and have this statement be targetable by
Column objects with those names; this is the
mechanism by which
query(MyClass).from_statement(some_statement)
works. At some point the specific case of
using select(['id']), which is equivalent to
select([literal_column('id')]), stopped working
here, so this has been re-instated and of
course tested. [ticket:2558]
- [bug] Added missing operators is_(), isnot()
to the ColumnOperators base, so that these long-available
operators are present as methods like all
the other operators. [ticket:2544]
- engine
- [bug] Fixed bug whereby
a disconnect detect + dispose that occurs
when the QueuePool has threads waiting
for connections would leave those
threads waiting for the duration of
the timeout on the old pool (or indefinitely
if timeout was disabled). The fix
now notifies those waiters with a special
exception case and has them move onto
the new pool. [ticket:2522]
- [feature] Dramatic improvement in memory
usage of the event system; instance-level
collections are no longer created for a
particular type of event until
instance-level listeners are established
for that event. [ticket:2516]
- [bug] Added gaerdbms import to mysql/__init__.py,
the absense of which was preventing the new
GAE dialect from being loaded. [ticket:2529]
- [bug] Fixed cextension bug whereby the
"ambiguous column error" would fail to
function properly if the given index were
a Column object and not a string.
Note there are still some column-targeting
issues here which are fixed in 0.8.
[ticket:2553]
- [bug] Fixed the repr() of Enum to include
the "name" and "native_enum" flags. Helps
Alembic autogenerate.
- sqlite
- [bug] Adjusted a very old bugfix which attempted
to work around a SQLite issue that itself was
"fixed" as of sqlite 3.6.14, regarding quotes
surrounding a table name when using
the "foreign_key_list" pragma. The fix has been
adjusted to not interfere with quotes that
are *actually in the name* of a column or table,
to as much a degree as possible; sqlite still
doesn't return the correct result for foreign_key_list()
if the target table actually has quotes surrounding
its name, as *part* of its name (i.e. """mytable""").
[ticket:2568]
- [bug] Adjusted column default reflection code to
convert non-string values to string, to accommodate
old SQLite versions that don't deliver
default info as a string. [ticket:2265]
- [feature] Added support for the localtimestamp()
SQL function implemented in SQLite, courtesy
Richard Mitchell.
- postgresql
- [bug] Columns in reflected primary key constraint
are now returned in the order in which the constraint
itself defines them, rather than how the table
orders them. Courtesy Gunnlaugur Þór Briem.
[ticket:2531].
- [bug] Added 'terminating connection' to the list
of messages we use to detect a disconnect with PG, which
appears to be present in some versions when the server
is restarted. [ticket:2570]
- mysql
- [bug] Updated mysqlconnector interface to use
updated "client flag" and "charset" APIs,
courtesy David McNelis.
- mssql
- [bug] Fixed compiler bug whereby using a correlated
subquery within an ORDER BY would fail to render correctly
if the stament also used LIMIT/OFFSET, due to mis-rendering
within the ROW_NUMBER() OVER clause. Fix courtesy
sayap [ticket:2538]
- [bug] Fixed compiler bug whereby a given
select() would be modified if it had an "offset"
attribute, causing the construct to not compile
correctly a second time. [ticket:2545]
- [bug] Fixed bug where reflection of primary key constraint
would double up columns if the same constraint/table
existed in multiple schemas.
0.7.8
=====
- orm
- [bug] Fixed bug whereby subqueryload() from
a polymorphic mapping to a target would incur
a new invocation of the query for each
distinct class encountered in the polymorphic
result. [ticket:2480]
- [bug] Fixed bug in declarative
whereby the precedence of columns
in a joined-table, composite
column (typically for id) would fail to
be correct if the columns contained
names distinct from their attribute
names. This would cause things like
primaryjoin conditions made against the
entity attributes to be incorrect. Related
to [ticket:1892] as this was supposed
to be part of that, this is [ticket:2491].
- [feature] The 'objects' argument to
flush() is no longer deprecated, as some
valid use cases have been identified.
- [bug] Fixed identity_key() function which
was not accepting a scalar argument
for the identity. [ticket:2508].
- [bug] Fixed bug whereby populate_existing
option would not propagate to subquery
eager loaders. [ticket:2497].
- sql
- [bug] added BIGINT to types.__all__,
BIGINT, BINARY, VARBINARY to sqlalchemy
module namespace, plus test to ensure
this breakage doesn't occur again.
[ticket:2499]
- [bug] Repaired common table expression
rendering to function correctly when the
SELECT statement contains UNION or other
compound expressions, courtesy btbuilder.
[ticket:2490]
- [bug] Fixed bug whereby append_column()
wouldn't function correctly on a cloned
select() construct, courtesy
Gunnlaugur Þór Briem. [ticket:2482]
- engine
- [bug] Fixed memory leak in C version of
result proxy whereby DBAPIs which don't deliver
pure Python tuples for result rows would
fail to decrement refcounts correctly.
The most prominently affected DBAPI
is pyodbc. [ticket:2489]
- [bug] Fixed bug affecting Py3K whereby
string positional parameters passed to
engine/connection execute() would fail to be
interpreted correctly, due to __iter__
being present on Py3K string.
[ticket:2503].
- postgresql
- [bug] removed unnecessary table clause when
reflecting enums, [ticket:2510]. Courtesy
Gunnlaugur Þór Briem.
- oracle
- [bug] Added ROWID to oracle.*, [ticket:2483]
- mysql
- [feature] Added a new dialect for Google App
Engine. Courtesy Richie Foreman. [ticket:2484]
0.7.7
=====
- orm
- [bug] Fixed issue in unit of work
whereby setting a non-None self-referential
many-to-one relationship to None
would fail to persist the change if the
former value was not already loaded.
[ticket:2477].
- [feature] Added prefix_with() method
to Query, calls upon select().prefix_with()
to allow placement of MySQL SELECT
directives in statements. Courtesy
Diana Clarke [ticket:2443]
- [bug] Fixed bug in 0.7.6 introduced by
[ticket:2409] whereby column_mapped_collection
used against columns that were mapped as
joins or other indirect selectables
would fail to function.
- [feature] Added new flag to @validates
include_removes. When True, collection
remove and attribute del events
will also be sent to the validation function,
which accepts an additional argument
"is_remove" when this flag is used.
- [bug] Fixed bug whereby polymorphic_on
column that's not otherwise mapped on the
class would be incorrectly included
in a merge() operation, raising an error.
[ticket:2449]
- [bug] Fixed bug in expression annotation
mechanics which could lead to incorrect
rendering of SELECT statements with aliases
and joins, particularly when using
column_property(). [ticket:2453]
- [bug] Fixed bug which would prevent
OrderingList from being pickleable
[ticket:2454]. Courtesy Jeff Dairiki
- [bug] Fixed bug in relationship comparisons
whereby calling unimplemented methods like
SomeClass.somerelationship.like() would
produce a recursion overflow, instead
of NotImplementedError.
- sql
- [bug] Removed warning when Index is created
with no columns; while this might not be what
the user intended, it is a valid use case
as an Index could be a placeholder for just an
index of a certain name.
- [feature] Added new connection event
dbapi_error(). Is called for all DBAPI-level
errors passing the original DBAPI exception
before SQLAlchemy modifies the state
of the cursor.
- [bug] If conn.begin() fails when calling
"with engine.begin()", the newly acquired
Connection is closed explicitly before
propagating the exception onward normally.
- [bug] Add BINARY, VARBINARY to types.__all__,
[ticket:2474]
- mssql
- [feature] Added interim create_engine flag
supports_unicode_binds to PyODBC dialect,
to force whether or not the dialect
passes Python unicode literals to PyODBC
or not.
- [bug] Repaired the use_scope_identity
create_engine() flag when using the pyodbc
dialect. Previously this flag would be
ignored if set to False. When set to False,
you'll get "SELECT @@identity" after each
INSERT to get at the last inserted ID,
for those tables which have "implicit_returning"
set to False.
- [bug] UPDATE..FROM syntax with SQL Server
requires that the updated table be present
in the FROM clause when an alias of that
table is also present in the FROM clause.
The updated table is now always present
in the FROM, when FROM is present
in the first place. Courtesy sayap.
[ticket:2468]
- postgresql
- [feature] Added new for_update/with_lockmode()
options for Postgresql: for_update="read"/
with_lockmode("read"),
for_update="read_nowait"/
with_lockmode("read_nowait").
These emit "FOR SHARE" and "FOR SHARE NOWAIT",
respectively. Courtesy Diana Clarke
[ticket:2445]
- [bug] removed unnecessary table clause
when reflecting domains, [ticket:2473]
- mysql
- [bug] Fixed bug whereby column name inside
of "KEY" clause for autoincrement composite
column with InnoDB would double quote a
name that's a reserved word. Courtesy Jeff
Dairiki. [ticket:2460]
- [bug] Fixed bug whereby get_view_names() for
"information_schema" schema would fail
to retrieve views marked as "SYSTEM VIEW".
courtesy Matthew Turland.
- [bug] Fixed bug whereby if cast() is used
on a SQL expression whose type is not supported
by cast() and therefore CAST isn't rendered by
the dialect, the order of evaluation could change
if the casted expression required that it be
grouped; grouping is now applied to those
expressions. [ticket:2467]
- sqlite
- [feature] Added SQLite execution option
"sqlite_raw_colnames=True", will bypass
attempts to remove "." from column names
returned by SQLite cursor.description.
[ticket:2475]
- [bug] When the primary key column of a Table
is replaced, such as via extend_existing,
the "auto increment" column used by insert()
constructs is reset. Previously it would
remain referring to the previous primary
key column. [ticket:2525]
0.7.6
=====
- orm
- [bug] Fixed event registration bug
which would primarily show up as
events not being registered with
sessionmaker() instances created
after the event was associated
with the Session class. [ticket:2424]
- [bug] Fixed bug whereby a primaryjoin
condition with a "literal" in it would
raise an error on compile with certain
kinds of deeply nested expressions
which also needed to render the same
bound parameter name more than once.
[ticket:2425]
- [feature] Added "no_autoflush" context
manager to Session, used with with:
will temporarily disable autoflush.
- [feature] Added cte() method to Query,
invokes common table expression support
from the Core (see below). [ticket:1859]
- [bug] Removed the check for number of
rows affected when doing a multi-delete
against mapped objects. If an ON DELETE
CASCADE exists between two rows, we can't
get an accurate rowcount from the DBAPI;
this particular count is not supported
on most DBAPIs in any case, MySQLdb
is the notable case where it is.
[ticket:2403]
- [bug] Fixed bug whereby objects using
attribute_mapped_collection or
column_mapped_collection could not be
pickled. [ticket:2409]
- [bug] Fixed bug whereby MappedCollection
would not get the appropriate collection
instrumentation if it were only used
in a custom subclass that used
@collection.internally_instrumented.
[ticket:2406]
- [bug] Fixed bug whereby SQL adaption mechanics
would fail in a very nested scenario involving
joined-inheritance, joinedload(), limit(), and a
derived function in the columns clause.
[ticket:2419]
- [bug] Fixed the repr() for CascadeOptions to
include refresh-expire. Also reworked
CascadeOptions to be a <frozenset>.
[ticket:2417]
- [feature] Added the ability to query for
Table-bound column names when using
query(sometable).filter_by(colname=value).
[ticket:2400]
- [bug] Improved the "declarative reflection"
example to support single-table inheritance,
multiple calls to prepare(), tables that
are present in alternate schemas,
establishing only a subset of classes
as reflected.
- [bug] Scaled back the test applied within
flush() to check for UPDATE against partially
NULL PK within one table to only actually
happen if there's really an UPDATE to occur.
[ticket:2390]
- [bug] Fixed bug whereby if a method name
conflicted with a column name, a
TypeError would be raised when the mapper
tried to inspect the __get__() method
on the method object. [ticket:2352]
- sql
- [bug] Fixed memory leak in core which would
occur when C extensions were used with
particular types of result fetches,
in particular when orm query.count()
were called. [ticket:2427]
- [bug] Fixed issue whereby attribute-based
column access on a row would raise
AttributeError with non-C version,
NoSuchColumnError with C version. Now
raises AttributeError in both cases.
[ticket:2398]
- [feature] Added support for SQL standard
common table expressions (CTE), allowing
SELECT objects as the CTE source (DML
not yet supported). This is invoked via
the cte() method on any select() construct.
[ticket:1859]
- [bug] Added support for using the .key
of a Column as a string identifier in a
result set row. The .key is currently
listed as an "alternate" name for a column,
and is superseded by the name of a column
which has that key value as its regular name.
For the next major release
of SQLAlchemy we may reverse this precedence
so that .key takes precedence, but this
is not decided on yet. [ticket:2392]
- [bug] A warning is emitted when a not-present
column is stated in the values() clause
of an insert() or update() construct.
Will move to an exception in 0.8.
[ticket:2413]
- [bug] A significant change to how labeling
is applied to columns in SELECT statements
allows "truncated" labels, that is label names
that are generated in Python which exceed
the maximum identifier length (note this is
configurable via label_length on create_engine()),
to be properly referenced when rendered inside
of a subquery, as well as to be present
in a result set row using their original
in-Python names. [ticket:2396]
- [bug] Fixed bug in new "autoload_replace" flag
which would fail to preserve the primary
key constraint of the reflected table.
[ticket:2402]
- [bug] Index will raise when arguments passed
cannot be interpreted as columns or expressions.
Will warn when Index is created
with no columns at all. [ticket:2380]
- engine
- [feature] Added "no_parameters=True" execution
option for connections. If no parameters
are present, will pass the statement
as cursor.execute(statement), thereby invoking
the DBAPIs behavior when no parameter collection
is present; for psycopg2 and mysql-python, this
means not interpreting % signs in the string.
This only occurs with this option, and not
just if the param list is blank, as otherwise
this would produce inconsistent behavior
of SQL expressions that normally escape percent
signs (and while compiling, can't know ahead of
time if parameters will be present in
some cases). [ticket:2407]
- [bug] Added execution_options() call to
MockConnection (i.e., that used with
strategy="mock") which acts as a pass through
for arguments.
- [feature] Added pool_reset_on_return argument
to create_engine, allows control over
"connection return" behavior. Also added
new arguments 'rollback', 'commit', None
to pool.reset_on_return to allow more control
over connection return activity. [ticket:2378]
- [feature] Added some decent context managers
to Engine, Connection:
with engine.begin() as conn:
<work with conn in a transaction>
and:
with engine.connect() as conn:
<work with conn>
Both close out the connection when done,
commit or rollback transaction with errors
on engine.begin().
- sqlite
- [bug] Fixed bug in C extensions whereby
string format would not be applied to a
Numeric value returned as integer; this
affected primarily SQLite which does
not maintain numeric scale settings.
[ticket:2432]
- mssql
- [feature] Added support for MSSQL INSERT,
UPDATE, and DELETE table hints, using
new with_hint() method on UpdateBase.
[ticket:2430]
- mysql
- [feature] Added support for MySQL index and
primary key constraint types
(i.e. USING) via new mysql_using parameter
to Index and PrimaryKeyConstraint,
courtesy Diana Clarke. [ticket:2386]
- [feature] Added support for the "isolation_level"
parameter to all MySQL dialects. Thanks
to mu_mind for the patch here. [ticket:2394]
- oracle
- [feature] Added a new create_engine() flag
coerce_to_decimal=False, disables the precision
numeric handling which can add lots of overhead
by converting all numeric values to
Decimal. [ticket:2399]
- [bug] Added missing compilation support for
LONG [ticket:2401]
- [bug] Added 'LEVEL' to the list of reserved
words for Oracle. [ticket:2435]
- examples
- [bug] Altered _params_from_query() function
in Beaker example to pull bindparams from the
fully compiled statement, as a quick means
to get everything including subqueries in the
columns clause, etc.
0.7.5 (January 28, 2012)
=====
- orm
- [bug] Fixed issue where modified session state
established after a failed flush would be committed
as part of the subsequent transaction that
begins automatically after manual call
to rollback(). The state of the session is
checked within rollback(), and if new state
is present, a warning is emitted and
restore_snapshot() is called a second time,
discarding those changes. [ticket:2389]
- [bug] Fixed regression from 0.7.4 whereby
using an already instrumented column from a
superclass as "polymorphic_on" failed to resolve
the underlying Column. [ticket:2345]
- [bug] Raise an exception if xyzload_all() is
used inappropriately with two non-connected
relationships. [ticket:2370]
- [feature] Added "class_registry" argument to
declarative_base(). Allows two or more declarative
bases to share the same registry of class names.
- [feature] query.filter() accepts multiple
criteria which will join via AND, i.e.
query.filter(x==y, z>q, ...)
- [feature] Added new capability to relationship
loader options to allow "default" loader strategies.
Pass '*' to any of joinedload(), lazyload(),
subqueryload(), or noload() and that becomes the
loader strategy used for all relationships,
except for those explicitly stated in the
Query. Thanks to up-and-coming contributor
Kent Bower for an exhaustive and well
written test suite ! [ticket:2351]
- [bug] Fixed bug whereby event.listen(SomeClass)
forced an entirely unnecessary compile of the
mapper, making events very hard to set up
at module import time (nobody noticed this ??)
[ticket:2367]
- [bug] Fixed bug whereby hybrid_property didn't
work as a kw arg in any(), has().
- Fixed regression from 0.6 whereby if
"load_on_pending" relationship() flag were used
where a non-"get()" lazy clause needed to be
emitted on a pending object, it would fail
to load.
- [bug] ensure pickleability of all ORM exceptions
for multiprocessing compatibility. [ticket:2371]
- [bug] implemented standard "can't set attribute" /
"can't delete attribute" AttributeError when
setattr/delattr used on a hybrid that doesn't
define fset or fdel. [ticket:2353]
- [bug] Fixed bug where unpickled object didn't
have enough of its state set up to work
correctly within the unpickle() event established
by the mutable object extension, if the object
needed ORM attribute access within
__eq__() or similar. [ticket:2362]
- [bug] Fixed bug where "merge" cascade could
mis-interpret an unloaded attribute, if the
load_on_pending flag were used with
relationship(). Thanks to Kent Bower
for tests. [ticket:2374]
- [feature] New declarative reflection example
added, illustrates how best to mix table reflection
with declarative as well as uses some new features
from [ticket:2356].
- sql
- [feature] New reflection feature "autoload_replace";
when set to False on Table, the Table can be autoloaded
without existing columns being replaced. Allows
more flexible chains of Table construction/reflection
to be constructed, including that it helps with
combining Declarative with table reflection.
See the new example on the wiki. [ticket:2356]
- [bug] Improved the API for add_column() such that
if the same column is added to its own table,
an error is not raised and the constraints
don't get doubled up. Also helps with some
reflection/declarative patterns. [ticket:2356]
- [feature] Added "false()" and "true()" expression
constructs to sqlalchemy.sql namespace, though
not part of __all__ as of yet.
- [feature] Dialect-specific compilers now raise
CompileException for all type/statement compilation
issues, instead of InvalidRequestError or ArgumentError.
The DDL for CREATE TABLE will re-raise
CompileExceptions to include table/column information
for the problematic column. [ticket:2361]
- [bug] Fixed issue where the "required" exception
would not be raised for bindparam() with required=True,
if the statement were given no parameters at all.
[ticket:2381]
- engine
- [bug] Added __reduce__ to StatementError,
DBAPIError, column errors so that exceptions
are pickleable, as when using multiprocessing.
However, not
all DBAPIs support this yet, such as
psycopg2. [ticket:2371]
- [bug] Improved error messages when a non-string
or invalid string is passed to any of the
date/time processors used by SQLite, including
C and Python versions. [ticket:2382]
- [bug] Fixed bug whereby a table-bound Column
object named "<a>_<b>" which matched a column
labeled as "<tablename>_<colname>" could match
inappropriately when targeting in a result
set row. [ticket:2377]
- [bug] Fixed bug in "mock" strategy whereby
correct DDL visit method wasn't called, resulting
in "CREATE/DROP SEQUENCE" statements being
duplicated [ticket:2384]
- sqlite
- [bug] the "name" of an FK constraint in SQLite
is reflected as "None", not "0" or other
integer value [ticket:2364].
SQLite does not appear to support constraint
naming in any case.
- [bug] sql.false() and sql.true() compile to
0 and 1, respectively in sqlite [ticket:2368]
- [bug] removed an erroneous "raise" in the
SQLite dialect when getting table names
and view names, where logic is in place
to fall back to an older version of
SQLite that doesn't have the
"sqlite_temp_master" table.
- mysql
- [bug] fixed regexp that filters out warnings
for non-reflected "PARTITION" directives,
thanks to George Reilly [ticket:2376]
- mssql
- [bug] Adjusted the regexp used in the
mssql.TIME type to ensure only six digits
are received for the "microseconds" portion
of the value, which is expected by
Python's datetime.time(). Note that
support for sending microseconds doesn't
seem to be possible yet with pyodbc
at least. [ticket:2340]
- [bug] Dropped the "30 char" limit on pymssql,
based on reports that it's doing things
better these days. pymssql hasn't been
well tested and as the DBAPI is in flux
it's still not clear what the status
is on this driver and how SQLAlchemy's
implementation should adapt. [ticket:2347]
- oracle
- [bug] Added ORA-03135 to the never ending
list of oracle "connection lost" errors
[ticket:2388]
- core
- [bug] Changed LRUCache, used by the mapper
to cache INSERT/UPDATE/DELETE statements,
to use an incrementing counter instead
of a timestamp to track entries, for greater
reliability versus using time.time(), which
can cause test failures on some platforms.
[ticket:2379]
- [bug] Added a boolean check for the "finalize"
function within the pool connection proxy's
weakref callback before calling it, so that a
warning isn't emitted that this function is None
when the application is exiting and gc has
removed the function from the module before the
weakref callback was invoked. [ticket:2383]
- Py3K
- [bug] Fixed inappropriate usage of util.py3k
flag and renamed it to util.py3k_warning, since
this flag is intended to detect the -3 flag
series of import restrictions only.
[ticket:2348]
- examples
- [feature] Simplified the versioning example
a bit to use a declarative mixin as well
as an event listener, instead of a metaclass +
SessionExtension. [ticket:2313]
- [bug] Fixed large_collection.py to close the
session before dropping tables. [ticket:2346]
0.7.4 (December 9, 2011)
=====
- orm
- [bug] Fixed backref behavior when "popping" the
value off of a many-to-one in response to
a removal from a stale one-to-many - the operation
is skipped, since the many-to-one has since
been updated. [ticket:2315]
- [bug] After some years of not doing this, added
more granularity to the "is X a parent of Y"
functionality, which is used when determining
if the FK on "Y" needs to be "nulled out" as well
as if "Y" should be deleted with delete-orphan
cascade. The test now takes into account the
Python identity of the parent as well its identity
key, to see if the last known parent of Y is
definitely X. If a decision
can't be made, a StaleDataError is raised. The
conditions where this error is raised are fairly
rare, requiring that the previous parent was
garbage collected, and previously
could very well inappropriately update/delete
a record that's since moved onto a new parent,
though there may be some cases where
"silent success" occurred previously that will now
raise in the face of ambiguity.
Expiring "Y" resets the "parent" tracker, meaning
X.remove(Y) could then end up deleting Y even
if X is stale, but this is the same behavior
as before; it's advised to expire X also in that
case. [ticket:2264]
- [bug] fixed inappropriate evaluation of user-mapped
object in a boolean context within query.get()
[ticket:2310]. Also in 0.6.9.
- [bug] Added missing comma to PASSIVE_RETURN_NEVER_SET
symbol [ticket:2304]
- [bug] Cls.column.collate("some collation") now
works. [ticket:1776] Also in 0.6.9
- [bug] the value of a composite attribute is now
expired after an insert or update operation, instead
of regenerated in place. This ensures that a
column value which is expired within a flush
will be loaded first, before the composite
is regenerated using that value. [ticket:2309]
- [bug] The fix in [ticket:2309] also emits the
"refresh" event when the composite value is
loaded on access, even if all column
values were already present, as is appropriate.
This fixes the "mutable" extension which relies
upon the "load" event to ensure the _parents
dictionary is up to date, fixes [ticket:2308].
Thanks to Scott Torborg for the test case here.
- [bug] Fixed bug whereby a subclass of a subclass
using concrete inheritance in conjunction with
the new ConcreteBase or AbstractConcreteBase
would fail to apply the subclasses deeper than
one level to the "polymorphic loader" of each
base [ticket:2312]
- [bug] Fixed bug whereby a subclass of a subclass
using the new AbstractConcreteBase would fail
to acquire the correct "base_mapper" attribute
when the "base" mapper was generated, thereby
causing failures later on. [ticket:2312]
- [bug] Fixed bug whereby column_property() created
against ORM-level column could be treated as
a distinct entity when producing certain
kinds of joined-inh joins. [ticket:2316]
- [bug] Fixed the error formatting raised when
a tuple is inadvertently passed to session.query()
[ticket:2297]. Also in 0.6.9.
- [bug] Calls to query.join() to a single-table
inheritance subclass are now tracked, and
are used to eliminate the additional WHERE..
IN criterion normally tacked on with single
table inheritance, since the join should
accommodate it. This allows OUTER JOIN
to a single table subclass to produce
the correct results, and overall will produce
fewer WHERE criterion when dealing with
single table inheritance joins.
[ticket:2328]
- [bug] __table_args__ can now be passed as
an empty tuple as well as an empty dict.
[ticket:2339]. Thanks to Fayaz Yusuf Khan
for the patch.
- [bug] Updated warning message when setting
delete-orphan without delete to no longer
refer to 0.6, as we never got around to
upgrading this to an exception. Ideally
this might be better as an exception but
it's not critical either way. [ticket:2325]
- [feature] polymorphic_on now accepts many
new kinds of values:
- standalone expressions that aren't
otherwise mapped
- column_property() objects
- string names of any column_property()
or attribute name of a mapped Column
The docs include an example using
the case() construct, which is likely to be
a common constructed used here.
[ticket:2345] and part of [ticket:2238]
Standalone expressions in polymorphic_on
propagate to single-table inheritance
subclasses so that they are used in the
WHERE /JOIN clause to limit rows to that
subclass as is the usual behavior.
- [feature] IdentitySet supports the - operator
as the same as difference(), handy when dealing
with Session.dirty etc. [ticket:2301]
- [feature] Added new value for Column autoincrement
called "ignore_fk", can be used to force autoincrement
on a column that's still part of a ForeignKeyConstraint.
New example in the relationship docs illustrates
its use.
- [bug] Fixed bug in get_history() when referring
to a composite attribute that has no value;
added coverage for get_history() regarding
composites which is otherwise just a userland
function.
- sql
- [bug] related to [ticket:2316], made some
adjustments to the change from [ticket:2261]
regarding the "from" list on a select(). The
_froms collection is no longer memoized, as this
simplifies various use cases and removes the
need for a "warning" if a column is attached
to a table after it was already used in an
expression - the select() construct will now
always produce the correct expression.
There's probably no real-world
performance hit here; select() objects are
almost always made ad-hoc, and systems that
wish to optimize the re-use of a select()
would be using the "compiled_cache" feature.
A hit which would occur when calling select.bind
has been reduced, but the vast majority
of users shouldn't be using "bound metadata"
anyway :).
- [feature] The update() construct can now accommodate
multiple tables in the WHERE clause, which will
render an "UPDATE..FROM" construct, recognized by
Postgresql and MSSQL. When compiled on MySQL,
will instead generate "UPDATE t1, t2, ..". MySQL
additionally can render against multiple tables in the
SET clause, if Column objects are used as keys
in the "values" parameter or generative method.
[ticket:2166] [ticket:1944]
- [feature] Added accessor to types called "python_type",
returns the rudimentary Python type object
for a particular TypeEngine instance, if known,
else raises NotImplementedError. [ticket:77]
- [bug] further tweak to the fix from [ticket:2261],
so that generative methods work a bit better
off of cloned (this is almost a non-use case though).
In particular this allows with_only_columns()
to behave more consistently. Added additional
documentation to with_only_columns() to clarify
expected behavior, which changed as a result
of [ticket:2261]. [ticket:2319]
- engine
- [bug] Fixed bug whereby transaction.rollback()
would throw an error on an invalidated
connection if the transaction were a
two-phase or savepoint transaction.
For plain transactions, rollback() is a no-op
if the connection is invalidated, so while
it wasn't 100% clear if it should be a no-op,
at least now the interface is consistent.
[ticket:2317]
- schema
- [feature] Added new support for remote "schemas":
- MetaData() accepts "schema" and "quote_schema"
arguments, which will be applied to the same-named
arguments of a Table
or Sequence which leaves these at their default
of ``None``.
- Sequence accepts "quote_schema" argument
- tometadata() for Table will use the "schema"
of the incoming MetaData for the new Table
if the schema argument is explicitly "None"
- Added CreateSchema and DropSchema DDL
constructs - these accept just the string
name of a schema and a "quote" flag.
- When using default "schema" with MetaData,
ForeignKey will also assume the "default" schema
when locating remote table. This allows the "schema"
argument on MetaData to be applied to any
set of Table objects that otherwise don't have
a "schema".
- a "has_schema" method has been implemented
on dialect, but only works on Postgresql so far.
Courtesy Manlio Perillo, [ticket:1679]
- [feature] The "extend_existing" flag on Table
now allows for the reflection process to take
effect for a Table object that's already been
defined; when autoload=True and extend_existing=True
are both set, the full set of columns will be
reflected from the Table which will then
*overwrite* those columns already present,
rather than no activity occurring. Columns that
are present directly in the autoload run
will be used as always, however.
[ticket:1410]
- [bug] Fixed bug whereby TypeDecorator would
return a stale value for _type_affinity, when
using a TypeDecorator that "switches" types,
like the CHAR/UUID type.
- [bug] Fixed bug whereby "order_by='foreign_key'"
option to Inspector.get_table_names
wasn't implementing the sort properly, replaced
with the existing sort algorithm
- [bug] the "name" of a column-level CHECK constraint,
if present, is now rendered in the CREATE TABLE
statement using "CONSTRAINT <name> CHECK <expression>".
[ticket:2305]
- pyodbc
- [bug] pyodbc-based dialects now parse the
pyodbc accurately as far as observed
pyodbc strings, including such gems
as "py3-3.0.1-beta4" [ticket:2318]
- postgresql
- [bug] Postgresql dialect memoizes that an ENUM of a
particular name was processed
during a create/drop sequence. This allows
a create/drop sequence to work without any
calls to "checkfirst", and also means with
"checkfirst" turned on it only needs to
check for the ENUM once. [ticket:2311]
- [feature] Added create_type constructor argument
to pg.ENUM. When False, no CREATE/DROP or
checking for the type will be performed as part
of a table create/drop event; only the
create()/drop)() methods called directly
will do this. Helps with Alembic "offline"
scripts.
- mssql
- [feature] lifted the restriction on SAVEPOINT
for SQL Server. All tests pass using it,
it's not known if there are deeper issues
however. [ticket:822]
- [bug] repaired the with_hint() feature which
wasn't implemented correctly on MSSQL -
usually used for the "WITH (NOLOCK)" hint
(which you shouldn't be using anyway !
use snapshot isolation instead :) )
[ticket:2336]
- [bug] use new pyodbc version detection for
_need_decimal_fix option, [ticket:2318]
- [bug] don't cast "table name" as NVARCHAR
on SQL Server 2000. Still mostly in the dark
what incantations are needed to make PyODBC
work fully with FreeTDS 0.91 here, however.
[ticket:2343]
- [bug] Decode incoming values when retrieving
list of index names and the names of columns
within those indexes. [ticket:2269]
- mysql
- [bug] Unicode adjustments allow latest pymysql
(post 0.4) to pass 100% on Python 2.
- ext
- [feature] Added an example to the hybrid docs
of a "transformer" - a hybrid that returns a
query-transforming callable in combination
with a custom comparator. Uses a new method
on Query called with_transformation(). The use
case here is fairly experimental, but only
adds one line of code to Query.
- [bug] the @compiles decorator raises an
informative error message when no "default"
compilation handler is present, rather
than KeyError.
- examples
- [bug] Fixed bug in history_meta.py example where
the "unique" flag was not removed from a
single-table-inheritance subclass which
generates columns to put up onto the base.
0.7.3
=====
- general
- Adjusted the "importlater" mechanism, which is
used internally to resolve import cycles,
such that the usage of __import__ is completed
when the import of sqlalchemy or sqlalchemy.orm
is done, thereby avoiding any usage of __import__
after the application starts new threads,
fixes [ticket:2279]. Also in 0.6.9.
- orm
- Improved query.join() such that the "left" side
can more flexibly be a non-ORM selectable,
such as a subquery. A selectable placed
in select_from() will now be used as the left
side, favored over implicit usage
of a mapped entity.
If the join still fails based on lack of
foreign keys, the error message includes
this detail. Thanks to brianrhude
on IRC for the test case. [ticket:2298]
- Added after_soft_rollback() Session event. This
event fires unconditionally whenever rollback()
is called, regardless of if an actual DBAPI
level rollback occurred. This event
is specifically designed to allow operations
with the Session to proceed after a rollback
when the Session.is_active is True.
[ticket:2241]
- added "adapt_on_names" boolean flag to orm.aliased()
construct. Allows an aliased() construct
to link the ORM entity to a selectable that contains
aggregates or other derived forms of a particular
attribute, provided the name is the same as that
of the entity mapped column.
- Added new flag expire_on_flush=False to column_property(),
marks those properties that would otherwise be considered
to be "readonly", i.e. derived from SQL expressions,
to retain their value after a flush has occurred, including
if the parent object itself was involved in an update.
- Enhanced the instrumentation in the ORM to support
Py3K's new argument style of "required kw arguments",
i.e. fn(a, b, *, c, d), fn(a, b, *args, c, d).
Argument signatures of mapped object's __init__
method will be preserved, including required kw rules.
[ticket:2237]
- Fixed bug in unit of work whereby detection of
"cycles" among classes in highly interlinked patterns
would not produce a deterministic
result; thereby sometimes missing some nodes that
should be considered cycles and causing further
issues down the road. Note this bug is in 0.6
also; not backported at the moment.
[ticket:2282]
- Fixed a variety of synonym()-related regressions
from 0.6:
- making a synonym against a synonym now works.
- synonyms made against a relationship() can
be passed to query.join(), options sent
to query.options(), passed by name
to query.with_parent().
- Fixed bug whereby mapper.order_by attribute would
be ignored in the "inner" query within a
subquery eager load. [ticket:2287].
Also in 0.6.9.
- Identity map .discard() uses dict.pop(,None)
internally instead of "del" to avoid KeyError/warning
during a non-determinate gc teardown [ticket:2267]
- Fixed regression in new composite rewrite where
deferred=True option failed due to missing
import [ticket:2253]
- Reinstated "comparator_factory" argument to
composite(), removed when 0.7 was released.
[ticket:2248]
- Fixed bug in query.join() which would occur
in a complex multiple-overlapping path scenario,
where the same table could be joined to
twice. Thanks *much* to Dave Vitek
for the excellent fix here. [ticket:2247]
- Query will convert an OFFSET of zero when
slicing into None, so that needless OFFSET
clauses are not invoked.
- Repaired edge case where mapper would fail
to fully update internal state when a relationship
on a new mapper would establish a backref on the
first mapper.
- Fixed bug whereby if __eq__() was
redefined, a relationship many-to-one lazyload
would hit the __eq__() and fail. [ticket:2260]
Does not apply to 0.6.9.
- Calling class_mapper() and passing in an object
that is not a "type" (i.e. a class that could
potentially be mapped) now raises an informative
ArgumentError, rather than UnmappedClassError.
[ticket:2196]
- New event hook, MapperEvents.after_configured().
Called after a configure() step has completed and
mappers were in fact affected. Theoretically this
event is called once per application, unless new mappings
are constructed after existing ones have been used
already.
- When an open Session is garbage collected, the objects
within it which remain are considered detached again
when they are add()-ed to a new Session.
This is accomplished by an extra check that the previous
"session_key" doesn't actually exist among the pool
of Sessions. [ticket:2281]
- New declarative features:
- __declare_last__() method, establishes an event
listener for the class method that will be called
when mappers are completed with the final "configure"
step.
- __abstract__ flag. The class will not be mapped
at all when this flag is present on the class.
- New helper classes ConcreteBase, AbstractConcreteBase.
Allow concrete mappings using declarative which automatically
set up the "polymorphic_union" when the "configure"
mapper step is invoked.
- The mapper itself has semi-private methods that allow
the "with_polymorphic" selectable to be assigned
to the mapper after it has already been configured.
[ticket:2239]
- Declarative will warn when a subclass' base uses
@declared_attr for a regular column - this attribute
does not propagate to subclasses. [ticket:2283]
- The integer "id" used to link a mapped instance with
its owning Session is now generated by a sequence
generation function rather than id(Session), to
eliminate the possibility of recycled id() values
causing an incorrect result, no need to check that
object actually in the session. [ticket:2280]
-sql
- Behavioral improvement: empty
conjunctions such as and_() and or_() will be
flattened in the context of an enclosing conjunction,
i.e. and_(x, or_()) will produce 'X' and not 'X AND
()'. [ticket:2257].
- Fixed bug regarding calculation of "from" list
for a select() element. The "from" calc is now
delayed, so that if the construct uses a Column
object that is not yet attached to a Table,
but is later associated with a Table, it generates
SQL using the table as a FROM. This change
impacted fairly deeply the mechanics of how
the FROM list as well as the "correlates" collection
is calculated, as some "clause adaption" schemes
(these are used very heavily in the ORM)
were relying upon the fact that the "froms"
collection would typically be cached before the
adaption completed. The rework allows it
such that the "froms" collection can be cleared
and re-generated at any time. [ticket:2261]
- Fixed bug whereby with_only_columns() method of
Select would fail if a selectable were passed.
[ticket:2270]. Also in 0.6.9.
- schema
- Modified Column.copy() to use _constructor(),
which defaults to self.__class__, in order to
create the new object. This allows easier support
of subclassing Column. [ticket:2284]
- Added a slightly nicer __repr__() to SchemaItem
classes. Note the repr here can't fully support
the "repr is the constructor" idea since schema
items can be very deeply nested/cyclical, have
late initialization of some things, etc.
[ticket:2223]
- engine
- The recreate() method in all pool classes uses
self.__class__ to get at the type of pool
to produce, in the case of subclassing. Note
there's no usual need to subclass pools.
[ticket:2254]
- Improvement to multi-param statement logging,
long lists of bound parameter sets will be
compressed with an informative indicator
of the compression taking place. Exception
messages use the same improved formatting.
[ticket:2243]
- Added optional "sa_pool_key" argument to
pool.manage(dbapi).connect() so that serialization
of args is not necessary.
- The entry point resolution supported by
create_engine() now supports resolution of
individual DBAPI drivers on top of a built-in
or entry point-resolved dialect, using the
standard '+' notation - it's converted to
a '.' before being resolved as an entry
point. [ticket:2286]
- Added an exception catch + warning for the
"return unicode detection" step within connect,
allows databases that crash on NVARCHAR to
continue initializing, assuming no NVARCHAR
type implemented. [ticket:2299]
- types
- Extra keyword arguments to the base Float
type beyond "precision" and "asdecimal" are ignored;
added a deprecation warning here and additional
docs, related to [ticket:2258]
- sqlite
- Ensured that the same ValueError is raised for
illegal date/time/datetime string parsed from
the database regardless of whether C
extensions are in use or not.
- postgresql
- Added "postgresql_using" argument to Index(), produces
USING clause to specify index implementation for
PG. [ticket:2290]. Thanks to Ryan P. Kelly for
the patch.
- Added client_encoding parameter to create_engine()
when the postgresql+psycopg2 dialect is used;
calls the psycopg2 set_client_encoding() method
with the value upon connect. [ticket:1839]
- Fixed bug related to [ticket:2141] whereby the
same modified index behavior in PG 9 affected
primary key reflection on a renamed column.
[ticket:2291]. Also in 0.6.9.
- Reflection functions for Table, Sequence no longer
case insensitive. Names can be differ only in case
and will be correctly distinguished. [ticket:2256]
- Use an atomic counter as the "random number"
source for server side cursor names;
conflicts have been reported in rare cases.
- Narrowed the assumption made when reflecting
a foreign-key referenced table with schema in
the current search path; an explicit schema will
be applied to the referenced table only if
it actually matches that of the referencing table,
which also has an explicit schema. Previously
it was assumed that "current" schema was synonymous
with the full search_path. [ticket:2249]
- mysql
- a CREATE TABLE will put the COLLATE option
after CHARSET, which appears to be part of
MySQL's arbitrary rules regarding if it will actually
work or not. [ticket:2225] Also in 0.6.9.
- Added mysql_length parameter to Index construct,
specifies "length" for indexes. [ticket:2293]
- mssql
- Changes to attempt support of FreeTDS 0.91 with
Pyodbc. This includes that string binds are sent as
Python unicode objects when FreeTDS 0.91 is detected,
and a CAST(? AS NVARCHAR) is used when we detect
for a table. However, I'd continue
to characterize Pyodbc + FreeTDS 0.91 behavior as
pretty crappy, there are still many queries such
as used in reflection which cause a core dump on
Linux, and it is not really usable at all
on OSX, MemoryErrors abound and just plain broken
unicode support. [ticket:2273]
- The behavior of =/!= when comparing a scalar select
to a value will no longer produce IN/NOT IN as of 0.8;
this behavior is a little too heavy handed (use in_() if
you want to emit IN) and now emits a deprecation warning.
To get the 0.8 behavior immediately and remove the warning,
a compiler recipe is given at
http://www.sqlalchemy.org/docs/07/dialects/mssql.html#scalar-select-comparisons
to override the behavior of visit_binary().
[ticket:2277]
- "0" is accepted as an argument for limit() which
will produce "TOP 0". [ticket:2222]
- oracle
- Fixed ReturningResultProxy for zxjdbc dialect.
[ticket:2272]. Regression from 0.6.
- The String type now generates VARCHAR2 on Oracle
which is recommended as the default VARCHAR.
Added an explicit VARCHAR2 and NVARCHAR2 to the Oracle
dialect as well. Using NVARCHAR still generates
"NVARCHAR2" - there is no "NVARCHAR" on Oracle -
this remains a slight breakage of the "uppercase types
always give exactly that" policy. VARCHAR still
generates "VARCHAR", keeping with the policy. If
Oracle were to ever define "VARCHAR" as something
different as they claim (IMHO this will never happen),
the type would be available. [ticket:2252]
- ext
- SQLSoup will not be included in version 0.8
of SQLAlchemy; while useful, we would like to
keep SQLAlchemy itself focused on one ORM
usage paradigm. SQLSoup will hopefully
soon be superseded by a third party
project. [ticket:2262]
- Added local_attr, remote_attr, attr accessors
to AssociationProxy, providing quick access
to the proxied attributes at the class
level. [ticket:2236]
- Changed the update() method on association proxy
dictionary to use a duck typing approach, i.e.
checks for "keys", to discern between update({})
and update((a, b)). Previously, passing a
dictionary that had tuples as keys would be misinterpreted
as a sequence. [ticket:2275]
- examples
- Adjusted dictlike-polymorphic.py example
to apply the CAST such that it works on
PG, other databases. [ticket:2266]
Also in 0.6.9.
0.7.2
=====
- orm
- Feature enhancement: joined and subquery
loading will now traverse already-present related
objects and collections in search of unpopulated
attributes throughout the scope of the eager load
being defined, so that the eager loading that is
specified via mappings or query options
unconditionally takes place for the full depth,
populating whatever is not already populated.
Previously, this traversal would stop if a related
object or collection were already present leading
to inconsistent behavior (though would save on
loads/cycles for an already-loaded graph). For a
subqueryload, this means that the additional
SELECT statements emitted by subqueryload will
invoke unconditionally, no matter how much of the
existing graph is already present (hence the
controversy). The previous behavior of "stopping"
is still in effect when a query is the result of
an attribute-initiated lazyload, as otherwise an
"N+1" style of collection iteration can become
needlessly expensive when the same related object
is encountered repeatedly. There's also an
as-yet-not-public generative Query method
_with_invoke_all_eagers()
which selects old/new behavior [ticket:2213]
- A rework of "replacement traversal" within
the ORM as it alters selectables to be against
aliases of things (i.e. clause adaption) includes
a fix for multiply-nested any()/has() constructs
against a joined table structure. [ticket:2195]
- Fixed bug where query.join() + aliased=True
from a joined-inh structure to itself on
relationship() with join condition on the child
table would convert the lead entity into the
joined one inappropriately. [ticket:2234]
Also in 0.6.9.
- Fixed regression from 0.6 where Session.add()
against an object which contained None in a
collection would raise an internal exception.
Reverted this to 0.6's behavior which is to
accept the None but obviously nothing is
persisted. Ideally, collections with None
present or on append() should at least emit a
warning, which is being considered for 0.8.
[ticket:2205]
- Load of a deferred() attribute on an object
where row can't be located raises
ObjectDeletedError instead of failing later
on; improved the message in ObjectDeletedError
to include other conditions besides a simple
"delete". [ticket:2191]
- Fixed regression from 0.6 where a get history
operation on some relationship() based attributes
would fail when a lazyload would emit; this could
trigger within a flush() under certain conditions.
[ticket:2224] Thanks to the user who submitted
the great test for this.
- Fixed bug apparent only in Python 3 whereby
sorting of persistent + pending objects during
flush would produce an illegal comparison,
if the persistent object primary key
is not a single integer. [ticket:2228]
Also in 0.6.9
- Fixed bug whereby the source clause
used by query.join() would be inconsistent
if against a column expression that combined
multiple entities together. [ticket:2197]
Also in 0.6.9
- Fixed bug whereby if a mapped class
redefined __hash__() or __eq__() to something
non-standard, which is a supported use case
as SQLA should never consult these,
the methods would be consulted if the class
was part of a "composite" (i.e. non-single-entity)
result set. [ticket:2215]
Also in 0.6.9.
- Added public attribute ".validators" to
Mapper, an immutable dictionary view of
all attributes that have been decorated
with the @validates decorator.
[ticket:2240] courtesy Stefano Fontanelli
- Fixed subtle bug that caused SQL to blow
up if: column_property() against subquery +
joinedload + LIMIT + order by the column
property() occurred. [ticket:2188].
Also in 0.6.9
- The join condition produced by with_parent
as well as when using a "dynamic" relationship
against a parent will generate unique
bindparams, rather than incorrectly repeating
the same bindparam. [ticket:2207].
Also in 0.6.9.
- Added the same "columns-only" check to
mapper.polymorphic_on as used when
receiving user arguments to
relationship.order_by, foreign_keys,
remote_side, etc.
- Fixed bug whereby comparison of column
expression to a Query() would not call
as_scalar() on the underlying SELECT
statement to produce a scalar subquery,
in the way that occurs if you called
it on Query().subquery(). [ticket:2190]
- Fixed declarative bug where a class inheriting
from a superclass of the same name would fail
due to an unnecessary lookup of the name
in the _decl_class_registry. [ticket:2194]
- Repaired the "no statement condition"
assertion in Query which would attempt
to raise if a generative method were called
after from_statement() were called.
[ticket:2199]. Also in 0.6.9.
- sql
- Fixed two subtle bugs involving column
correspondence in a selectable,
one with the same labeled subquery repeated, the other
when the label has been "grouped" and
loses itself. Affects [ticket:2188].
- schema
- New feature: with_variant() method on
all types. Produces an instance of Variant(),
a special TypeDecorator which will select
the usage of a different type based on the
dialect in use. [ticket:2187]
- Added an informative error message when
ForeignKeyConstraint refers to a column name in
the parent that is not found. Also in 0.6.9.
- Fixed bug whereby adaptation of old append_ddl_listener()
function was passing unexpected **kw through
to the Table event. Table gets no kws, the MetaData
event in 0.6 would get "tables=somecollection",
this behavior is preserved. [ticket:2206]
- Fixed bug where "autoincrement" detection on
Table would fail if the type had no "affinity"
value, in particular this would occur when using
the UUID example on the site that uses TypeEngine
as the "impl".
- Added an improved repr() to TypeEngine objects
that will only display constructor args which
are positional or kwargs that deviate
from the default. [ticket:2209]
- engine
- Context manager provided by Connection.begin()
will issue rollback() if the commit() fails,
not just if an exception occurs.
- Use urllib.parse_qsl() in Python 2.6 and above,
no deprecation warning about cgi.parse_qsl()
[ticket:1682]
- Added mixin class sqlalchemy.ext.DontWrapMixin.
User-defined exceptions of this type are never
wrapped in StatementException when they
occur in the context of a statement
execution.
- StatementException wrapping will display the
original exception class in the message.
- Failures on connect which raise dbapi.Error
will forward the error to dialect.is_disconnect()
and set the "connection_invalidated" flag if
the dialect knows this to be a potentially
"retryable" condition. Only Oracle ORA-01033
implemented for now. [ticket:2201]
- sqlite
- SQLite dialect no longer strips quotes
off of reflected default value, allowing
a round trip CREATE TABLE to work.
This is consistent with other dialects
that also maintain the exact form of
the default. [ticket:2189]
- postgresql
- Added new "postgresql_ops" argument to
Index, allows specification of PostgreSQL
operator classes for indexed columns.
[ticket:2198] Courtesy Filip Zyzniewski.
- mysql
- Fixed OurSQL dialect to use ansi-neutral
quote symbol "'" for XA commands instead
of '"'. [ticket:2186]. Also in 0.6.9.
- mssql
- Adjusted the pyodbc dialect such that bound
values are passed as bytes and not unicode
if the "Easysoft" unix drivers are detected.
This is the same behavior as occurs with
FreeTDS. Easysoft appears to segfault
if Python unicodes are passed under
certain circumstances.
- oracle
- Added ORA-00028 to disconnect codes, use
cx_oracle _Error.code to get at the code,
[ticket:2200]. Also in 0.6.9.
- Added ORA-01033 to disconnect codes, which
can be caught during a connection
event. [ticket:2201]
- repaired the oracle.RAW type which did not
generate the correct DDL. [ticket:2220]
Also in 0.6.9.
- added CURRENT to reserved word list.
[ticket:2212] Also in 0.6.9.
-ext
- Fixed bug in the mutable extension whereby
if the same type were used twice in one
mapping, the attributes beyond the first
would not get instrumented.
- Fixed bug in the mutable extension whereby
if None or a non-corresponding type were set,
an error would be raised. None is now accepted
which assigns None to all attributes,
illegal values raise ValueError.
- examples
- Repaired the examples/versioning test runner
to not rely upon SQLAlchemy test libs,
nosetests must be run from within
examples/versioning to get around setup.cfg
breaking it.
- Tweak to examples/versioning to pick the
correct foreign key in a multi-level
inheritance situation.
- Fixed the attribute shard example to check
for bind param callable correctly in 0.7
style.
0.7.1
=====
- general
- Added a workaround for Python bug 7511 where
failure of C extension build does not
raise an appropriate exception on Windows 64
bit + VC express [ticket:2184]
- orm
- "delete-orphan" cascade is now allowed on
self-referential relationships - this since
SQLA 0.7 no longer enforces "parent with no
child" at the ORM level; this check is left
up to foreign key nullability.
Related to [ticket:1912]
- Repaired new "mutable" extension to propagate
events to subclasses correctly; don't
create multiple event listeners for
subclasses either. [ticket:2180]
- Modify the text of the message which occurs
when the "identity" key isn't detected on
flush, to include the common cause that
the Column isn't set up to detect
auto-increment correctly; [ticket:2170].
Also in 0.6.8.
- Fixed bug where transaction-level "deleted"
collection wouldn't be cleared of expunged
states, raising an error if they later
became transient [ticket:2182].
Also in 0.6.8.
- sql
- Fixed bug whereby metadata.reflect(bind)
would close a Connection passed as a
bind argument. Regression from 0.6.
- Streamlined the process by which a Select
determines what's in it's '.c' collection.
Behaves identically, except that a
raw ClauseList() passed to select([])
(which is not a documented case anyway) will
now be expanded into its individual column
elements instead of being ignored.
- engine
- Deprecate schema/SQL-oriented methods on
Connection/Engine that were never well known
and are redundant: reflecttable(), create(),
drop(), text(), engine.func
- Adjusted the __contains__() method of
a RowProxy result row such that no exception
throw is generated internally;
NoSuchColumnError() also will generate its
message regardless of whether or not the column
construct can be coerced to a string.
[ticket:2178]. Also in 0.6.8.
- sqlite
- Accept None from cursor.fetchone() when
"PRAGMA read_uncommitted" is called to determine
current isolation mode at connect time and
default to SERIALIZABLE; this to support SQLite
versions pre-3.3.0 that did not have this
feature. [ticket:2173]
- postgresql
- Some unit test fixes regarding numeric arrays,
MATCH operator. A potential floating-point
inaccuracy issue was fixed, and certain tests
of the MATCH operator only execute within an
EN-oriented locale for now. [ticket:2175].
Also in 0.6.8.
- mysql
- Unit tests pass 100% on MySQL installed
on windows.
- Removed the "adjust casing" step that would
fail when reflecting a table on MySQL
on windows with a mixed case name. After some
experimenting with a windows MySQL server, it's
been determined that this step wasn't really
helping the situation much; MySQL does not return
FK names with proper casing on non-windows
platforms either, and removing the step at
least allows the reflection to act more like
it does on other OSes. A warning here
has been considered but its difficult to
determine under what conditions such a warning
can be raised, so punted on that for now -
added some docs instead. [ticket:2181]
- supports_sane_rowcount will be set to False
if using MySQLdb and the DBAPI doesn't provide
the constants.CLIENT module.
0.7.0
=======
- This section documents those changes from 0.7b4
to 0.7.0. For an overview of what's new in
SQLAlchemy 0.7, see
http://www.sqlalchemy.org/trac/wiki/07Migration
- orm
- Fixed regression introduced in 0.7b4 (!) whereby
query.options(someoption("nonexistent name")) would
fail to raise an error. Also added additional
error catching for cases where the option would
try to build off a column-based element, further
fixed up some of the error messages tailored
in [ticket:2069]
- query.count() emits "count(*)" instead of
"count(1)". [ticket:2162]
- Fine tuning of Query clause adaptation when
from_self(), union(), or other "select from
myself" operation, such that plain SQL expression
elements added to filter(), order_by() etc.
which are present in the nested "from myself"
query *will* be adapted in the same way an ORM
expression element will, since these
elements are otherwise not easily accessible.
[ticket:2155]
- Fixed bug where determination of "self referential"
relationship would fail with no workaround
for joined-inh subclass related to itself,
or joined-inh subclass related to a subclass
of that with no cols in the sub-sub class
in the join condition. [ticket:2149]
Also in 0.6.8.
- mapper() will ignore non-configured foreign keys
to unrelated tables when determining inherit
condition between parent and child class,
but will raise as usual for unresolved
columns and table names regarding the inherited
table. This is an enhanced generalization of
behavior that was already applied to declarative
previously. [ticket:2153] 0.6.8 has a more
conservative version of this which doesn't
fundamentally alter how join conditions
are determined.
- It is an error to call query.get() when the
given entity is not a single, full class
entity or mapper (i.e. a column). This is
a deprecation warning in 0.6.8.
[ticket:2144]
- Fixed a potential KeyError which under some
circumstances could occur with the identity
map, part of [ticket:2148]
- added Query.with_session() method, switches
Query to use a different session.
- horizontal shard query should use execution
options per connection as per [ticket:2131]
- a non_primary mapper will inherit the _identity_class
of the primary mapper. This so that a non_primary
established against a class that's normally in an
inheritance mapping will produce results that are
identity-map compatible with that of the primary
mapper [ticket:2151] (also in 0.6.8)
- Fixed the error message emitted for "can't
execute syncrule for destination column 'q';
mapper 'X' does not map this column" to
reference the correct mapper. [ticket:2163].
Also in 0.6.8.
- polymorphic_union() gets a "cast_nulls" option,
disables the usage of CAST when it renders
the labeled NULL columns. [ticket:1502]
- polymorphic_union() renders the columns in their
original table order, as according to the first
table/selectable in the list of polymorphic
unions in which they appear. (which is itself
an unordered mapping unless you pass an OrderedDict).
- Fixed bug whereby mapper mapped to an anonymous
alias would fail if logging were used, due to
unescaped % sign in the alias name. [ticket:2171]
Also in 0.6.8.
- sql
- Fixed bug whereby nesting a label of a select()
with another label in it would produce incorrect
exported columns. Among other things this would
break an ORM column_property() mapping against
another column_property(). [ticket:2167].
Also in 0.6.8
- Changed the handling in determination of join
conditions such that foreign key errors are
only considered between the two given tables.
That is, t1.join(t2) will report FK errors
that involve 't1' or 't2', but anything
involving 't3' will be skipped. This affects
join(), as well as ORM relationship and
inherit condition logic.
- Some improvements to error handling inside
of the execute procedure to ensure auto-close
connections are really closed when very
unusual DBAPI errors occur.
- metadata.reflect() and reflection.Inspector()
had some reliance on GC to close connections
which were internally procured, fixed this.
- Added explicit check for when Column .name
is assigned as blank string [ticket:2140]
- Fixed bug whereby if FetchedValue was passed
to column server_onupdate, it would not
have its parent "column" assigned, added
test coverage for all column default assignment
patterns. [ticket:2147] also in 0.6.8
- postgresql
- Fixed the psycopg2_version parsing in the
psycopg2 dialect.
- Fixed bug affecting PG 9 whereby index reflection
would fail if against a column whose name
had changed. [ticket:2141]. Also in 0.6.8.
- mssql
- Fixed bug in MSSQL dialect whereby the aliasing
applied to a schema-qualified table would leak
into enclosing select statements [ticket:2169].
Also in 0.6.8.
- documentation
- Removed the usage of the "collections.MutableMapping"
abc from the ext.mutable docs as it was being used
incorrectly and makes the example more difficult
to understand in any case. [ticket:2152]
- examples
- removed the ancient "polymorphic association"
examples and replaced with an updated set of
examples that use declarative mixins,
"generic_associations". Each presents an alternative
table layout.
- ext
- Fixed bugs in sqlalchemy.ext.mutable extension where
`None` was not appropriately handled, replacement
events were not appropriately handled.
[ticket:2143]
0.7.0b4
=======
- general
- Changes to the format of CHANGES, this file.
The format changes have been applied to
the 0.7 releases.
- The "-declarative" changes will now be listed
directly under the "-orm" section, as these
are closely related.
- The 0.5 series changes have been moved to
the file CHANGES_PRE_06 which replaces
CHANGES_PRE_05.
- The changelog for 0.6.7 and subsequent within
the 0.6 series is now listed only in the
CHANGES file within the 0.6 branch.
In the 0.7 CHANGES file (i.e. this file), all the
0.6 changes are listed inline within the 0.7
section in which they were also applied
(since all 0.6 changes are in 0.7 as well).
Changes that apply to an 0.6 version here
are noted as are if any differences in
implementation/behavior are present.
- orm
- Some fixes to "evaulate" and "fetch" evaluation
when query.update(), query.delete() are called.
The retrieval of records is done after autoflush
in all cases, and before update/delete is
emitted, guarding against unflushed data present
as well as expired objects failing during
the evaluation. [ticket:2122]
- Reworded the exception raised when a flush
is attempted of a subclass that is not polymorphic
against the supertype. [ticket:2063]
- Still more wording adjustments when a query option
can't find the target entity. Explain that the
path must be from one of the root entities.
- Some fixes to the state handling regarding
backrefs, typically when autoflush=False, where
the back-referenced collection wouldn't
properly handle add/removes with no net
change. Thanks to Richard Murri for the
test case + patch. [ticket:2123]
(also in 0.6.7).
- Added checks inside the UOW to detect the unusual
condition of being asked to UPDATE or DELETE
on a primary key value that contains NULL
in it. [ticket:2127]
- Some refinements to attribute history. More
changes are pending possibly in 0.8, but
for now history has been modified such that
scalar history doesn't have a "side effect"
of populating None for a non-present value.
This allows a slightly better ability to
distinguish between a None set and no actual
change, affects [ticket:2127] as well.
- a "having" clause would be copied from the
inside to the outside query if from_self()
were used; in particular this would break
an 0.7 style count() query [ticket:2130].
(also in 0.6.7)
- the Query.execution_options() method now passes
those options to the Connection rather than
the SELECT statement, so that all available
options including isolation level and
compiled cache may be used. [ticket:2131]
- sql
- The "compiled_cache" execution option now raises
an error when passed to a SELECT statement
rather than a Connection. Previously it was
being ignored entirely. We may look into
having this option work on a per-statement
level at some point. [ticket:2131]
- Restored the "catchall" constructor on the base
TypeEngine class, with a deprecation warning.
This so that code which does something like
Integer(11) still succeeds.
- Fixed regression whereby MetaData() coming
back from unpickling did not keep track of
new things it keeps track of now, i.e.
collection of Sequence objects, list
of schema names. [ticket:2104]
- The limit/offset keywords to select() as well
as the value passed to select.limit()/offset()
will be coerced to integer. [ticket:2116]
(also in 0.6.7)
- fixed bug where "from" clause gathering from an
over() clause would be an itertools.chain() and
not a list, causing "can only concatenate list"
TypeError when combined with other clauses.
- Fixed incorrect usage of "," in over() clause
being placed between the "partition" and "order by"
clauses. [ticket:2134]
- Before/after attach events for PrimaryKeyConstraint
now function, tests added for before/after events
on all constraint types. [ticket:2105]
- Added explicit true()/false() constructs to expression
lib - coercion rules will intercept "False"/"True"
into these constructs. In 0.6, the constructs were
typically converted straight to string, which was
no longer accepted in 0.7. [ticket:2117]
- engine
- The C extension is now enabled by default on CPython
2.x with a fallback to pure python if it fails to
compile. [ticket:2129]
- schema
- The 'useexisting' flag on Table has been superceded
by a new pair of flags 'keep_existing' and
'extend_existing'. 'extend_existing' is equivalent
to 'useexisting' - the existing Table is returned,
and additional constructor elements are added.
With 'keep_existing', the existing Table is returned,
but additional constructor elements are not added -
these elements are only applied when the Table
is newly created. [ticket:2109]
- types
- REAL has been added to the core types. Supported
by Postgresql, SQL Server, MySQL, SQLite. Note
that the SQL Server and MySQL versions, which
add extra arguments, are also still available
from those dialects. [ticket:2081]
-event
- Added @event.listens_for() decorator, given
target + event name, applies the decorated
function as a listener. [ticket:2106]
- pool
- AssertionPool now stores the traceback indicating
where the currently checked out connection was
acquired; this traceback is reported within
the assertion raised upon a second concurrent
checkout; courtesy Gunnlaugur Briem
[ticket:2103]
- The "pool.manage" feature doesn't use pickle
anymore to hash the arguments for each pool.
- sqlite
- Fixed bug where reflection of foreign key
created as "REFERENCES <tablename>" without
col name would fail. [ticket:2115]
(also in 0.6.7)
- postgresql
- Psycopg2 for Python 3 is now supported.
- Fixed support for precision numerics when using
pg8000. [ticket:2132]
- oracle
- Using column names that would require quotes
for the column itself or for a name-generated
bind parameter, such as names with special
characters, underscores, non-ascii characters,
now properly translate bind parameter keys when
talking to cx_oracle. [ticket:2100] (Also
in 0.6.7)
- Oracle dialect adds use_binds_for_limits=False
create_engine() flag, will render the LIMIT/OFFSET
values inline instead of as binds, reported to
modify the execution plan used by Oracle.
[ticket:2116] (Also in 0.6.7)
- documentation
- Documented SQLite DATE/TIME/DATETIME types.
[ticket:2029] (also in 0.6.7)
- Fixed mutable extension docs to show the
correct type-association methods.
[ticket:2118]
0.7.0b3
=======
- general
- Lots of fixes to unit tests when run under Pypy
(courtesy Alex Gaynor).
- orm
- Changed the underlying approach to query.count().
query.count() is now in all cases exactly:
query.
from_self(func.count(literal_column('1'))).
scalar()
That is, "select count(1) from (<full query>)".
This produces a subquery in all cases, but
vastly simplifies all the guessing count()
tried to do previously, which would still
fail in many scenarios particularly when
joined table inheritance and other joins
were involved. If the subquery produced
for an otherwise very simple count is really
an issue, use query(func.count()) as an
optimization. [ticket:2093]
- some changes to the identity map regarding
rare weakref callbacks during iterations.
The mutex has been removed as it apparently
can cause a reentrant (i.e. in one thread) deadlock,
perhaps when gc collects objects at the point of
iteration in order to gain more memory. It is hoped
that "dictionary changed during iteration" will
be exceedingly rare as iteration methods internally
acquire the full list of objects in a single values()
call. Note 0.6.7 has a more conservative fix here
which still keeps the mutex in place. [ticket:2087]
- A tweak to the unit of work causes it to order
the flush along relationship() dependencies even if
the given objects don't have any inter-attribute
references in memory, which was the behavior in
0.5 and earlier, so a flush of Parent/Child with
only foreign key/primary key set will succeed.
This while still maintaining 0.6 and above's not
generating a ton of useless internal dependency
structures within the flush that don't correspond
to state actually within the current flush.
[ticket:2082]
- Improvements to the error messages emitted when
querying against column-only entities in conjunction
with (typically incorrectly) using loader options,
where the parent entity is not fully present.
[ticket:2069]
- Fixed bug in query.options() whereby a path
applied to a lazyload using string keys could
overlap a same named attribute on the wrong
entity. Note 0.6.7 has a more conservative fix
to this. [ticket:2098]
- declarative
- Arguments in __mapper_args__ that aren't "hashable"
aren't mistaken for always-hashable, possibly-column
arguments. [ticket:2091] (also in 0.6.7)
- sql
- Added a fully descriptive error message for the
case where Column is subclassed and _make_proxy()
fails to make a copy due to TypeError on the
constructor. The method _constructor should
be implemented in this case.
- Added new event "column_reflect" for Table objects.
Receives the info dictionary about a Column before
the object is generated within reflection, and allows
modification to the dictionary for control over
most aspects of the resulting Column including
key, name, type, info dictionary. [ticket:2095]
- To help with the "column_reflect" event being used
with specific Table objects instead of all instances
of Table, listeners can be added to a Table object
inline with its construction using a new argument
"listeners", a list of tuples of the form
(<eventname>, <fn>), which are applied to the Table
before the reflection process begins.
- Added new generic function "next_value()", accepts
a Sequence object as its argument and renders the
appropriate "next value" generation string on the
target platform, if supported. Also provides
".next_value()" method on Sequence itself.
[ticket:2085]
- func.next_value() or other SQL expression can
be embedded directly into an insert() construct,
and if implicit or explicit "returning" is used
in conjunction with a primary key column,
the newly generated value will be present in
result.inserted_primary_key. [ticket:2084]
- Added accessors to ResultProxy "returns_rows",
"is_insert" [ticket:2089] (also in 0.6.7)
- engine
- Fixed AssertionPool regression bug. [ticket:2097]
- Changed exception raised to ArgumentError when an
invalid dialect is specified. [ticket:2060]
- postgresql
- Added RESERVED_WORDS for postgresql dialect. [ticket:2092]
(also in 0.6.7)
- Fixed the BIT type to allow a "length" parameter, "varying"
parameter. Reflection also fixed. [ticket:2073]
(also in 0.6.7)
- mssql
- Rewrote the query used to get the definition of a view,
typically when using the Inspector interface, to
use sys.sql_modules instead of the information schema,
thereby allowing views definitions longer than 4000
characters to be fully returned. [ticket:2071]
(also in 0.6.7)
- firebird
- The "implicit_returning" flag on create_engine() is
honored if set to False. [ticket:2083] (also in 0.6.7)
- informix
- Added RESERVED_WORDS informix dialect. [ticket:2092]
(also in 0.6.7)
- ext
- The horizontal_shard ShardedSession class accepts the common
Session argument "query_cls" as a constructor argument,
to enable further subclassing of ShardedQuery.
[ticket:2090] (also in 0.6.7)
- examples
- Updated the association, association proxy examples
to use declarative, added a new example
dict_of_sets_with_default.py, a "pushing the envelope"
example of association proxy.
- The Beaker caching example allows a "query_cls" argument
to the query_callable() function. [ticket:2090]
(also in 0.6.7)
0.7.0b2
========
- orm
- Fixed bug whereby Session.merge() would call the
load() event with one too few arguments.
[ticket:2053]
- Added logic which prevents the generation of
events from a MapperExtension or SessionExtension
from generating do-nothing events for all the methods
not overridden. [ticket:2052]
- declarative
- Fixed regression whereby composite() with
Column objects placed inline would fail
to initialize. The Column objects can now
be inline with the composite() or external
and pulled in via name or object ref.
[ticket:2058]
- Fix error message referencing old @classproperty
name to reference @declared_attr [ticket:2061]
(also in 0.6.7)
- the dictionary at the end of the __table_args__
tuple is now optional. [ticket:1468]
- sql
- Renamed the EngineEvents event class to
ConnectionEvents. As these classes are never
accessed directly by end-user code, this strictly
is a documentation change for end users. Also
simplified how events get linked to engines
and connections internally. [ticket:2059]
- The Sequence() construct, when passed a MetaData()
object via its 'metadata' argument, will be
included in CREATE/DROP statements within
metadata.create_all() and metadata.drop_all(),
including "checkfirst" logic. [ticket:2055]
- The Column.references() method now returns True
if it has a foreign key referencing the
given column exactly, not just it's parent
table. [ticket:2064]
- postgresql
- Fixed regression from 0.6 where SMALLINT and
BIGINT types would both generate SERIAL
on an integer PK column, instead of
SMALLINT and BIGSERIAL [ticket:2065]
- ext
- Association proxy now has correct behavior for
any(), has(), and contains() when proxying
a many-to-one scalar attribute to a one-to-many
collection (i.e. the reverse of the 'typical'
association proxy use case) [ticket:2054]
- examples
- Beaker example now takes into account 'limit'
and 'offset', bind params within embedded
FROM clauses (like when you use union() or
from_self()) when generating a cache key.
0.7.0b1
=======
- Detailed descriptions of each change below are
described at:
http://www.sqlalchemy.org/trac/wiki/07Migration
- general
- New event system, supercedes all extensions, listeners,
etc. [ticket:1902]
- Logging enhancements
[ticket:1926]
- Setup no longer installs a Nose plugin
[ticket:1949]
- The "sqlalchemy.exceptions" alias in sys.modules
has been removed. Base SQLA exceptions are
available via "from sqlalchemy import exc".
The "exceptions" alias for "exc" remains in
"sqlalchemy" for now, it's just not patched into
sys.modules.
- orm
- More succinct form of query.join(target, onclause)
[ticket:1923]
- Hybrid Attributes, implements/supercedes synonym()
[ticket:1903]
- Rewrite of composites [ticket:2008]
- Mutation Event Extension, supercedes "mutable=True"
- PickleType and ARRAY mutability turned off by default
[ticket:1980]
- Simplified polymorphic_on assignment
[ticket:1895]
- Flushing of Orphans that have no parent is allowed
[ticket:1912]
- Adjusted flush accounting step to occur before
the commit in the case of autocommit=True. This allows
autocommit=True to work appropriately with
expire_on_commit=True, and also allows post-flush session
hooks to operate in the same transactional context
as when autocommit=False. [ticket:2041]
- Warnings generated when collection members, scalar referents
not part of the flush
[ticket:1973]
- Non-`Table`-derived constructs can be mapped
[ticket:1876]
- Tuple label names in Query Improved
[ticket:1942]
- Mapped column attributes reference the most specific
column first
[ticket:1892]
- Mapping to joins with two or more same-named columns
requires explicit declaration
[ticket:1896]
- Mapper requires that polymorphic_on column be present
in the mapped selectable
[ticket:1875]
- compile_mappers() renamed configure_mappers(), simplified
configuration internals
[ticket:1966]
- the aliased() function, if passed a SQL FromClause element
(i.e. not a mapped class), will return element.alias()
instead of raising an error on AliasedClass. [ticket:2018]
- Session.merge() will check the version id of the incoming
state against that of the database, assuming the mapping
uses version ids and incoming state has a version_id
assigned, and raise StaleDataError if they don't
match. [ticket:2027]
- Session.connection(), Session.execute() accept 'bind',
to allow execute/connection operations to participate
in the open transaction of an engine explicitly.
[ticket:1996]
- Query.join(), Query.outerjoin(), eagerload(),
eagerload_all(), others no longer allow lists
of attributes as arguments (i.e. option([x, y, z])
form, deprecated since 0.5)
- ScopedSession.mapper is removed (deprecated since 0.5).
- Horizontal shard query places 'shard_id' in
context.attributes where it's accessible by the
"load()" event. [ticket:2031]
- A single contains_eager() call across
multiple entities will indicate all collections
along that path should load, instead of requiring
distinct contains_eager() calls for each endpoint
(which was never correctly documented).
[ticket:2032]
- The "name" field used in orm.aliased() now renders
in the resulting SQL statement.
- Session weak_instance_dict=False is deprecated.
[ticket:1473]
- An exception is raised in the unusual case that an
append or similar event on a collection occurs after
the parent object has been dereferenced, which
prevents the parent from being marked as "dirty"
in the session. Was a warning in 0.6.6.
[ticket:2046]
- Query.distinct() now accepts column expressions
as *args, interpreted by the Postgresql dialect
as DISTINCT ON (<expr>). [ticket:1069]
- Additional tuning to "many-to-one" relationship
loads during a flush(). A change in version 0.6.6
([ticket:2002]) required that more "unnecessary" m2o
loads during a flush could occur. Extra loading modes have
been added so that the SQL emitted in this
specific use case is trimmed back, while still
retrieving the information the flush needs in order
to not miss anything. [ticket:2049]
- the value of "passive" as passed to
attributes.get_history() should be one of the
constants defined in the attributes package. Sending
True or False is deprecated.
- Added a `name` argument to `Query.subquery()`, to allow
a fixed name to be assigned to the alias object.
[ticket:2030] (also in 0.6.7)
- A warning is emitted when a joined-table inheriting mapper
has no primary keys on the locally mapped table
(but has pks on the superclass table). [ticket:2019]
(also in 0.6.7)
- Fixed bug where "middle" class in a polymorphic hierarchy
would have no 'polymorphic_on' column if it didn't also
specify a 'polymorphic_identity', leading to strange
errors upon refresh, wrong class loaded when querying
from that target. Also emits the correct WHERE criterion
when using single table inheritance. [ticket:2038]
(also in 0.6.7)
- Fixed bug where a column with a SQL or server side default
that was excluded from a mapping with include_properties
or exclude_properties would result in UnmappedColumnError.
[ticket:1995] (also in 0.6.7)
- A warning is emitted in the unusual case that an
append or similar event on a collection occurs after
the parent object has been dereferenced, which
prevents the parent from being marked as "dirty"
in the session. This will be an exception in 0.7.
[ticket:2046] (also in 0.6.7)
- declarative
- Added an explicit check for the case that the name
'metadata' is used for a column attribute on a
declarative class. [ticket:2050] (also in 0.6.7)
- sql
- Added over() function, method to FunctionElement
classes, produces the _Over() construct which
in turn generates "window functions", i.e.
"<window function> OVER (PARTITION BY <partition by>,
ORDER BY <order by>)".
[ticket:1844]
- LIMIT/OFFSET clauses now use bind parameters
[ticket:805]
- select.distinct() now accepts column expressions
as *args, interpreted by the Postgresql dialect
as DISTINCT ON (<expr>). Note this was already
available via passing a list to the `distinct`
keyword argument to select(). [ticket:1069]
- select.prefix_with() accepts multiple expressions
(i.e. *expr), 'prefix' keyword argument to select()
accepts a list or tuple.
- Passing a string to the `distinct` keyword argument
of `select()` for the purpose of emitting special
MySQL keywords (DISTINCTROW etc.) is deprecated -
use `prefix_with()` for this.
- TypeDecorator works with primary key columns
[ticket:2005] [ticket:2006]
- DDL() constructs now escape percent signs
[ticket:1897]
- Table.c / MetaData.tables refined a bit, don't allow direct
mutation [ticket:1893] [ticket:1917]
- Callables passed to `bindparam()` don't get evaluated
[ticket:1950]
- types.type_map is now private, types._type_map
[ticket:1870]
- Non-public Pool methods underscored
[ticket:1982]
- Added NULLS FIRST and NULLS LAST support. It's implemented
as an extension to the asc() and desc() operators, called
nullsfirst() and nullslast(). [ticket:723]
- The Index() construct can be created inline with a Table
definition, using strings as column names, as an alternative
to the creation of the index outside of the Table.
- execution_options() on Connection accepts
"isolation_level" argument, sets transaction isolation
level for that connection only until returned to the
connection pool, for thsoe backends which support it
(SQLite, Postgresql) [ticket:2001]
- A TypeDecorator of Integer can be used with a primary key
column, and the "autoincrement" feature of various dialects
as well as the "sqlite_autoincrement" flag will honor
the underlying database type as being Integer-based.
[ticket:2005]
- Established consistency when server_default is present
on an Integer PK column. SQLA doesn't pre-fetch these,
nor do they come back in cursor.lastrowid (DBAPI).
Ensured all backends consistently return None
in result.inserted_primary_key for these. Regarding
reflection for this case, reflection of an int PK col
with a server_default sets the "autoincrement" flag to False,
except in the case of a PG SERIAL col where we detected a
sequence default. [ticket:2020] [ticket:2021]
- Result-row processors are applied to pre-executed SQL
defaults, as well as cursor.lastrowid, when determining
the contents of result.inserted_primary_key.
[ticket:2006]
- Bind parameters present in the "columns clause" of a select
are now auto-labeled like other "anonymous" clauses,
which among other things allows their "type" to be meaningful
when the row is fetched, as in result row processors.
- TypeDecorator is present in the "sqlalchemy" import space.
- Non-DBAPI errors which occur in the scope of an `execute()`
call are now wrapped in sqlalchemy.exc.StatementError,
and the text of the SQL statement and repr() of params
is included. This makes it easier to identify statement
executions which fail before the DBAPI becomes
involved. [ticket:2015]
- The concept of associating a ".bind" directly with a
ClauseElement has been explicitly moved to Executable,
i.e. the mixin that describes ClauseElements which represent
engine-executable constructs. This change is an improvement
to internal organization and is unlikely to affect any
real-world usage. [ticket:2048]
- Column.copy(), as used in table.tometadata(), copies the
'doc' attribute. [ticket:2028] (also in 0.6.7)
- Added some defs to the resultproxy.c extension so that
the extension compiles and runs on Python 2.4.
[ticket:2023] (also in 0.6.7)
- The compiler extension now supports overriding the default
compilation of expression._BindParamClause including that
the auto-generated binds within the VALUES/SET clause
of an insert()/update() statement will also use the new
compilation rules. [ticket:2042] (also in 0.6.7)
-sqlite
- SQLite dialect now uses `NullPool` for file-based databases
[ticket:1921]
- The path given as the location of a sqlite database is now
normalized via os.path.abspath(), so that directory changes
within the process don't affect the ultimate location
of a relative file path. [ticket:2036]
- postgresql
- When explicit sequence execution derives the name
of the auto-generated sequence of a SERIAL column,
which currently only occurs if implicit_returning=False,
now accommodates if the table + column name is greater
than 63 characters using the same logic Postgresql uses.
[ticket:1083] (also in 0.6.7)
- Added an additional libpq message to the list of "disconnect"
exceptions, "could not receive data from server"
[ticket:2044] (also in 0.6.7)
- mssql
- the String/Unicode types, and their counterparts VARCHAR/
NVARCHAR, emit "max" as the length when no length is
specified, so that the default length, normally '1'
as per SQL server documentation, is instead
'unbounded'. This also occurs for the VARBINARY type.
[ticket:1833].
This behavior makes these types more closely compatible
with Postgresql's VARCHAR type which is similarly unbounded
when no length is specified.
- mysql
- New DBAPI support for pymysql, a pure Python port
of MySQL-python. [ticket:1991]
- oursql dialect accepts the same "ssl" arguments in
create_engine() as that of MySQLdb. [ticket:2047]
(also in 0.6.7)
- firebird
- Some adjustments so that Interbase is supported as well.
FB/Interbase version idents are parsed into a structure
such as (8, 1, 1, 'interbase') or (2, 1, 588, 'firebird')
so they can be distinguished. [ticket:1885]
- drizzle
- New dialect for Drizzle, a MySQL variant. Uses MySQL-python
for the DBAPI. [ticket:2003]
0.6.7 - 0.6.xx
==============
Changes which apply to 0.6.7 and subsequent versions of 0.6
are listed in the CHANGES file within the 0.6 branch. All
those changes which are also in the 0.7 series (which is typically
all of them) are listed inline within the 0.7 changes above,
those which apply to an 0.6 release are noted.
0.6.6
=====
- orm
- Fixed bug whereby a non-"mutable" attribute modified event
which occurred on an object that was clean except for
preceding mutable attribute changes would fail to strongly
reference itself in the identity map. This would cause the
object to be garbage collected, losing track of any changes
that weren't previously saved in the "mutable changes"
dictionary.
- Fixed bug whereby "passive_deletes='all'" wasn't passing
the correct symbols to lazy loaders during flush, thereby
causing an unwarranted load. [ticket:2013]
- Fixed bug which prevented composite mapped
attributes from being used on a mapped select statement.
[ticket:1997]. Note the workings of composite are slated to
change significantly in 0.7.
- active_history flag also added to composite().
The flag has no effect in 0.6, but is instead
a placeholder flag for forwards compatibility,
as it applies in 0.7 for composites.
[ticket:1976]
- Fixed uow bug whereby expired objects passed to
Session.delete() would not have unloaded references
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
the same. [ticket:1987]
- "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
a referenced child row to be correctly returned
in results. [ticket:1954]
- Fixed bug regarding "subqueryload" strategy whereby
strategy would fail if the entity was an aliased()
construct. [ticket:1964]
- Fixed bug regarding "subqueryload" strategy whereby
the join would fail if using a multi-level load
of the form from A->joined-subclass->C [ticket:2014]
- Fixed indexing of Query objects by -1. It was erroneously
transformed to the empty slice -1:0 that resulted in
IndexError. [ticket:1968]
- 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.
- Added active_history flag to relationship()
and column_property(), forces attribute events to
always load the "old" value, so that it's available to
attributes.get_history(). [ticket:1961]
- Query.get() will raise if the number of params
in a composite key is too large, as well as too
small. [ticket:1977]
- Backport of "optimized get" fix from 0.7,
improves the generation of joined-inheritance
"load expired row" behavior. [ticket:1992]
- A little more verbiage to the "primaryjoin" error,
in an unusual condition that the join condition
"works" for viewonly but doesn't work for non-viewonly,
and foreign_keys wasn't used - adds "foreign_keys" to
the suggestion. Also add "foreign_keys" to the
suggestion for the generic "direction" error.
- sql
- Fixed operator precedence rules for multiple
chains of a single non-associative operator.
I.e. "x - (y - z)" will compile as "x - (y - z)"
and not "x - y - z". Also works with labels,
i.e. "x - (y - z).label('foo')"
[ticket:1984]
- 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
str() on values.
- CheckConstraint will copy its 'initially', 'deferrable',
and '_create_rule' attributes within a copy()/tometadata()
[ticket:2000]
- engine
- 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
or String type.
- Fixed memory leak in C version of Decimal result
processor. [ticket:1978]
- Implemented sequence check capability for the C
version of RowProxy, as well as 2.7 style
"collections.Sequence" registration for RowProxy.
[ticket:1871]
- 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]
- Threadlocal engine returns itself upon begin(),
begin_nested(); engine then implements contextmanager
methods to allow the "with" statement. [ticket:2004]
- postgresql
- 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"
base type. [ticket:1955]
- Added as_uuid=True flag to the UUID type, will receive
and return values as Python UUID() objects rather than
strings. Currently, the UUID type is only known to
work with psycopg2. [ticket:1956]
- Fixed bug whereby KeyError would occur with non-ENUM
supported PG versions after a pool dispose+recreate
would occur, [ticket:1989]
- mysql
- Fixed error handling for Jython + zxjdbc, such that
has_table() property works again. Regression from
0.6.3 (we don't have a Jython buildbot, sorry)
[ticket:1960]
- sqlite
- The REFERENCES clause in a CREATE TABLE that includes
a remote schema to another table with the same schema
name now renders the remote name without
the schema clause, as required by SQLite. [ticket:1851]
- On the same theme, the REFERENCES clause in a CREATE TABLE
that includes a remote schema to a *different* schema
than that of the parent table doesn't render at all,
as cross-schema references do not appear to be supported.
- mssql
- The rewrite of index reflection in [ticket:1770] was
unfortunately not tested correctly, and returned incorrect
results. This regression is now fixed.
- oracle
- The cx_oracle "decimal detection" logic, which takes place
for for result set columns with ambiguous numeric characteristics,
now uses the decimal point character determined by the locale/
NLS_LANG setting, using an on-first-connect detection of
this character. cx_oracle 5.0.3 or greater is also required
when using a non-period-decimal-point NLS_LANG setting.
[ticket:1953].
- firebird
- Firebird numeric type now checks for Decimal explicitly,
lets float() pass right through, thereby allowing
special values such as float('inf'). [ticket:2012]
- declarative
- An error is raised if __table_args__ is not in tuple
or dict format, and is not None. [ticket:1972]
- sqlsoup
- Added "map_to()" method to SqlSoup, which is a "master"
method which accepts explicit arguments for each aspect of
the selectable and mapping, including a base class per
mapping. [ticket:1975]
- Mapped selectables used with the map(), with_labels(),
join() methods no longer put the given argument into the
internal "cache" dictionary. Particularly since the
join() and select() objects are created in the method
itself this was pretty much a pure memory leaking behavior.
- examples
- The versioning example now supports detection of changes
in an associated relationship().
0.6.5
=====
- orm
- 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
an offline cache, or otherwise used after
the session isn't available, and straight 'select'
loading, not 'joined' or 'subquery', is desired.
[ticket:1914]
- New Query methods: query.label(name), query.as_scalar(),
return the query's statement as a scalar subquery
with /without label [ticket:1920];
query.with_entities(*ent), replaces the SELECT list of
the query with new entities.
Roughly equivalent to a generative form of query.values()
which accepts mapped entities as well as column
expressions.
- Fixed recursion bug which could occur when moving
an object from one reference to another, with
backrefs involved, where the initiating parent
was a subclass (with its own mapper) of the
previous parent.
- Fixed a regression in 0.6.4 which occurred if you
passed an empty list to "include_properties" on
mapper() [ticket:1918]
- 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
inappropriately [ticket:1925]
- Query.select_from() has been beefed up to help
ensure that a subsequent call to query.join()
will use the select_from() entity, assuming it's
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
now been reworded (this is the "inactive due to a
rollback in a subtransaction" message). In particular,
if the rollback was due to an exception during flush(),
the message states this is the case, and reiterates the
string form of the original exception that occurred
during flush. If the session is closed due to explicit
usage of subtransactions (not very common), the message
just states this is the case.
- The exception raised by Mapper when repeated requests to
its initialization are made after initialization already
failed no longer assumes the "hasattr" case, since
there's other scenarios in which this message gets
emitted, and the message also does not compound onto
itself multiple times - you get the same message for
each attempt at usage. The misnomer "compiles" is being
traded out for "initialize".
- Fixed bug in query.update() where 'evaluate' or 'fetch'
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.
This can occur when user defined code inadvertently
triggers flushes on not-fully-loaded objects.
- lazy loads for relationship attributes now use
the current state, not the "committed" state,
of foreign and primary key attributes
when issuing SQL, if a flush is not in process.
Previously, only the database-committed state would
be used. In particular, this would cause a many-to-one
get()-on-lazyload operation to fail, as autoflush
is not triggered on these loads when the attributes are
determined and the "committed" state may not be
available. [ticket:1910]
- 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
been manually "attached" to the session. Note that this
flag blocks attribute events from taking place when an
object is loaded, so backrefs aren't available until
after a flush. The flag is only intended for very
specific use cases.
- Another new flag on relationship(), cascade_backrefs,
disables the "save-update" cascade when the event was
initiated on the "reverse" side of a bidirectional
relationship. This is a cleaner behavior so that
many-to-ones can be set on a transient object without
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
been clarified that passive_updates=False should really
be on the one-to-many side.
- Placing passive_deletes=True on a many-to-one emits
a warning, since you probably intended to put it on
the one-to-many side.
- 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,
instead of repeatedly.
- 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
some more adjustments to this.
- scoped_session emits a warning when configure() is
called if a Session is already present (checks only the
current thread) [ticket:1924]
- reworked the internals of mapper.cascade_iterator() to
cut down method calls by about 9% in some circumstances.
[ticket:1932]
- sql
- 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 will now place itself as the resulting
type for a binary expression where the type coercion
rules would normally return its impl type - previously,
a copy of the impl type would be returned which would
have the TypeDecorator embedded into it as the "dialect"
impl, this was probably an unintentional way of achieving
the desired effect.
- TypeDecorator.load_dialect_impl() returns "self.impl" by
default, i.e. not the dialect implementation type of
"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.
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
label.
- Table.tometadata() now copies Index objects associated
with the Table as well.
- Table.tometadata() issues a warning if the given Table
is already present in the target MetaData - the existing
Table object is returned.
- An informative error message is raised if a Column
which has not yet been assigned a name, i.e. as in
declarative, is used in a context where it is
exported to the columns collection of an enclosing
select() construct, or if any construct involving
that column is compiled before its name is
assigned.
- as_scalar(), label() can be called on a selectable
which contains a Column that is not yet named.
[ticket:1862]
- Fixed recursion overflow which could occur when operating
with two expressions both of type "NullType", but
not the singleton NULLTYPE instance. [ticket:1907]
- declarative
- @classproperty (soon/now @declared_attr) takes effect for
__mapper_args__, __table_args__, __tablename__ on
a base class that is not a mixin, as well as mixins.
[ticket:1922]
- @classproperty 's official name/location for usage
with declarative is sqlalchemy.ext.declarative.declared_attr.
Same thing, but moving there since it is more of a
"marker" that's specific to declararative,
not just an attribute technique. [ticket:1915]
- Fixed bug whereby columns on a mixin wouldn't propagate
correctly to a single-table, or joined-table,
inheritance scheme where the attribute name is
different than that of the column. [ticket:1930],
[ticket:1931].
- A mixin can now specify a column that overrides
a column of the same name associated with a superclass.
Thanks to Oystein Haaland.
- engine
- 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'.
[ticket:1899]
- postgresql
- Added "as_tuple" flag to ARRAY type, returns results
as tuples instead of lists to allow hashing.
- Fixed bug which prevented "domain" built from a
custom type such as "enum" from being reflected.
[ticket:1933]
- mysql
- Fixed bug involving reflection of CURRENT_TIMESTAMP
default used with ON UPDATE clause, thanks to
Taavi Burns [ticket:1940]
- oracle
- The implicit_retunring argument to create_engine()
is now honored regardless of detected version of
Oracle. Previously, the flag would be forced
to False if server version info was < 10.
[ticket:1878]
- mssql
- 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]
- Rewrote the reflection of indexes to use sys.
catalogs, so that column names of any configuration
(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]
- informix
- *Major* cleanup / modernization of the Informix
dialect for 0.6, courtesy Florian Apolloner.
[ticket:1906]
- tests
- the NoseSQLAlchemyPlugin has been moved to a
new package "sqlalchemy_nose" which installs
along with "sqlalchemy". This so that the "nosetests"
script works as always but also allows the
--with-coverage option to turn on coverage before
SQLAlchemy modules are imported, allowing coverage
to work correctly.
- misc
- 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.
[ticket:1890]
0.6.4
=====
- orm
- The name ConcurrentModificationError has been
changed to StaleDataError, and descriptive
error messages have been revised to reflect
exactly what the issue is. Both names will
remain available for the forseeable future
for schemes that may be specifying
ConcurrentModificationError in an "except:"
clause.
- Added a mutex to the identity map which mutexes
remove operations against iteration methods,
which now pre-buffer before returning an
iterable. This because asyncrhonous gc
can remove items via the gc thread at any time.
[ticket:1891]
- 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,
however.
- 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.
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
objects, such as those within a join(), can be
disambiguated.
- A warning is now emitted if a mapper is created against a
join or other single selectable that includes multiple
columns with the same name in its .c. collection,
and those columns aren't explictly named as part of
the same or separate attributes (or excluded).
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.
[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
selectable, without an error being raised. This
helps for situations where a selectable's effective
primary key is simpler than the number of columns
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
the object would live in the identity map
silently until its attributes were accessed.
The make_transient() function now resets this
flag along with the "key" flag.
- 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
with_polymorphic selectable, instead of silently
ignoring it. Look for this to become an
exception in 0.7.
- Another pass through the series of error messages
emitted when relationship() is configured with
ambiguous arguments. The "foreign_keys"
setting is no longer mentioned, as it is almost
never needed and it is preferable users set up
correct ForeignKey metadata, which is now the
recommendation. If 'foreign_keys'
is used and is incorrect, the message suggests
the attribute is probably unnecessary. Docs
for the attribute are beefed up. This
because all confused relationship() users on the
ML appear to be attempting to use foreign_keys
due to the message, which only confuses them
further since Table metadata is much clearer.
- If the "secondary" table has no ForeignKey metadata
and no foreign_keys is set, even though the
user is passing screwed up information, it is assumed
that primary/secondaryjoin expressions should
consider only and all cols in "secondary" to be
foreign. It's not possible with "secondary" for
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
member of the primary key, will now be more
carefully checked during flush if the change in
value of the foreign key on the "many" side is the
result of a change in the primary key of the "one"
side, or if the "one" is just a different object.
In one case, a cascade-capable DB would have
cascaded the value already and we need to look at
the "new" PK value to do an UPDATE, in the other we
need to continue looking at the "old". We now look
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
now use the "committed" value of the
version_id_col in the WHERE clause and
not the pending changed value. The
version generator is also bypassed if
manual changes are present on the attribute.
[ticket:1857]
- Repaired the usage of merge() when used with
concrete inheriting mappers. Such mappers frequently
have so-called "concrete" attributes, which are
subclass attributes that "disable" propagation from
the parent - these needed to allow a merge()
operation to pass through without effect.
- Specifying a non-column based argument
for column_mapped_collection, including string,
text() etc., will raise an error message that
specifically asks for a column element, no longer
misleads with incorrect information about
text() or literal(). [ticket:1863]
- Similarly, for relationship(), foreign_keys,
remote_side, order_by - all column-based
expressions are enforced - lists of strings
are explicitly disallowed since this is a
very common error
- Dynamic attributes don't support collection
population - added an assertion for when
set_committed_value() is called, as well as
when joinedload() or subqueryload() options
are applied to a dynamic attribute, instead
of failure / silent failure. [ticket:1864]
- Fixed bug whereby generating a Query derived
from one which had the same column repeated
with different label names, typically
in some UNION situations, would fail to
propagate the inner columns completely to
the outer query. [ticket:1852]
- object_session() raises the proper
UnmappedInstanceError when presented with an
unmapped instance. [ticket:1881]
- Applied further memoizations to calculated Mapper
properties, with significant (~90%) runtime mapper.py
call count reduction in heavily polymorphic mapping
configurations.
- mapper _get_col_to_prop private method used
by the versioning example is deprecated;
now use mapper.get_property_by_column() which
will remain the public method for this.
- the versioning example works correctly now
if versioning on a col that was formerly
NULL.
- sql
- 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
present and are pending deprecation in 0.7, but note
these would always raise an error anyway if you were
not an Executable (unless you were an alias(), see
previous note).
- Added basic math expression coercion for
Numeric->Integer,
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
place with the auto-generated name, not one
that is user-defined (an error would be
raised instead), and the truncation scheme
itself is now based on a fragment of an md5
hash of the identifier name, so that multiple
indexes on columns with similar names still
have unique names. [ticket:1855]
- The generated index name also is based on
a "max index name length" attribute which is
separate from the "max identifier length" -
this to appease MySQL who has a max length
of 64 for index names, separate from their
overall max length of 255. [ticket:1412]
- the text() construct, if placed in a column
oriented situation, will at least return NULLTYPE
for its type instead of None, allowing it to
be used a little more freely for ad-hoc column
expressions than before. literal_column()
is still the better choice, however.
- Added full description of parent table/column,
target table/column in error message raised when
ForeignKey can't resolve target.
- Fixed bug whereby replacing composite foreign key
columns in a reflected table would cause an attempt
to remove the reflected constraint from the table
a second time, raising a KeyError. [ticket:1865]
- the _Label construct, i.e. the one that is produced
whenever you say somecol.label(), now counts itself
in its "proxy_set" unioned with that of it's
contained column's proxy set, instead of
directly returning that of the contained column.
This allows column correspondence
operations which depend on the identity of the
_Labels themselves to return the correct result
- fixes ORM bug [ticket:1852].
- engine
- Calling fetchone() or similar on a result that
has already been exhausted, has been closed,
or is not a result-returning result now
raises ResourceClosedError, a subclass of
InvalidRequestError, in all cases, regardless
of backend. Previously, some DBAPIs would
raise ProgrammingError (i.e. pysqlite), others
would return None leading to downstream breakages
(i.e. MySQL-python).
- Fixed bug in Connection whereby if a "disconnect"
event occurred in the "initialize" phase of the
first connection pool connect, an AttributeError
would be raised when the Connection would attempt
to invalidate the DBAPI connection. [ticket:1894]
- Connection, ResultProxy, as well as Session use
ResourceClosedError for all "this
connection/transaction/result is closed" types of
errors.
- Connection.invalidate() can be called more than
once and subsequent calls do nothing.
- declarative
- if @classproperty is used with a regular class-bound
mapper property attribute, it will be called to get the
actual attribute value during initialization. Currently,
there's no advantage to using @classproperty on a column
or relationship attribute of a declarative class that
isn't a mixin - evaluation is at the same time as if
@classproperty weren't used. But here we at least allow
it to function as expected.
- Fixed bug where "Can't add additional column" message
would display the wrong name.
- postgresql
- Fixed the psycopg2 dialect to use its
set_isolation_level() method instead of relying
upon the base "SET SESSION ISOLATION" command,
as psycopg2 resets the isolation level on each new
transaction otherwise.
- mssql
- Fixed "default schema" query to work with
pymssql backend.
- firebird
- Fixed bug whereby a column default would fail to
reflect if the "default" keyword were lower case.
- oracle
- Added ROWID type to the Oracle dialect, for those
cases where an explicit CAST might be needed.
[ticket:1879]
- Oracle reflection of indexes has been tuned so
that indexes which include some or all primary
key columns, but not the same set of columns
as that of the primary key, are reflected.
Indexes which contain the identical columns
as that of the primary key are skipped within
reflection, as the index in that case is assumed
to be the auto-generated primary key index.
Previously, any index with PK columns present
would be skipped. Thanks to Kent Bower
for the patch. [ticket:1867]
- Oracle now reflects the names of primary key
constraints - also thanks to Kent Bower.
[ticket:1868]
- informix
- Applied patches from [ticket:1904] to get
basic Informix functionality up again. We
rely upon end-user testing to ensure that
Informix is working to some degree.
- documentation
- The docs have been reorganized such that the "API
Reference" section is gone - all the docstrings from
there which were public API are moved into the
context of the main doc section that talks about it.
Main docs divided into "SQLAlchemy Core" and
"SQLAlchemy ORM" sections, mapper/relationship docs
have been broken out. Lots of sections rewritten
and/or reorganized.
- examples
- The beaker_caching example has been reorgnized
such that the Session, cache manager,
declarative_base are part of environment, and
custom cache code is portable and now within
"caching_query.py". This allows the example to
be easier to "drop in" to existing projects.
- the history_meta versioning recipe sets "unique=False"
when copying columns, so that the versioning
table handles multiple rows with repeating values.
[ticket:1887]
0.6.3
=====
- orm
- Removed errant many-to-many load in unitofwork
which triggered unnecessarily on expired/unloaded
collections. This load now takes place only if
passive_updates is False and the parent primary
key has changed, or if passive_deletes is False
and a delete of the parent has occurred.
[ticket:1845]
- Column-entities (i.e. query(Foo.id)) copy their
state more fully when queries are derived from
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
present, now raises a checked exception the
same way it does when the clause is not
present. [ticket:1853]
- Improved the check for an "unmapped class",
including the case where the superclass is mapped
but the subclass is not. Any attempts to access
cls._sa_class_manager.mapper now raise
UnmappedClassError(). [ticket:1142]
- 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.
- mysql
- The _extract_error_code() method now works
correctly with each MySQL dialect (
MySQL-python, OurSQL, MySQL-Connector-Python,
PyODBC). Previously,
the reconnect logic would fail for OperationalError
conditions, however since MySQLdb and OurSQL
have their own reconnect feature, there was no
symptom for these drivers here unless one
watched the logs. [ticket:1848]
- oracle
- More tweaks to cx_oracle Decimal handling.
"Ambiguous" numerics with no decimal place
are coerced to int at the connection handler
level. The advantage here is that ints
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
handler, when instructed to return Decimal,
can't take full advantage of "native decimal"
mode and must run isinstance() on every value
to check if its Decimal already. Reopen of
[ticket:1840]
0.6.2
=====
- orm
- Query.join() will check for a call of the
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
for the change is so that multiple "post update"
calls, each affecting different foreign key
columns of the same row, are executed in a single
UPDATE statement, rather than one UPDATE
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.
- Can now call make_transient() on an instance that
is referenced by parent objects via many-to-one,
without the parent's foreign key value getting
temporarily set to None - this was a function
of the "detect primary key switch" flush handler.
It now ignores objects that are no longer
in the "persistent" state, and the parent's
foreign key identifier is left unaffected.
- query.order_by() now accepts False, which cancels
any existing order_by() state on the Query, allowing
subsequent generative methods to be called which do
not support ORDER BY. This is not the same as the
already existing feature of passing None, which
suppresses any existing order_by() settings, including
those configured on the mapper. False will make it
as though order_by() was never called, while
None is an active setting.
- An instance which is moved to "transient", has
an incomplete or missing set of primary key
attributes, and contains expired attributes, will
raise an InvalidRequestError if an expired attribute
is accessed, instead of getting a recursion overflow.
- The make_transient() function is now in the generated
documentation.
- 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.
- sql
- The warning emitted by the Unicode and String types
with convert_unicode=True no longer embeds the actual
value passed. This so that the Python warning
registry does not continue to grow in size, the warning
is emitted once as per the warning filter settings,
and large string values don't pollute the output.
[ticket:1822]
- 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
scenarios.
- 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
making "configurational" column classes that aren't
involved in proxying, etc.
- Column.copy() takes along the "unique" attribute
among others, fixes [ticket:1829] regarding declarative
mixins
- postgresql
- render_literal_value() is overridden which escapes
backslashes, currently applies to the ESCAPE clause
of LIKE and similar expressions.
Ultimately this will have to detect the value of
"standard_conforming_strings" for full behavior.
[ticket:1400]
- 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
honored. [ticket:1836]
- mysql
- 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.
- 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
NO_BACKSLASH_ESCAPES. [ticket:1400]
- oracle:
- Fixed ora-8 compatibility flags such that they
don't cache a stale value from before the first
database connection actually occurs. [ticket:1819]
- Oracle's "native decimal" metadata begins to return
ambiguous typing information about numerics
when columns are embedded in subqueries as well
as when ROWNUM is consulted with subqueries, as we
do for limit/offset. We've added these ambiguous
conditions to the cx_oracle "convert to Decimal()"
handler, so that we receive numerics as Decimal
in more cases instead of as floats. These are
then converted, if requested, into Integer
or Float, or otherwise kept as the lossless
Decimal [ticket:1840].
- mssql
- If server_version_info is outside the usual
range of (8, ), (9, ), (10, ), a warning is emitted
which suggests checking that the FreeTDS version
configuration is using 7.0 or 8.0, not 4.2.
[ticket:1825]
- firebird
- 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]
- declarative
- Added support for @classproperty to provide
any kind of schema/mapping construct from a
declarative mixin, including columns with foreign
keys, relationships, column_property, deferred.
This solves all such issues on declarative mixins.
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
not present in the __table__, and the error message
here now works. [ticket:1821]
- compiler extension
- The 'default' compiler is automatically copied over
when overriding the compilation of a built in
clause construct, so no KeyError is raised if the
user-defined compiler is specific to certain
backends and compilation for a different backend
is invoked. [ticket:1838]
- documentation
- Added documentation for the Inspector. [ticket:1820]
- Fixed @memoized_property and @memoized_instancemethod
decorators so that Sphinx documentation picks up
these attributes and methods, such as
ResultProxy.inserted_primary_key. [ticket:1830]
0.6.1
=====
- orm
- 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]
- fixed __setstate__ method of CollectionAdapter to not
fail during deserialize where parent InstanceState not
yet unserialized. [ticket:1802]
- Added internal warning in case an instance without a
full PK happened to be expired and then was asked
to refresh. [ticket:1797]
- Added more aggressive caching to the mapper's usage of
UPDATE, INSERT, and DELETE expressions. Assuming the
statement has no per-object SQL expressions attached,
the expression objects are cached by the mapper after
the first create, and their compiled form is stored
persistently in a cache dictionary for the duration of
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.
- sql
- expr.in_() now accepts a text() construct as the argument.
Grouping parenthesis are added automatically, i.e. usage
is like `col.in_(text("select id from table"))`.
[ticket:1793]
- Columns of _Binary type (i.e. LargeBinary, BLOB, etc.)
will coerce a "basestring" on the right side into a
_Binary as well so that required DBAPI processing
takes place.
- 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.
[ticket:1801]
- Fixed bug that prevented implicit RETURNING from functioning
properly with composite primary key that contained zeroes.
[ticket:1778]
- Fixed errant space character when generating ADD CONSTRAINT
for a named UNIQUE constraint.
- Fixed "table" argument on constructor of ForeginKeyConstraint
[ticket:1571]
- Fixed bug in connection pool cursor wrapper whereby if a
cursor threw an exception on close(), the logging of the
message would fail. [ticket:1786]
- the _make_proxy() method of ColumnClause and Column now use
self.__class__ to determine the class of object to be returned
instead of hardcoding to ColumnClause/Column, making it slightly
easier to produce specific subclasses of these which work in
alias/subquery situations.
- func.XXX() doesn't inadvertently resolve to non-Function
classes (e.g. fixes func.text()). [ticket:1798]
- engines
- Fixed building the C extensions on Python 2.4. [ticket:1781]
- 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.
- mysql
- func.sysdate() emits "SYSDATE()", i.e. with the ending
parenthesis, on MySQL. [ticket:1794]
- sqlite
- Fixed concatenation of constraints when "PRIMARY KEY"
constraint gets moved to column level due to SQLite
AUTOINCREMENT keyword being rendered. [ticket:1812]
- oracle
- Added a check for cx_oracle versions lower than version 5,
in which case the incompatible "output type handler" won't
be used. This will impact decimal accuracy and some
unicode handling issues. [ticket:1775]
- Fixed use_ansi=False mode, which was producing broken
WHERE clauses in pretty much all cases. [ticket:1790]
- Re-established support for Oracle 8 with cx_oracle,
including that use_ansi is set to False automatically,
NVARCHAR2 and NCLOB are not rendered for Unicode,
"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
in connect strings here since we don't know what encoding
we could use. [ticket:1670]
- FOR UPDATE is emitted in the syntactically correct position
when limit/offset is used, i.e. the ROWNUM subquery.
However, Oracle can't really handle FOR UPDATE with ORDER BY
or with subqueries, so its still not very usable, but at
least SQLA gets the SQL past the Oracle parser.
[ticket:1815]
- firebird
- 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]
- Added 'connection shutdown' to the list of exception strings
which indicate a dropped connection. [ticket:1646]
- sqlsoup
- the SqlSoup constructor accepts a `base` argument which specifies
the base class to use for mapped classes, the default being
`object`. [ticket:1783]
0.6.0
=====
- orm
- Unit of work internals have been rewritten. Units of work
with large numbers of objects interdependent objects
can now be flushed without recursion overflows
as there is no longer reliance upon recursive calls
[ticket:1081]. The number of internal structures now stays
constant for a particular session state, regardless of
how many relationships are present on mappings. The flow
of events now corresponds to a linear list of steps,
generated by the mappers and relationships based on actual
work to be done, filtered through a single topological sort
for correct ordering. Flush actions are assembled using
far fewer steps and less memory. [ticket:1742]
- Along with the UOW rewrite, this also removes an issue
introduced in 0.6beta3 regarding topological cycle detection
for units of work with long dependency cycles. We now use
an algorithm written by Guido (thanks Guido!).
- one-to-many relationships now maintain a list of positive
parent-child associations within the flush, preventing
previous parents marked as deleted from cascading a
delete or NULL foreign key set on those child objects,
despite the end-user not removing the child from the old
association. [ticket:1764]
- A collection lazy load will switch off default
eagerloading on the reverse many-to-one side, since
that loading is by definition unnecessary. [ticket:1495]
- Session.refresh() now does an equivalent expire()
on the given instance first, so that the "refresh-expire"
cascade is propagated. Previously, refresh() was
not affected in any way by the presence of "refresh-expire"
cascade. This is a change in behavior versus that
of 0.6beta2, where the "lockmode" flag passed to refresh()
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.
[ticket:1754]
- id(obj) is no longer used internally within topological.py,
as the sorting functions now require hashable objects
only. [ticket:1756]
- 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.
- Usage of version_id_col on a backend that supports
cursor.rowcount for execute() but not executemany() now works
when a delete is issued (already worked for saves, since those
don't use executemany()). For a backend that doesn't support
cursor.rowcount at all, a warning is emitted the same
as with saves. [ticket:1761]
- The ORM now short-term caches the "compiled" form of
insert() and update() constructs when flushing lists of
objects of all the same class, thereby avoiding redundant
compilation per individual INSERT/UPDATE within an
individual flush() call.
- internal getattr(), setattr(), getcommitted() methods
on ColumnProperty, CompositeProperty, RelationshipProperty
have been underscored (i.e. are private), signature has
changed.
- engines
- The C extension now also works with DBAPIs which use custom
sequences as row (and not only tuples). [ticket:1757]
- sql
- Restored some bind-labeling logic from 0.5 which ensures
that tables with column names that overlap another column
of the form "<tablename>_<columnname>" won't produce
errors if column._label is used as a bind name during
an UPDATE. Test coverage which wasn't present in 0.5
has been added. [ticket:1755]
- 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.
- Added new 'compiled_cache' execution option. A dictionary
where Compiled objects will be cached when the Connection
compiles a clause expression into a dialect- and parameter-
specific Compiled object. It is the user's responsibility to
manage the size of this dictionary, which will have keys
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).
[ticket:1769]
- Table.create() and Table.drop() no longer apply metadata-
level create/drop events. [ticket:1771]
- ext
- 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.
- Further reworked the "mixin" logic in declarative to
additionally allow __mapper_args__ as a @classproperty
on a mixin, such as to dynamically assign polymorphic_identity.
- postgresql
- Postgresql now reflects sequence names associated with
SERIAL columns correctly, after the name of of the sequence
has been changed. Thanks to Kumar McMillan for the patch.
[ticket:1071]
- Repaired missing import in psycopg2._PGNumeric type when
unknown numeric is received.
- psycopg2/pg8000 dialects now aware of REAL[], FLOAT[],
DOUBLE_PRECISION[], NUMERIC[] return types without
raising an exception.
- Postgresql reflects the name of primary key constraints,
if one exists. [ticket:1769]
- oracle
- Now using cx_oracle output converters so that the
DBAPI returns natively the kinds of values we prefer:
- NUMBER values with positive precision + scale convert
to cx_oracle.STRING and then to Decimal. This
allows perfect precision for the Numeric type when
using cx_oracle. [ticket:1759]
- STRING/FIXED_CHAR now convert to unicode natively.
SQLAlchemy's String types then don't need to
apply any kind of conversions.
- firebird
- The functionality of result.rowcount can be disabled on a
per-engine basis by setting 'enable_rowcount=False'
on create_engine(). Normally, cursor.rowcount is called
after any UPDATE or DELETE statement unconditionally,
because the cursor is then closed and Firebird requires
an open cursor in order to get a rowcount. This
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.
- examples
- Updated attribute_shard.py example to use a more robust
method of searching a Query for binary expressions which
compare columns against literal values.
0.6beta3
========
- orm
- Major feature: Added new "subquery" loading capability to
relationship(). This is an eager loading option which
generates a second SELECT for each collection represented
in a query, across all parents at once. The query
re-issues the original end-user query wrapped in a subquery,
applies joins out to the target collection, and loads
all those collections fully in one result, similar to
"joined" eager loading but using all inner joins and not
re-fetching full parent rows repeatedly (as most DBAPIs seem
to do, even if columns are skipped). Subquery loading is
available at mapper config level using "lazy='subquery'" and
at the query options level using "subqueryload(props..)",
"subqueryload_all(props...)". [ticket:1675]
- To accomodate the fact that there are now two kinds of eager
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
"select". The old values of True/
False/None still retain their usual meanings and will remain
as synonyms for the foreseeable future.
- Added with_hint() method to Query() construct. This calls
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
inside.
- Fixed bug in Query whereby the usage of aliased() constructs
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))
wouldn't eagerload anything, but using eagerload("b.c") would
work fine.
- Query gains an add_columns(*columns) method which is a multi-
version of add_column(col). add_column(col) is future
deprecated.
- Query.join() will detect if the end result will be
"FROM A JOIN A", and will raise an error if so.
- Query.join(Cls.propname, from_joinpoint=True) will check more
carefully that "Cls" is compatible with the current joinpoint,
and act the same way as Query.join("propname", from_joinpoint=True)
in that regard.
- sql
- 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.
[ticket:1747]
- postgresql
- The psycopg2 dialect will log NOTICE messages via the
"sqlalchemy.dialects.postgresql" logger name.
[ticket:877]
- the TIME and TIMESTAMP types are now availble from the
postgresql dialect directly, which add the PG-specific
argument 'precision' to both. 'precision' and
'timezone' are correctly reflected for both TIME and
TIMEZONE types. [ticket:997]
- mysql
- No longer guessing that TINYINT(1) should be BOOLEAN
when reflecting - TINYINT(1) is returned. Use Boolean/
BOOLEAN in table definition to get boolean conversion
behavior. [ticket:1752]
- oracle
- The Oracle dialect will issue VARCHAR type definitions
using character counts, i.e. VARCHAR2(50 CHAR), so that
the column is sized in terms of characters and not bytes.
Column reflection of character types will also use
ALL_TAB_COLUMNS.CHAR_LENGTH instead of
ALL_TAB_COLUMNS.DATA_LENGTH. Both of these behaviors take
effect when the server version is 9 or higher - for
version 8, the old behaviors are used. [ticket:1744]
- declarative
- Using a mixin won't break if the mixin implements an
unpredictable __getattribute__(), i.e. Zope interfaces.
[ticket:1746]
- Using @classdecorator and similar on mixins to define
__tablename__, __table_args__, etc. now works if
the method references attributes on the ultimate
subclass. [ticket:1749]
- relationships and columns with foreign keys aren't
allowed on declarative mixins, sorry. [ticket:1751]
- ext
- The sqlalchemy.orm.shard module now becomes an extension,
sqlalchemy.ext.horizontal_shard. The old import
works with a deprecation warning.
0.6beta2
========
- py3k
- Improved the installation/test setup regarding Python 3,
now that Distribute runs on Py3k. distribute_setup.py
is now included. See README.py3k for Python 3 installation/
testing instructions.
- orm
- The official name for the relation() function is now
relationship(), to eliminate confusion over the relational
algebra term. relation() however will remain available
in equal capacity for the foreseeable future. [ticket:1740]
- Added "version_id_generator" argument to Mapper, this is a
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
in with_lockmode(), will also do version check for a
version_id_col-enabled mapping.
- Fixed bug whereby calling query(A).join(A.bs).add_entity(B)
in a joined inheritance scenario would double-add B as a
target and produce an invalid query. [ticket:1188]
- Fixed bug in session.rollback() which involved not removing
formerly "pending" objects from the session before
re-integrating "deleted" objects, typically occured with
natural primary keys. If there was a primary key conflict
between them, the attach of the deleted would fail
internally. The formerly "pending" objects are now expunged
first. [ticket:1674]
- Removed a lot of logging that nobody really cares about,
logging that remains will respond to live changes in the
log level. No significant overhead is added. [ticket:1719]
- 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
is ignored completely.
- 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
a value for the attribute. This prevents unnecessary loads
on existing items. Will still mark the attr as expired
if the destination doesn't have the attr, though, which
fulfills some contracts of deferred cols. [ticket:1681]
- The "allow_null_pks" flag is now called "allow_partial_pks",
defaults to True, acts like it did in 0.5 again. Except,
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
UNIQUE column) will pull the "old" value in from the
database during a change, since if it's in the session
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
relation(). [ticket:1731]
- 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
multiple identities for two or more rows. As a bonus,
one() can now also be called with a query that issued
from_statement() to start with since it no longer modifies
the query. [ticket:1688]
- 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.
[ticket:1727]
- 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
with the same PK.
- Now uses sqlalchemy.orm.exc.DetachedInstanceError when an
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.
- Query.union() retains disambiguating labels within the
returned statement, thus avoiding various SQL composition
errors which can result from column name conflicts.
[ticket:1676]
- Fixed bug in attribute history that inadvertently invoked
__eq__ on mapped instances.
- Some internal streamlining of object loading grants a
small speedup for large results, estimates are around
10-15%. Gave the "state" internals a good solid
cleanup with less complexity, datamembers,
method calls, blank dictionary creates.
- Documentation clarification for query.delete()
[ticket:1689]
- Fixed cascade bug in many-to-one relation() when attribute
was set to None, introduced in r6711 (cascade deleted
items into session during add()).
- Calling query.order_by() or query.distinct() before calling
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.
[ticket:1735]
- 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]
- sql
- join() will now simulate a NATURAL JOIN by default. Meaning,
if the left side is a join, it will attempt to join the right
side to the rightmost side of the left first, and not raise
any exceptions about ambiguous join conditions if successful
even if there are further join targets across the rest of
the left. [ticket:1714]
- 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
to their needs instead of implementing custom ones.
- SchemaType and subclasses Boolean, Enum are now serializable,
including their ddl listener and other event callables.
[ticket:1694] [ticket:1698]
- Some platforms will now interpret certain literal values
as non-bind parameters, rendered literally into the SQL
statement. This to support strict SQL-92 rules that are
enforced by some platforms including MS-SQL and Sybase.
In this model, bind parameters aren't allowed in the
columns clause of a SELECT, nor are certain ambiguous
expressions like "?=?". When this mode is enabled, the base
compiler will render the binds as inline literals, but only across
strings and numeric values. Other types such as dates
will raise an error, unless the dialect subclass defines
a literal rendering function for those. The bind parameter
must have an embedded literal value already or an error
is raised (i.e. won't work with straight bindparam('x')).
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
requires that `convert_unicode` is set to `"force"` - otherwise,
SQLAlchemy is not guaranteed to handle the task of unicode
conversion. Note that this flag adds significant performance
overhead to row-fetching operations for backends that already
return unicode objects natively (which most DBAPIs do). This
flag should only be used as an absolute last resort for reading
strings from a column with varied or corrupted encodings,
which only applies to databases that accept invalid encodings
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
class-level variable.
- 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
a SQL operator, based on the full left/right/operator
of the given expression. In particular
the date/time/interval system created for Postgresql
EXTRACT in [ticket:1647] has now been generalized into
the type system. The previous behavior which often
occured of an expression "column + literal" forcing
the type of "literal" to be the same as that of "column"
will now usually not occur - the type of
"literal" is first derived from the Python type of the
literal, assuming standard native Python types + date
types, before falling back to that of the known type
on the other side of the expression. If the
"fallback" type is compatible (i.e. CHAR from String),
the literal side will use that. TypeDecorator
types override this by default to coerce the "literal"
side unconditionally, which can be changed by implementing
the coerce_compared_value() method. Also part of
[ticket:1683].
- Made sqlalchemy.sql.expressions.Executable part of public
API, used for any expression construct that can be sent to
execute(). FunctionElement now inherits Executable so that
it gains execution_options(), which are also propagated
to the select() that's generated within execute().
Executable in turn subclasses _Generative which marks
any ClauseElement that supports the @_generative
decorator - these may also become "public" for the benefit
of the compiler extension at some point.
- A change to the solution for [ticket:1579] - an end-user
defined bind parameter name that directly conflicts with
a column-named bind generated directly from the SET or
VALUES clause of an update/insert generates a compile error.
This reduces call counts and eliminates some cases where
undesirable name conflicts could still occur.
- 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
on SQLite, MySQL. [ticket:1717]
- the copy() method of Column now copies over uninitialized
"on table attach" events. Helps with the new declarative
"mixin" capability.
- engines
- Added an optional C extension to speed up the sql layer by
reimplementing RowProxy and the most common result processors.
The actual speedups will depend heavily on your DBAPI and
the mix of datatypes used in your tables, and can vary from
a 30% improvement to more than 200%. It also provides a modest
(~15-20%) indirect improvement to ORM speed for large queries.
Note that it is *not* built/installed by default.
See README for installation instructions.
- the execution sequence pulls all rowcount/last inserted ID
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
amount of method call overhead. It's negligible and will make
life a lot easier for all those situations when logging
just happens to be configured after create_engine() is called.
[ticket:1719]
- 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
is explicitly passed a bytestring. The String type will do nothing
for DBAPIs that already accept Python unicode objects.
- Bind parameters are sent as a tuple instead of a list. Some
backend drivers will not accept bind parameters as a list.
- threadlocal engine wasn't properly closing the connection
upon close() - fixed that.
- Transaction object doesn't rollback or commit if it isn't
"active", allows more accurate nesting of begin/rollback/commit.
- Python unicode objects as binds result in the Unicode type,
not string, thus eliminating a certain class of unicode errors
on drivers that don't support unicode binds.
- Added "logging_name" argument to create_engine(), Pool() constructor
as well as "pool_logging_name" argument to create_engine() which
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
for dialects.
- 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.
[ticket:1728]
- metadata
- Added the ability to strip schema information when using
"tometadata" by passing "schema=None" as an argument. If schema
is not specified then the table's schema is retained.
[ticket: 1673]
- declarative
- DeclarativeMeta exclusively uses cls.__dict__ (not dict_)
as the source of class information; _as_declarative exclusively
uses the dict_ passed to it as the source of class information
(which when using DeclarativeMeta is cls.__dict__). This should
in theory make it easier for custom metaclasses to modify
the state passed into _as_declarative.
- 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.
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
on this. [ticket:1707]
- 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
propagates the things you want from the parent mapper.
[ticket:1393]
- An exception is raised when a single-table subclass specifies
a column that is already present on the base class.
[ticket:1732]
- mysql
- Fixed reflection bug whereby when COLLATE was present,
nullable flag and server defaults would not be reflected.
[ticket:1655]
- Fixed reflection of TINYINT(1) "boolean" columns defined with
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]
- mssql
- 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.
- oracle
- "out" parameters require a type that is supported by
cx_oracle. An error will be raised if no cx_oracle
type can be found.
- Oracle 'DATE' now does not perform any result processing,
as the DATE type in Oracle stores full date+time objects,
that's what you'll get. Note that the generic types.Date
type *will* still call value.date() on incoming values,
however. When reflecting a table, the reflected type
will be 'DATE'.
- Added preliminary support for Oracle's WITH_UNICODE
mode. At the very least this establishes initial
support for cx_Oracle with Python 3. When WITH_UNICODE
mode is used in Python 2.xx, a large and scary warning
is emitted asking that the user seriously consider
the usage of this difficult mode of operation.
[ticket:1670]
- The except_() method now renders as MINUS on Oracle,
which is more or less equivalent on that platform.
[ticket:1712]
- Added support for rendering and reflecting
TIMESTAMP WITH TIME ZONE, i.e. TIMESTAMP(timezone=True).
[ticket:651]
- Oracle INTERVAL type can now be reflected.
- sqlite
- Added "native_datetime=True" flag to create_engine().
This will cause the DATE and TIMESTAMP types to skip
all bind parameter and result row processing, under
the assumption that PARSE_DECLTYPES has been enabled
on the connection. Note that this is not entirely
compatible with the "func.current_date()", which
will be returned as a string. [ticket:1685]
- sybase
- Implemented a preliminary working dialect for Sybase,
with sub-implementations for Python-Sybase as well
as Pyodbc. Handles table
creates/drops and basic round trip functionality.
Does not yet include reflection or comprehensive
support of unicode/special expressions/etc.
- examples
- Changed the beaker cache example a bit to have a separate
RelationCache option for lazyload caching. This object
does a lookup among any number of potential attributes
more efficiently by grouping several into a common structure.
Both FromCache and RelationCache are simpler individually.
- documentation
- Major cleanup work in the docs to link class, function, and
method names into the API docs. [ticket:1700/1702/1703]
0.6beta1
========
- Major Release
- For the full set of feature descriptions, see
http://www.sqlalchemy.org/trac/wiki/06Migration .
This document is a work in progress.
- All bug fixes and feature enhancements from the most
recent 0.5 version and below are also included within 0.6.
- Platforms targeted now include Python 2.4/2.5/2.6, Python
3.1, Jython2.5.
- orm
- Changes to query.update() and query.delete():
- the 'expire' option on query.update() has been renamed to
'fetch', thus matching that of query.delete().
'expire' is deprecated and issues a warning.
- query.update() and query.delete() both default to
'evaluate' for the synchronize strategy.
- the 'synchronize' strategy for update() and delete()
raises an error on failure. There is no implicit fallback
onto "fetch". Failure of evaluation is based on the
structure of criteria, so success/failure is deterministic
based on code structure.
- Enhancements on many-to-one relations:
- many-to-one relations now fire off a lazyload in fewer
cases, including in most cases will not fetch the "old"
value when a new one is replaced.
- many-to-one relation to a joined-table subclass now uses
get() for a simple load (known as the "use_get"
condition), i.e. Related->Sub(Base), without the need to
redefine the primaryjoin condition in terms of the base
table. [ticket:1186]
- specifying a foreign key with a declarative column, i.e.
ForeignKey(MyRelatedClass.id) doesn't break the "use_get"
condition from taking place [ticket:1492]
- relation(), eagerload(), and eagerload_all() now feature
an option called "innerjoin". Specify `True` or `False` to
control whether an eager join is constructed as an INNER
or OUTER join. Default is `False` as always. The mapper
options will override whichever setting is specified on
relation(). Should generally be set for many-to-one, not
nullable foreign key relations to allow improved join
performance. [ticket:1544]
- the behavior of eagerloading such that the main query is
wrapped in a subquery when LIMIT/OFFSET are present now
makes an exception for the case when all eager loads are
many-to-one joins. In those cases, the eager joins are
against the parent table directly along with the
limit/offset without the extra overhead of a subquery,
since a many-to-one join does not add rows to the result.
- Enhancements / Changes on Session.merge():
- the "dont_load=True" flag on Session.merge() is deprecated
and is now "load=False".
- 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
for "load=True" mode.
- 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.
- 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"
attribute of the relation(), and also allows it to be used
in filter criterion against the dynamic relation.
[ticket:1531]
- relation() with uselist=False will emit a warning when
an eager or lazy load locates more than one valid value for
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.select_from() accepts multiple clauses to produce
multiple comma separated entries within the FROM clause.
Useful when selecting from multiple-homed join() clauses.
- query.select_from() also accepts mapped classes, aliased()
constructs, and mappers as arguments. In particular this
helps when querying from multiple joined-table classes to ensure
the full join gets rendered.
- query.get() can be used with a mapping to an outer join
where one or more of the primary key values are None.
[ticket:1135]
- 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
to the columns clause of the outer query. This is
potentially backwards incompatible with 0.5, in that this
may break queries with literal expressions that do not have labels
applied (i.e. literal('foo'), etc.)
[ticket:1568]
- 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.
[ticket:1622]
- `expression.null()` is fully understood the same way
None is when comparing an object/collection-referencing
attribute within query.filter(), filter_by(), etc.
[ticket:1415]
- added "make_transient()" helper function which transforms a
persistent/ detached instance into a transient one (i.e.
deletes the instance_key and removes from any session.)
[ticket:1052]
- the allow_null_pks flag on mapper() is deprecated, and
the feature is turned "on" by default. This means that
a row which has a non-null value for any of its primary key
columns will be considered an identity. The need for this
scenario typically only occurs when mapping to an outer join.
[ticket:1339]
- the mechanics of "backref" have been fully merged into the
finer grained "back_populates" system, and take place entirely
within the _generate_backref() method of RelationProperty. This
makes the initialization procedure of RelationProperty
simpler and allows easier propagation of settings (such as from
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.
[ticket:1569]
- added "execution_options()" to Query, to so options can be
passed to the resulting statement. Currently only
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
option automatically.
- Deprecated or removed:
* 'allow_null_pks' flag on mapper() is deprecated. It does
nothing now and the setting is "on" in all cases.
* 'transactional' flag on sessionmaker() and others is
removed. Use 'autocommit=True' to indicate 'transactional=False'.
* 'polymorphic_fetch' argument on mapper() is removed.
Loading can be controlled using the 'with_polymorphic'
option.
* 'select_table' argument on mapper() is removed. Use
'with_polymorphic=("*", <some selectable>)' for this
functionality.
* 'proxy' argument on synonym() is removed. This flag
did nothing throughout 0.5, as the "proxy generation"
behavior is now automatic.
* Passing a single list of elements to eagerload(),
eagerload_all(), contains_eager(), lazyload(),
defer(), and undefer() instead of multiple positional
*args is deprecated.
* Passing a single list of elements to query.order_by(),
query.group_by(), query.join(), or query.outerjoin()
instead of multiple positional *args is deprecated.
* query.iterate_instances() is removed. Use query.instances().
* Query.query_from_parent() is removed. Use the
sqlalchemy.orm.with_parent() function to produce a
"parent" clause, or alternatively query.with_parent().
* query._from_self() is removed, use query.from_self()
instead.
* the "comparator" argument to composite() is removed.
Use "comparator_factory".
* RelationProperty._get_join() is removed.
* the 'echo_uow' flag on Session is removed. Use
logging on the "sqlalchemy.orm.unitofwork" name.
* session.clear() is removed. use session.expunge_all().
* session.save(), session.update(), session.save_or_update()
are removed. Use session.add() and session.add_all().
* the "objects" flag on session.flush() remains deprecated.
* the "dont_load=True" flag on session.merge() is deprecated
in favor of "load=False".
* ScopedSession.mapper remains deprecated. See the
usage recipe at
http://www.sqlalchemy.org/trac/wiki/UsageRecipes/SessionAwareMapper
* passing an InstanceState (internal SQLAlchemy state object) to
attributes.init_collection() or attributes.get_history() is
deprecated. These functions are public API and normally
expect a regular mapped object instance.
* the 'engine' parameter to declarative_base() is removed.
Use the 'bind' keyword argument.
- sql
- the "autocommit" flag on select() and text() as well
as select().autocommit() are deprecated - now call
.execution_options(autocommit=True) on either of those
constructs, also available directly on Connection and orm.Query.
- 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
and behavior of an insert/update statement is very much
determined by the first parameter set, including which
defaults are going to fire off, and a minimum of
guesswork is performed with all the rest so that performance
is not impacted. For this reason defaults would otherwise
silently "fail" for missing parameters, so this is now guarded
against. [ticket:1566]
- returning() support is native to insert(), update(),
delete(). Implementations of varying levels of
functionality exist for Postgresql, Firebird, MSSQL and
Oracle. returning() can be called explicitly with column
expressions which are then returned in the resultset,
usually via fetchone() or first().
insert() constructs will also use RETURNING implicitly to
get newly generated primary key values, if the database
version in use supports it (a version number check is
performed). This occurs if no end-user returning() was
specified.
- union(), intersect(), except() and other "compound" types
of statements have more consistent behavior w.r.t.
parenthesizing. Each compound element embedded within
another will now be grouped with parenthesis - previously,
the first compound element in the list would not be grouped,
as SQLite doesn't like a statement to start with
parenthesis. However, Postgresql in particular has
precedence rules regarding INTERSECT, and it is
more consistent for parenthesis to be applied equally
to all sub-elements. So now, the workaround for SQLite
is also what the workaround for PG was previously -
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
SQL. [ticket:1579]
- 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
IN with multiple columns. The "scalar select can
have only one column" error message is removed - will
rely upon the database to report problems with
col mismatch.
- User-defined "default" and "onupdate" callables which
accept a context should now call upon
"context.current_parameters" to get at the dictionary
of bind parameters currently being processed. This
dict is available in the same way regardless of
single-execute or executemany-style statement execution.
- multi-part schema names, i.e. with dots such as
"dbo.master", are now rendered in select() labels
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
"tablename_id_1" in an attempt to avoid naming
conflicts, when the table has a column actually
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
that the user not issue in_() if the list is empty,
instead simply not querying, or modifying the criterion
as appropriate for more complex situations.
[ticket:1628]
- Added "execution_options()" to select()/text(), which set the
default options for the Connection. See the note in "engines".
- Deprecated or removed:
* "scalar" flag on select() is removed, use
select.as_scalar().
* "shortname" attribute on bindparam() is removed.
* postgres_returning, firebird_returning flags on
insert(), update(), delete() are deprecated, use
the new returning() method.
* fold_equivalents flag on join is deprecated (will remain
until [ticket:1131] is implemented)
- engines
- 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
"stream_results", causes psycopg2 to use a server
side cursor for that statement, as well as
"autocommit", which is the new location for the "autocommit"
option from select() and text(). select() and
text() also have .execution_options() as well as
ORM Query().
- 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 objects are now pickleable, i.e. the object returned
by result.fetchone(), result.fetchall() etc.
- 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
result sets. The improvement is larger when fetching columns
that have no type-level processing applied and when using
results as tuples (instead of as dictionaries). Many
thanks to Elixir's Gaëtan de Menten for this dramatic
improvement ! [ticket:1586]
- Databases which rely upon postfetch of "last inserted id"
to get at a generated sequence value (i.e. MySQL, MS-SQL)
now work correctly when there is a composite primary key
where the "autoincrement" column is not the first primary
key column in the table.
- the last_inserted_ids() method has been renamed to the
descriptor "inserted_primary_key".
- 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(),
etc.
- 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'.
[ticket:1621]
- the "threadlocal" engine has been rewritten and simplified
and now supports SAVEPOINT operations.
- deprecated or removed
* result.last_inserted_ids() is deprecated. Use
result.inserted_primary_key
* dialect.get_default_schema_name(connection) is now
public via dialect.default_schema_name.
* the "connection" argument from engine.transaction() and
engine.run_callable() is removed - Connection itself
now has those methods. All four methods accept
*args and **kwargs which are passed to the given callable,
as well as the operating connection.
- schema
- 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
sorted_tables)
- 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.
- Removed public mutability from Index and Constraint
objects:
- ForeignKeyConstraint.append_element()
- Index.append_column()
- UniqueConstraint.append_column()
- PrimaryKeyConstraint.add()
- PrimaryKeyConstraint.remove()
These should be constructed declaratively (i.e. in one
construction).
- 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.
- Other removed things:
- Table.key (no idea what this was for)
- Table.primary_key is not assignable - use
table.append_constraint(PrimaryKeyConstraint(...))
- Column.bind (get via column.table.bind)
- 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
ALTER for foreign keys.
- ForeignKey and ForeignKeyConstraint objects now correctly
copy() all their public keyword arguments. [ticket:1605]
- Reflection/Inspection
- 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,
indexes, etc.
- 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.
- DDL
- the DDL system has been greatly expanded. the DDL() class
now extends the more generic DDLElement(), which forms the basis
of many new constructs:
- CreateTable()
- DropTable()
- AddConstraint()
- DropConstraint()
- CreateIndex()
- DropIndex()
- CreateSequence()
- DropSequence()
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
MetaData object triggering the event.
"connection" - the Connection object in use for the operation.
**kw - keyword arguments. In the case of MetaData before/after
create/drop, the list of Table objects for which
CREATE/DROP DDL is to be issued is passed as the kw
argument "tables". This is necessary for metadata-level
DDL that is dependent on the presence of specific tables.
- the "schema_item" attribute of DDL has been renamed to
"target".
- dialect refactor
- Dialect modules are now broken into database dialects
plus DBAPI implementations. Connect URLs are now
preferred to be specified using dialect+driver://...,
i.e. "mysql+mysqldb://scott:tiger@localhost/test". See
the 0.6 documentation for examples.
- the setuptools entrypoint for external dialects is now
called "sqlalchemy.dialects".
- the "owner" keyword argument is removed from Table. Use
"schema" to represent any namespaces to be prepended to
the table name.
- server_version_info becomes a static attribute.
- dialects receive an initialize() event on initial
connection to determine connection properties.
- dialects receive a visit_pool event have an opportunity
to establish pool listeners.
- cached TypeEngine classes are cached per-dialect class
instead of per-dialect.
- new UserDefinedType should be used as a base class for
new types, which preserves the 0.5 behavior of
get_col_spec().
- 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
of result values.
- Deprecated Dialect.get_params() removed.
- Dialect.get_rowcount() has been renamed to a descriptor
"rowcount", and calls cursor.rowcount directly. Dialects
which need to hardwire a rowcount in for certain calls
should override the method to provide different behavior.
- DefaultRunner and subclasses have been removed. The job
of this object has been simplified and moved into
ExecutionContext. Dialects which support sequences should
add a `fire_sequence()` method to their execution context
implementation. [ticket:1566]
- Functions and operators generated by the compiler now use
(almost) regular dispatch functions of the form
"visit_<opname>" and "visit_<funcname>_fn" to provide
customed processing. This replaces the need to copy the
"functions" and "operators" dictionaries in compiler
subclasses with straightforward visitor methods, and also
allows compiler subclasses complete control over
rendering, as the full _Function or _BinaryExpression
object is passed in.
- postgresql
- New dialects: pg8000, zxjdbc, and pypostgresql
on py3k.
- The "postgres" dialect is now named "postgresql" !
Connection strings look like:
postgresql://scott:tiger@localhost/test
postgresql+pg8000://scott:tiger@localhost/test
The "postgres" name remains for backwards compatiblity
in the following ways:
- There is a "postgres.py" dummy dialect which
allows old URLs to work, i.e.
postgres://scott:tiger@localhost/test
- The "postgres" name can be imported from the old
"databases" module, i.e. "from
sqlalchemy.databases import postgres" as well as
"dialects", "from sqlalchemy.dialects.postgres
import base as pg", will send a deprecation
warning.
- Special expression arguments are now named
"postgresql_returning" and "postgresql_where", but
the older "postgres_returning" and
"postgres_where" names still work with a
deprecation warning.
- "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
reflection. [ticket:1511]
- INTERVAL supports an optional "precision" argument
corresponding to the argument that PG accepts.
- using new dialect.initialize() feature to set up
version-dependent behavior.
- somewhat better support for % signs in table/column names;
psycopg2 can't handle a bind parameter name of
%(foobar)s however and SQLA doesn't want to add overhead
just to treat that one non-existent use case.
[ticket:1279]
- 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"
sequence. [ticket:1516]
- 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]
- The psycopg2 now respects the statement option
"stream_results". This option overrides the connection setting
"server_side_cursors". If true, server side cursors will be
used for the statement. If false, they will not be used, even
if "server_side_cursors" is true on the
connection. [ticket:1619]
- mysql
- 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
dialect.initialize()
- somewhat better support for % signs in table/column names;
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
binary column.
- 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
objects.
- 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]
- oracle
- unit tests pass 100% with cx_oracle !
- support for cx_Oracle's "native unicode" mode which does
not require NLS_LANG to be set. Use the latest 5.0.2 or
later of 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
uses JOIN/OUTERJOIN.
- 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
parameters. [ticket:885]
- func.char_length is a generic function for LENGTH
- ForeignKey() which includes onupdate=<value> will emit a
warning, not emit ON UPDATE CASCADE which is unsupported
by oracle
- the keys() method of RowProxy() now returns the result
column names *normalized* to be SQLAlchemy case
insensitive names. This means they will be lower case for
case insensitive names, whereas the DBAPI would normally
return them as UPPERCASE names. This allows row keys() to
be compatible with further SQLAlchemy operations.
- using new dialect.initialize() feature to set up
version-dependent behavior.
- using types.BigInteger with Oracle will generate
NUMBER(19) [ticket:1125]
- "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
quoting is maintained.
- firebird
- the keys() method of RowProxy() now returns the result
column names *normalized* to be SQLAlchemy case
insensitive names. This means they will be lower case for
case insensitive names, whereas the DBAPI would normally
return them as UPPERCASE names. This allows row keys() to
be compatible with further SQLAlchemy operations.
- using new dialect.initialize() feature to set up
version-dependent behavior.
- "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
quoting is maintained.
- mssql
- MSSQL + Pyodbc + FreeTDS now works for the most part,
with possible exceptions regarding binary data as well as
unicode schema identifiers.
- the "has_window_funcs" flag is removed. LIMIT/OFFSET
usage will use ROW NUMBER as always, and if on an older
version of SQL Server, the operation fails. The behavior
is exactly the same except the error is raised by SQL
server instead of the dialect, and no flag setting is
required to enable it.
- the "auto_identity_insert" flag is removed. This feature
always takes effect when an INSERT statement overrides a
column that is known to have a sequence on it. As with
"has_window_funcs", if the underlying driver doesn't
support this, then you can't do this operation in any
case, so there's no point in having a flag.
- using new dialect.initialize() feature to set up
version-dependent behavior.
- removed references to sequence which is no longer used.
implicit identities in mssql work the same as implicit
sequences on any other dialects. Explicit sequences are
enabled through the use of "default=Sequence()". See
the MSSQL dialect documentation for more information.
- sqlite
- DATE, TIME and DATETIME types can now take optional storage_format
and regexp argument. storage_format can be used to store those types
using a custom string format. regexp allows to use a custom regular
expression to match string values from the database.
- Time and DateTime types now use by a default a stricter regular
expression to match strings from the database. Use the regexp
argument if you are using data stored in a legacy format.
- __legacy_microseconds__ on SQLite Time and DateTime types is not
supported anymore. You should use the storage_format argument
instead.
- Date, Time and DateTime types are now stricter in what they accept as
bind parameters: Date type only accepts date objects (and datetime
ones, because they inherit from date), Time only accepts time
objects, and DateTime only accepts date and datetime objects.
- Table() supports a keyword argument "sqlite_autoincrement", which
applies the SQLite keyword "AUTOINCREMENT" to the single integer
primary key column when generating DDL. Will prevent generation of
a separate PRIMARY KEY constraint. [ticket:1016]
- new dialects
- postgresql+pg8000
- postgresql+pypostgresql (partial)
- postgresql+zxjdbc
- mysql+pyodbc
- mysql+zxjdbc
- types
- The construction of types within dialects has been totally
overhauled. Dialects now define publically available types
as UPPERCASE names exclusively, and internal implementation
types using underscore identifiers (i.e. are private).
The system by which types are expressed in SQL and DDL
has been moved to the compiler system. This has the
effect that there are much fewer type objects within
most dialects. A detailed document on this architecture
for dialect authors is in
lib/sqlalchemy/dialects/type_migration_guidelines.txt .
- Types no longer make any guesses as to default
parameters. In particular, Numeric, Float, NUMERIC,
FLOAT, DECIMAL don't generate any length or scale unless
specified.
- types.Binary is renamed to types.LargeBinary, it only
produces BLOB, BYTEA, or a similar "long binary" type.
New base BINARY and VARBINARY
types have been added to access these MySQL/MS-SQL specific
types in an agnostic way [ticket:1664].
- String/Text/Unicode types now skip the unicode() check
on each result column value if the dialect has
detected the DBAPI as returning Python unicode objects
natively. This check is issued on first connect
using "SELECT CAST 'some text' AS VARCHAR(10)" or
equivalent, then checking if the returned object
is a Python unicode. This allows vast performance
increases for native-unicode DBAPIs, including
pysqlite/sqlite3, psycopg2, and pg8000.
- Most types result processors have been checked for possible speed
improvements. Specifically, the following generic types have been
optimized, resulting in varying speed improvements:
Unicode, PickleType, Interval, TypeDecorator, Binary.
Also the following dbapi-specific implementations have been improved:
Time, Date and DateTime on Sqlite, ARRAY on Postgresql,
Time on MySQL, Numeric(as_decimal=False) on MySQL, oursql and
pypostgresql, DateTime on cx_oracle and LOB-based types on cx_oracle.
- Reflection of types now returns the exact UPPERCASE
type within types.py, or the UPPERCASE type within
the dialect itself if the type is not a standard SQL
type. This means reflection now returns more accurate
information about reflected types.
- Added a new Enum generic type. Enum is a schema-aware object
to support databases which require specific DDL in order to
use enum or equivalent; in the case of PG it handles the
details of `CREATE TYPE`, and on other databases without
native enum support will by generate VARCHAR + an inline CHECK
constraint to enforce the enum.
[ticket:1109] [ticket:1511]
- The Interval type includes a "native" flag which controls
if native INTERVAL types (postgresql + oracle) are selected
if available, or not. "day_precision" and "second_precision"
arguments are also added which propagate as appropriately
to these native types. Related to [ticket:1467].
- The Boolean type, when used on a backend that doesn't
have native boolean support, will generate a CHECK
constraint "col IN (0, 1)" along with the int/smallint-
based column type. This can be switched off if
desired with create_constraint=False.
Note that MySQL has no native boolean *or* CHECK constraint
support so this feature isn't available on that platform.
[ticket:1589]
- PickleType now uses == for comparison of values when
mutable=True, unless the "comparator" argument with a
comparsion function is specified to the type. Objects
being pickled will be compared based on identity (which
defeats the purpose of mutable=True) if __eq__() is not
overridden or a comparison function is not provided.
- The default "precision" and "scale" arguments of Numeric
and Float have been removed and now default to None.
NUMERIC and FLOAT will be rendered with no numeric
arguments by default unless these values are provided.
- AbstractType.get_search_list() is removed - the games
that was used for are no longer necessary.
- Added a generic BigInteger type, compiles to
BIGINT or NUMBER(19). [ticket:1125]
-ext
- sqlsoup has been overhauled to explicitly support an 0.5 style
session, using autocommit=False, autoflush=True. Default
behavior of SQLSoup now requires the usual usage of commit()
and rollback(), which have been added to its interface. An
explcit Session or scoped_session can be passed to the
constructor, allowing these arguments to be overridden.
- sqlsoup db.<sometable>.update() and delete() now call
query(cls).update() and delete(), respectively.
- sqlsoup now has execute() and connection(), which call upon
the Session methods of those names, ensuring that the bind is
in terms of the SqlSoup object's bind.
- sqlsoup objects no longer have the 'query' attribute - it's
not needed for sqlsoup's usage paradigm and it gets in the
way of a column that is actually named 'query'.
- The signature of the proxy_factory callable passed to
association_proxy is now (lazy_collection, creator,
value_attr, association_proxy), adding a fourth argument
that is the parent AssociationProxy argument. Allows
serializability and subclassing of the built in collections.
[ticket:1259]
- association_proxy now has basic comparator methods .any(),
.has(), .contains(), ==, !=, thanks to Scott Torborg.
[ticket:1372]
- examples
- The "query_cache" examples have been removed, and are replaced
with a fully comprehensive approach that combines the usage of
Beaker with SQLAlchemy. New query options are used to indicate
the caching characteristics of a particular Query, which
can also be invoked deep within an object graph when lazily
loading related objects. See /examples/beaker_caching/README.
For changes prior to 0.6, see CHANGES_PRE_06