8
:released: July 3, 2013
14
Fixed bug when using multi-table UPDATE where a supplemental
15
table is a SELECT with its own bound parameters, where the positioning
16
of the bound parameters would be reversed versus the statement
17
itself when using MySQL's special syntax.
23
Added :class:`.BIGINT` to the list of type names that can be
24
reflected by the SQLite dialect; courtesy Russell Stuart.
27
:tags: feature, orm, declarative
30
ORM descriptors such as hybrid properties can now be referenced
31
by name in a string argument used with ``order_by``,
32
``primaryjoin``, or similar in :func:`.relationship`,
33
in addition to column-bound attributes.
36
:tags: feature, firebird
39
Added new flag ``retaining=True`` to the kinterbasdb and fdb dialects.
40
This controls the value of the ``retaining`` flag sent to the
41
``commit()`` and ``rollback()`` methods of the DBAPI connection.
42
Due to historical concerns, this flag defaults to ``True``, however
43
in 0.9 this flag will be defaulted to ``False``.
48
The Python `mock <https://pypi.python.org/pypi/mock>`_ library
49
is now required in order to run the unit test suite. While part
50
of the standard library as of Python 3.3, previous Python installations
51
will need to install this in order to run unit tests or to
52
use the ``sqlalchemy.testing`` package for external dialects.
58
A warning is emitted when trying to flush an object of an inherited
59
class where the polymorphic discriminator has been assigned
60
to a value that is invalid for the class.
63
:tags: bug, postgresql
66
The behavior of :func:`.extract` has been simplified on the
67
Postgresql dialect to no longer inject a hardcoded ``::timestamp``
68
or similar cast into the given expression, as this interfered
69
with types such as timezone-aware datetimes, but also
70
does not appear to be at all necessary with modern versions
78
Type lookup when reflecting the Firebird types LONG and
79
INT64 has been fixed so that LONG is treated as INTEGER,
80
INT64 treated as BIGINT, unless the type has a "precision"
81
in which case it's treated as NUMERIC. Patch courtesy
85
:tags: bug, postgresql
88
Fixed bug in HSTORE type where keys/values that contained
89
backslashed quotes would not be escaped correctly when
90
using the "non native" (i.e. non-psycopg2) means
91
of translating HSTORE data. Patch courtesy Ryan Kelly.
94
:tags: bug, postgresql
97
Fixed bug where the order of columns in a multi-column
98
Postgresql index would be reflected in the wrong order.
99
Courtesy Roman Podolyaka.
105
Multiple fixes to the correlation behavior of
106
:class:`.Select` constructs, first introduced in 0.8.0:
108
* To satisfy the use case where FROM entries should be
109
correlated outwards to a SELECT that encloses another,
110
which then encloses this one, correlation now works
111
across multiple levels when explicit correlation is
112
established via :meth:`.Select.correlate`, provided
113
that the target select is somewhere along the chain
114
contained by a WHERE/ORDER BY/columns clause, not
115
just nested FROM clauses. This makes
116
:meth:`.Select.correlate` act more compatibly to
117
that of 0.7 again while still maintaining the new
120
* When explicit correlation is not used, the usual
121
"implicit" correlation limits its behavior to just
122
the immediate enclosing SELECT, to maximize compatibility
123
with 0.7 applications, and also prevents correlation
124
across nested FROMs in this case, maintaining compatibility
127
* The :meth:`.Select.correlate_except` method was not
128
preventing the given FROM clauses from correlation in
129
all cases, and also would cause FROM clauses to be incorrectly
130
omitted entirely (more like what 0.7 would do),
133
* Calling `select.correlate_except(None)` will enter
134
all FROM clauses into correlation as would be expected.
139
Fixed bug whereby if a composite type were set up
140
with a function instead of a class, the mutable extension
141
would trip up when it tried to check that column
142
for being a :class:`.MutableComposite` (which it isn't).
149
Provided a new attribute for :class:`.TypeDecorator`
150
called :attr:`.TypeDecorator.coerce_to_is_types`,
151
to make it easier to control how comparisons using
152
``==`` or ``!=`` to ``None`` and boolean types goes
153
about producing an ``IS`` expression, or a plain
154
equality expression with a bound parameter.
157
:tags: feature, postgresql
159
Support for Postgresql 9.2 range types has been added.
160
Currently, no type translation is provided, so works
161
directly with strings or psycopg2 2.5 range extension types
162
at the moment. Patch courtesy Chris Withers.
167
Fixed an issue with the "versioning" recipe whereby a many-to-one
168
reference could produce a meaningless version for the target,
169
even though it was not changed, when backrefs were present.
170
Patch courtesy Matt Chisholm.
173
:tags: feature, postgresql
176
Added support for "AUTOCOMMIT" isolation when using the psycopg2
177
DBAPI. The keyword is available via the ``isolation_level``
178
execution option. Patch courtesy Roman Podolyaka.
184
Fixed bug in polymorphic SQL generation where multiple joined-inheritance
185
entities against the same base class joined to each other as well
186
would not track columns on the base table independently of each other if
187
the string of joins were more than two entities long.
193
Fixed bug where the ``reset_on_return`` argument to various :class:`.Pool`
194
implementations would not be propagated when the pool was regenerated.
201
Fixed bug where sending a composite attribute into :meth:`.Query.order_by`
202
would produce a parenthesized expression not accepted by some databases.
208
Fixed the interaction between composite attributes and
209
the :func:`.aliased` function. Previously, composite attributes
210
wouldn't work correctly in comparison operations when aliasing
217
Added another conditional to the ``mysql+gaerdbms`` dialect to
218
detect so-called "development" mode, where we should use the
219
``rdbms_mysqldb`` DBAPI. Patch courtesy Brett Slatkin.
222
:tags: feature, mysql
225
The ``mysql_length`` parameter used with :class:`.Index` can now
226
be passed as a dictionary of column names/lengths, for use
227
with composite indexes. Big thanks to Roman Podolyaka for the
234
When querying the information schema on SQL Server 2000, removed
235
a CAST call that was added in 0.8.1 to help with driver issues,
236
which apparently is not compatible on 2000.
237
The CAST remains in place for SQL Server 2005 and greater.
243
The ``deferrable`` keyword argument on :class:`.ForeignKey` and
244
:class:`.ForeignKeyConstraint` will not render the ``DEFERRABLE`` keyword
245
on the MySQL dialect. For a long time we left this in place because
246
a non-deferrable foreign key would act very differently than a deferrable
247
one, but some environments just disable FKs on MySQL, so we'll be less
254
Fixed bug where :class:`.MutableDict` didn't report a change event
255
when ``clear()`` was called.
261
Fixed bug whereby joining a select() of a table "A" with multiple
262
foreign key paths to a table "B", to that table "B", would fail
263
to produce the "ambiguous join condition" error that would be
264
reported if you join table "A" directly to "B"; it would instead
265
produce a join condition with multiple criteria.
268
:tags: bug, sql, reflection
271
Fixed bug whereby using :meth:`.MetaData.reflect` across a remote
272
schema as well as a local schema could produce wrong results
273
in the case where both schemas had a table of the same name.
279
Removed the "not implemented" ``__iter__()`` call from the base
280
:class:`.ColumnOperators` class, while this was introduced
281
in 0.8.0 to prevent an endless, memory-growing loop when one also
282
implements a ``__getitem__()`` method on a custom
283
operator and then calls erroneously ``list()`` on that object,
284
it had the effect of causing column elements to report that they
285
were in fact iterable types which then throw an error when you try
286
to iterate. There's no real way to have both sides here so we
287
stick with Python best practices. Careful with implementing
288
``__getitem__()`` on your custom operators!
294
Added a new method :meth:`.Query.select_entity_from` which
295
will in 0.9 replace part of the functionality of
296
:meth:`.Query.select_from`. In 0.8, the two methods perform
297
the same function, so that code can be migrated to use the
298
:meth:`.Query.select_entity_from` method as appropriate.
299
See the 0.9 migration guide for details.
305
Fixed a regression caused by :ticket:`2682` whereby the
306
evaluation invoked by :meth:`.Query.update` and :meth:`.Query.delete`
307
would hit upon unsupported ``True`` and ``False`` symbols
308
which now appear due to the usage of ``IS``.
311
:tags: bug, postgresql
314
Fixed the HSTORE type to correctly encode/decode for unicode.
315
This is always on, as the hstore is a textual type, and
316
matches the behavior of psycopg2 when using Python 3.
317
Courtesy Dmitry Mugtasimov.
322
Fixed a small bug in the dogpile example where the generation
323
of SQL cache keys wasn't applying deduping labels to the
324
statement the same way :class:`.Query` normally does.
327
:tags: bug, engine, sybase
330
Fixed a bug where the routine to detect the correct kwargs
331
being sent to :func:`.create_engine` would fail in some cases,
332
such as with the Sybase dialect.
338
Fixed a regression from 0.7 caused by this ticket, which
339
made the check for recursion overflow in self-referential
340
eager joining too loose, missing a particular circumstance
341
where a subclass had lazy="joined" or "subquery" configured
342
and the load was a "with_polymorphic" against the base.
348
Fixed a regression from 0.7 where the contextmanager feature
349
of :meth:`.Session.begin_nested` would fail to correctly
350
roll back the transaction when a flush error occurred, instead
351
raising its own exception while leaving the session still
357
Updated mysqlconnector dialect to check for disconnect based
358
on the apparent string message sent in the exception; tested
359
against mysqlconnector 1.0.9.
362
:tags: bug, sql, mssql
365
Regression from this ticket caused the unsupported keyword
366
"true" to render, added logic to convert this to 1/0
371
:released: April 27, 2013
377
Fixes to the ``sqlalchemy.ext.serializer`` extension, including
378
that the "id" passed from the pickler is turned into a string
379
to prevent against bytes being parsed on Py3K, as well as that
380
``relationship()`` and ``orm.join()`` constructs are now properly
387
A significant improvement to the inner workings of query.join(),
388
such that the decisionmaking involved on how to join has been
389
dramatically simplified. New test cases now pass such as
390
multiple joins extending from the middle of an already complex
391
series of joins involving inheritance and such. Joining from
392
deeply nested subquery structures is still complicated and
393
not without caveats, but with these improvements the edge
394
cases are hopefully pushed even farther out to the edges.
400
Added a convenience method to Query that turns a query into an
401
EXISTS subquery of the form
402
``EXISTS (SELECT 1 FROM ... WHERE ...)``.
407
Added a conditional to the unpickling process for ORM
408
mapped objects, such that if the reference to the object
409
were lost when the object was pickled, we don't
410
erroneously try to set up _sa_instance_state - fixes
414
:tags: bug, postgresql
417
Opened up the checking for "disconnect" with psycopg2/libpq
418
to check for all the various "disconnect" messages within
419
the full exception hierarchy. Specifically the
420
"closed the connection unexpectedly" message has now been
421
seen in at least three different exception types.
422
Courtesy Eli Collins.
425
:tags: bug, sql, mysql
428
Fully implemented the IS and IS NOT operators with
429
regards to the True/False constants. An expression like
430
``col.is_(True)`` will now render ``col IS true``
431
on the target platform, rather than converting the True/
432
False constant to an integer bound parameter.
433
This allows the ``is_()`` operator to work on MySQL when
434
given True/False constants.
437
:tags: bug, postgresql
440
The operators for the Postgresql ARRAY type supports
441
input types of sets, generators, etc. even when
442
a dimension is not specified, by turning the given
443
iterable into a collection unconditionally.
449
Fixes to support the latest cymysql DBAPI, courtesy
456
Improvements to the operation of the pymysql dialect on
457
Python 3, including some important decode/bytes steps.
458
Issues remain with BLOB types due to driver issues.
459
Courtesy Ben Trofatter.
465
Fixed bug where many-to-many relationship with uselist=False
466
would fail to delete the association row and raise an error
467
if the scalar attribute were set to None. This was a
468
regression introduced by the changes for :ticket:`2229`.
474
Improved the behavior of instance management regarding
475
the creation of strong references within the Session;
476
an object will no longer have an internal reference cycle
477
created if it's in the transient state or moves into the
478
detached state - the strong ref is created only when the
479
object is attached to a Session and is removed when the
480
object is detached. This makes it somewhat safer for an
481
object to have a `__del__()` method, even though this is
482
not recommended, as relationships with backrefs produce
483
cycles too. A warning has been added when a class with
484
a `__del__()` method is mapped.
490
A major fix to the way in which a select() object produces
491
labeled columns when apply_labels() is used; this mode
492
produces a SELECT where each column is labeled as in
493
<tablename>_<columnname>, to remove column name collisions
494
for a multiple table select. The fix is that if two labels
495
collide when combined with the table name, i.e.
496
"foo.bar_id" and "foo_bar.id", anonymous aliasing will be
497
applied to one of the dupes. This allows the ORM to handle
498
both columns independently; previously, 0.7
499
would in some cases silently emit a second SELECT for the
500
column that was "duped", and in 0.8 an ambiguous column error
501
would be emitted. The "keys" applied to the .c. collection
502
of the select() will also be deduped, so that the "column
503
being replaced" warning will no longer emit for any select()
504
that specifies use_labels, though the dupe key will be given
505
an anonymous label which isn't generally user-friendly.
511
Updated a regexp to correctly extract error code on
512
google app engine v1.7.5 and newer. Courtesy
518
Fixed a long-standing bug in the caching example, where
519
the limit/offset parameter values wouldn't be taken into
520
account when computing the cache key. The
521
_key_from_query() function has been simplified to work
522
directly from the final compiled statement in order to get
523
at both the full statement as well as the fully processed
530
Part of a longer series of fixes needed for pyodbc+
531
mssql, a CAST to NVARCHAR(max) has been added to the bound
532
parameter for the table name and schema name in all information schema
533
queries to avoid the issue of comparing NVARCHAR to NTEXT,
534
which seems to be rejected by the ODBC driver in some cases,
535
such as FreeTDS (0.91 only?) plus unicode bound parameters being passed.
536
The issue seems to be specific to the SQL Server information
537
schema tables and the workaround is harmless for those cases
538
where the problem doesn't exist in the first place.
544
Fixed bug where disconnect detect on error would
545
raise an attribute error if the error were being
546
raised after the Connection object had already
553
Reworked internal exception raises that emit
554
a rollback() before re-raising, so that the stack
555
trace is preserved from sys.exc_info() before entering
556
the rollback. This so that the traceback is preserved
557
when using coroutine frameworks which may have switched
558
contexts before the rollback function returns.
564
Fixed bug whereby ORM would run the wrong kind of
565
query when refreshing an inheritance-mapped class
566
where the superclass was mapped to a non-Table
567
object, like a custom join() or a select(),
568
running a query that assumed a hierarchy that's
569
mapped to individual Table-per-class.
574
Fixed `__repr__()` on mapper property constructs
575
to work before the object is initialized, so
576
that Sphinx builds with recent Sphinx versions
580
:tags: bug, sql, postgresql
582
The _Binary base type now converts values through
583
the bytes() callable when run on Python 3; in particular
584
psycopg2 2.5 with Python 3.3 seems to now be returning
585
the "memoryview" type, so this is converted to bytes
592
Improvements to Connection auto-invalidation
593
handling. If a non-disconnect error occurs,
594
but leads to a delayed disconnect error within error
595
handling (happens with MySQL), the disconnect condition
596
is detected. The Connection can now also be closed
597
when in an invalid state, meaning it will raise "closed"
598
on next usage, and additionally the "close with result"
599
feature will work even if the autorollback in an error
600
handling routine fails and regardless of whether the
601
condition is a disconnect or not.
605
:tags: bug, orm, declarative
608
Fixed indirect regression regarding :func:`.has_inherited_table`,
609
where since it considers the current class' ``__table__``, was
610
sensitive to when it was called. This is 0.7's behavior also,
611
but in 0.7 things tended to "work out" within events like
612
``__mapper_args__()``. :func:`.has_inherited_table` now only
613
considers superclasses, so should return the same answer
614
regarding the current class no matter when it's called
615
(obviously assuming the state of the superclass).
621
Fixed bug when a query of the form:
622
``query(SubClass).options(subqueryload(Baseclass.attrname))``,
623
where ``SubClass`` is a joined inh of ``BaseClass``,
624
would fail to apply the ``JOIN`` inside the subquery
625
on the attribute load, producing a cartesian product.
626
The populated results still tended to be correct as additional
627
rows are just ignored, so this issue may be present as a
628
performance degradation in applications that are
629
otherwise working correctly. Also in 0.7.11.
635
Fixed bug in unit of work whereby a joined-inheritance
636
subclass could insert the row for the "sub" table
637
before the parent table, if the two tables had no
638
ForeignKey constraints set up between them.
645
Added support for additional "disconnect" messages
646
to the pymssql dialect. Courtesy John Anderson.
651
Loosened the check on dialect-specific argument names
652
passed to Table(); since we want to support external dialects
653
and also want to support args without a certain dialect
654
being installed, it only checks the format of the arg now,
655
rather than looking for that dialect in sqlalchemy.dialects.
660
Fixed bug whereby a DBAPI that can return "0"
661
for cursor.lastrowid would not function correctly
662
in conjunction with :attr:`.ResultProxy.inserted_primary_key`.
669
Fixed Py3K bug regarding "binary" types and
670
pymssql. Courtesy Marc Abramowitz.
673
:tags: bug, postgresql
676
Added missing HSTORE type to postgresql type names
677
so that the type can be reflected.
681
:released: March 9, 2013
685
There are some new behavioral changes as of 0.8.0
686
not present in 0.8.0b2. They are present in the
687
migration document as follows:
689
* :ref:`legacy_is_orphan_addition`
691
* :ref:`metadata_create_drop_tables`
693
* :ref:`correlation_context_specific`
696
:tags: feature, postgresql
699
Added support for Postgresql's traditional SUBSTRING
700
function syntax, renders as "SUBSTRING(x FROM y FOR z)"
701
when regular ``func.substring()`` is used.
702
Also in 0.7.11. Courtesy Gunnlaugur Þór Briem.
708
A meaningful :attr:`.QueryableAttribute.info` attribute is
709
added, which proxies down to the ``.info`` attribute on either
710
the :class:`.schema.Column` object if directly present, or
711
the :class:`.MapperProperty` otherwise. The full behavior
712
is documented and ensured by tests to remain stable.
718
The behavior of SELECT correlation has been improved such that
719
the :meth:`.Select.correlate` and :meth:`.Select.correlate_except`
720
methods, as well as their ORM analogues, will still retain
721
"auto-correlation" behavior in that the FROM clause is modified
722
only if the output would be legal SQL; that is, the FROM clause
723
is left intact if the correlated SELECT is not used in the context
724
of an enclosing SELECT inside of the WHERE, columns, or HAVING clause.
725
The two methods now only specify conditions to the default
726
"auto correlation", rather than absolute FROM lists.
729
:tags: feature, mysql
732
New dialect for CyMySQL added, courtesy Hajime Nakagami.
738
Improved checking for an existing backref name conflict during
739
mapper configuration; will now test for name conflicts on
740
superclasses and subclasses, in addition to the current mapper,
741
as these conflicts break things just as much. This is new for
742
0.8, but see below for a warning that will also be triggered
749
Improved the error message emitted when a "backref loop" is detected,
750
that is when an attribute event triggers a bidirectional
751
assignment between two other attributes with no end.
752
This condition can occur not just when an object of the wrong
753
type is assigned, but also when an attribute is mis-configured
754
to backref into an existing backref pair. Also in 0.7.11.
760
A warning is emitted when a MapperProperty is assigned to a mapper
761
that replaces an existing property, if the properties in question
762
aren't plain column-based properties. Replacement of relationship
763
properties is rarely (ever?) what is intended and usually refers to a
764
mapper mis-configuration. Also in 0.7.11.
769
Can set/change the "cascade" attribute on a :func:`.relationship`
770
construct after it's been constructed already. This is not
771
a pattern for normal use but we like to change the setting
772
for demonstration purposes in tutorials.
778
:meth:`.MetaData.create_all` and :meth:`.MetaData.drop_all` will
779
now accommodate an empty list as an instruction to not create/drop
780
any items, rather than ignoring the collection.
788
Fixed an import of "logging" in test_execute which was not
789
working on some linux platforms. Also in 0.7.11.
795
A clear error message is emitted if an event handler
796
attempts to emit SQL on a Session within the after_commit()
797
handler, where there is not a viable transaction in progress.
803
Detection of a primary key change within the process
804
of cascading a natural primary key update will succeed
805
even if the key is composite and only some of the
806
attributes have changed.
812
Added new helper function :func:`.was_deleted`, returns True
813
if the given object was the subject of a :meth:`.Session.delete`
820
An object that's deleted from a session will be de-associated with
821
that session fully after the transaction is committed, that is
822
the :func:`.object_session` function will return None.
827
The cx_oracle dialect will no longer run the bind parameter names
828
through ``encode()``, as this is not valid on Python 3, and prevented
829
statements from functioning correctly on Python 3. We now
830
encode only if ``supports_unicode_binds`` is False, which is not
831
the case for cx_oracle when at least version 5 of cx_oracle is used.
837
Fixed bug whereby :meth:`.Query.yield_per` would set the execution
838
options incorrectly, thereby breaking subsequent usage of the
839
:meth:`.Query.execution_options` method. Courtesy Ryan Kelly.
845
Fixed the consideration of the ``between()`` operator
846
so that it works correctly with the new relationship local/remote
853
Fixed a bug regarding column annotations which in particular
854
could impact some usages of the new :func:`.orm.remote` and
855
:func:`.orm.local` annotation functions, where annotations
856
could be lost when the column were used in a subsequent
860
:tags: bug, mysql, gae
863
Added a conditional import to the ``gaerdbms`` dialect which attempts
864
to import rdbms_apiproxy vs. rdbms_googleapi to work
865
on both dev and production platforms. Also now honors the
866
``instance`` attribute. Courtesy Sean Lynch.
873
The :meth:`.ColumnOperators.in_` operator will now coerce
874
values of ``None`` to :func:`.null`.
880
Added a new argument to :class:`.Enum` and its base
881
:class:`.SchemaType` ``inherit_schema``. When set to ``True``,
882
the type will set its ``schema`` attribute of that of the
883
:class:`.Table` to which it is associated. This also occurs
884
during a :meth:`.Table.tometadata` operation; the :class:`.SchemaType`
885
is now copied in all cases when :meth:`.Table.tometadata` happens,
886
and if ``inherit_schema=True``, the type will take on the new
887
schema name passed to the method. The ``schema`` is important
888
when used with the Postgresql backend, as the type results in
889
a ``CREATE TYPE`` statement.
892
:tags: feature, postgresql
895
Added :meth:`.postgresql.ARRAY.Comparator.any` and
896
:meth:`.postgresql.ARRAY.Comparator.all`
897
methods, as well as standalone expression constructs. Big thanks
898
to Audrius Kažukauskas for the terrific work here.
904
Fixed bug where :meth:`.Table.tometadata` would fail if a
905
:class:`.Column` had both a foreign key as well as an
906
alternate ".key" name for the column. Also in 0.7.10.
912
insert().returning() raises an informative CompileError if attempted
913
to compile on a dialect that doesn't support RETURNING.
919
the consideration of a pending object as
920
an "orphan" has been modified to more closely match the
921
behavior as that of persistent objects, which is that the object
922
is expunged from the :class:`.Session` as soon as it is
923
de-associated from any of its orphan-enabled parents. Previously,
924
the pending object would be expunged only if de-associated
925
from all of its orphan-enabled parents. The new flag ``legacy_is_orphan``
926
is added to :func:`.orm.mapper` which re-establishes the
929
See the change note and example case at :ref:`legacy_is_orphan_addition`
930
for a detailed discussion of this change.
936
Fixed the (most likely never used) "@collection.link" collection
937
method, which fires off each time the collection is associated
938
or de-associated with a mapped object - the decorator
939
was not tested or functional. The decorator method
940
is now named :meth:`.collection.linker` though the name "link"
941
remains for backwards compatibility. Courtesy Luca Wehrstedt.
947
Made some fixes to the system of producing custom instrumented
948
collections, mainly that the usage of the @collection decorators
949
will now honor the __mro__ of the given class, applying the
950
logic of the sub-most classes' version of a particular collection
951
method. Previously, it wasn't predictable when subclassing
952
an existing instrumented class such as :class:`.MappedCollection`
953
whether or not custom methods would resolve correctly.
958
The undocumented (and hopefully unused) system of producing
959
custom collections using an ``__instrumentation__`` datastructure
960
associated with the collection has been removed, as this was a complex
961
and untested feature which was also essentially redundant versus the
962
decorator approach. Other internal simplifcations to the
963
orm.collections module have been made as well.
966
:tags: mssql, feature
969
Added ``mssql_include`` and ``mssql_clustered`` options to
970
:class:`.Index`, renders the ``INCLUDE`` and ``CLUSTERED`` keywords,
971
respectively. Courtesy Derek Harland.
977
:class:`.Index` now supports arbitrary SQL expressions and/or
978
functions, in addition to straight columns. Common modifiers
979
include using ``somecolumn.desc()`` for a descending index and
980
``func.lower(somecolumn)`` for a case-insensitive index, depending on the
981
capabilities of the target backend.
987
Added a py3K conditional around unnecessary .decode()
988
call in mssql information schema, fixes reflection
989
in Py3K. Also in 0.7.10.
995
Fixed potential memory leak which could occur if an
996
arbitrary number of :class:`.sessionmaker` objects
997
were created. The anonymous subclass created by
998
the sessionmaker, when dereferenced, would not be garbage
999
collected due to remaining class-level references from the
1000
event package. This issue also applies to any custom system
1001
that made use of ad-hoc subclasses in conjunction with
1002
an event dispatcher. Also in 0.7.10.
1007
Fixed a regression whereby the "collation" parameter
1008
of the character types CHAR, NCHAR, etc. stopped working,
1009
as "collation" is now supported by the base string types.
1010
The TEXT, NCHAR, CHAR, VARCHAR types within the
1011
MSSQL dialect are now synonyms for the base types.
1014
:tags: mssql, feature
1018
DDL for IDENTITY columns is now supported on
1019
non-primary key columns, by establishing a
1020
:class:`.Sequence` construct on any
1021
integer column. Courtesy Derek Harland.
1024
:tags: examples, bug
1026
Fixed a regression in the examples/dogpile_caching example
1027
which was due to the change in :ticket:`2614`.
1033
:meth:`.Query.merge_result` can now load rows from an outer join
1034
where an entity may be ``None`` without throwing an error.
1041
Tweaked the "REQUIRED" symbol used by the compiler to identify
1042
INSERT/UPDATE bound parameters that need to be passed, so that
1043
it's more easily identifiable when writing custom bind-handling
1047
:tags: postgresql, bug
1049
Fixed bug in :func:`.postgresql.array` construct whereby using it
1050
inside of an :func:`.expression.insert` construct would produce an
1051
error regarding a parameter issue in the ``self_group()`` method.
1056
Extended the :doc:`/core/inspection` system so that all Python descriptors
1057
associated with the ORM or its extensions can be retrieved.
1058
This fulfills the common request of being able to inspect
1059
all :class:`.QueryableAttribute` descriptors in addition to
1060
extension types such as :class:`.hybrid_property` and
1061
:class:`.AssociationProxy`. See :attr:`.Mapper.all_orm_descriptors`.
1064
:tags: mysql, feature
1067
GAE dialect now accepts username/password arguments in the URL,
1068
courtesy Owen Nelson.
1074
GAE dialect won't fail on None match if the error code can't be extracted
1075
from the exception throw; courtesy Owen Nelson.
1081
Fixes to the "dynamic" loader on :func:`.relationship`, includes
1082
that backrefs will work properly even when autoflush is disabled,
1083
history events are more accurate in scenarios where multiple add/remove
1084
of the same object occurs.
1088
:released: December 14, 2012
1094
More adjustment to this SQLite related issue which was released in
1095
0.7.9, to intercept legacy SQLite quoting characters when reflecting
1096
foreign keys. In addition to intercepting double quotes, other
1097
quoting characters such as brackets, backticks, and single quotes
1098
are now also intercepted. Also in 0.7.10.
1104
The :meth:`.Query.select_from` method can now be used with a
1105
:func:`.aliased` construct without it interfering with the entities
1106
being selected. Basically, a statement like this::
1109
session.query(User.name).select_from(ua).join(User, User.name > ua.name)
1111
Will maintain the columns clause of the SELECT as coming from the
1112
unaliased "user", as specified; the select_from only takes place in the
1115
SELECT users.name AS users_name FROM users AS users_1
1116
JOIN users ON users.name < users_1.name
1118
Note that this behavior is in contrast
1119
to the original, older use case for :meth:`.Query.select_from`, which is that
1120
of restating the mapped entity in terms of a different selectable::
1122
session.query(User.name).\
1123
select_from(user_table.select().where(user_table.c.id > 5))
1127
SELECT anon_1.name AS anon_1_name FROM (SELECT users.id AS id,
1128
users.name AS name FROM users WHERE users.id > :id_1) AS anon_1
1130
It was the "aliasing" behavior of the latter use case that was
1131
getting in the way of the former use case. The method now
1132
specifically considers a SQL expression like
1133
:func:`.expression.select` or :func:`.expression.alias`
1134
separately from a mapped entity like a :func:`.aliased`
1141
Fixed a regression caused by :ticket:`2410` whereby a
1142
:class:`.CheckConstraint` would apply itself back to the
1143
original table during a :meth:`.Table.tometadata` operation, as
1144
it would parse the SQL expression for a parent table. The
1145
operation now copies the given expression to correspond to the
1152
Fixed table reflection for Oracle when accessing a synonym that refers
1153
to a DBLINK remote database; while the syntax has been present in the
1154
Oracle dialect for some time, up until now it has never been tested.
1155
The syntax has been tested against a sample database linking to itself,
1156
however there's still some uncertainty as to what should be used for the
1157
"owner" when querying the remote database for table information.
1158
Currently, the value of "username" from user_db_links is used to
1165
Added :meth:`.KeyedTuple._asdict` and :attr:`.KeyedTuple._fields`
1166
to the :class:`.KeyedTuple` class to provide some degree of compatibility
1167
with the Python standard library ``collections.namedtuple()``.
1173
Fixed bug where using server_onupdate=<FetchedValue|DefaultClause>
1174
without passing the "for_update=True" flag would apply the default
1175
object to the server_default, blowing away whatever was there.
1176
The explicit for_update=True argument shouldn't be needed with this usage
1177
(especially since the documentation shows an example without it being
1178
used) so it is now arranged internally using a copy of the given default
1179
object, if the flag isn't set to what corresponds to that argument.
1186
Fixed bug whereby using a label_length on dialect that was smaller
1187
than the size of actual column identifiers would fail to render
1188
the columns correctly in a SELECT statement.
1194
The :class:`.Insert` construct now supports multi-valued inserts,
1195
that is, an INSERT that renders like
1196
"INSERT INTO table VALUES (...), (...), ...".
1197
Supported by Postgresql, SQLite, and MySQL.
1198
Big thanks to Idan Kamara for doing the legwork on this one.
1204
The Oracle LONG type, while an unbounded text type, does not appear
1205
to use the cx_Oracle.LOB type when result rows are returned,
1206
so the dialect has been repaired to exclude LONG from
1207
having cx_Oracle.LOB filtering applied. Also in 0.7.10.
1213
Repaired the usage of ``.prepare()`` in conjunction with
1214
cx_Oracle so that a return value of ``False`` will result
1215
in no call to ``connection.commit()``, hence avoiding
1216
"no transaction" errors. Two-phase transactions have
1217
now been shown to work in a rudimental fashion with
1218
SQLAlchemy and cx_oracle, however are subject to caveats
1219
observed with the driver; check the documentation
1220
for details. Also in 0.7.10.
1226
The :class:`.DECIMAL` type now honors the "precision" and
1227
"scale" arguments when rendering DDL.
1233
The :class:`.MutableComposite` type did not allow for the
1234
:meth:`.MutableBase.coerce` method to be used, even though
1235
the code seemed to indicate this intent, so this now works
1236
and a brief example is added. As a side-effect,
1237
the mechanics of this event handler have been changed so that
1238
new :class:`.MutableComposite` types no longer add per-type
1239
global event handlers. Also in 0.7.10.
1245
Made an adjustment to the "boolean", (i.e. ``__nonzero__``)
1246
evaluation of binary expressions, i.e. ``x1 == x2``, such
1247
that the "auto-grouping" applied by :class:`.BinaryExpression`
1248
in some cases won't get in the way of this comparison.
1249
Previously, an expression like::
1251
expr1 = mycolumn > 2
1252
bool(expr1 == expr1)
1254
Would evaulate as ``False``, even though this is an identity
1255
comparison, because ``mycolumn > 2`` would be "grouped" before
1256
being placed into the :class:`.BinaryExpression`, thus changing
1257
its identity. :class:`.BinaryExpression` now keeps track
1258
of the "original" objects passed in.
1259
Additionally the ``__nonzero__`` method now only returns if
1260
the operator is ``==`` or ``!=`` - all others raise ``TypeError``.
1263
:tags: firebird, bug
1266
Added missing import for "fdb" to the experimental
1267
"firebird+fdb" dialect.
1272
Allow synonyms to be used when defining primary and secondary
1273
joins for relationships.
1279
A second overhaul of aliasing/internal pathing mechanics
1280
now allows two subclasses to have different relationships
1281
of the same name, supported with subquery or joined eager
1282
loading on both simultaneously when a full polymorphic
1289
Fixed bug whereby a multi-hop subqueryload within
1290
a particular with_polymorphic load would produce a KeyError.
1291
Takes advantage of the same internal pathing overhaul
1297
Fixed a gotcha where inadvertently calling list() on a
1298
:class:`.ColumnElement` would go into an endless loop, if
1299
:meth:`.ColumnOperators.__getitem__` were implemented.
1300
A new NotImplementedError is emitted via ``__iter__()``.
1303
:tags: orm, extensions, feature
1305
The :mod:`sqlalchemy.ext.mutable` extension now includes the
1306
example :class:`.MutableDict` class as part of the extension.
1309
:tags: postgresql, feature
1312
:class:`.HSTORE` is now available in the Postgresql dialect.
1313
Will also use psycopg2's extensions if available. Courtesy
1314
Audrius Kažukauskas.
1317
:tags: sybase, feature
1320
Reflection support has been added to the Sybase dialect.
1321
Big thanks to Ben Trofatter for all the work developing and
1325
:tags: engine, feature
1327
The :meth:`.Connection.connect` and :meth:`.Connection.contextual_connect`
1328
methods now return a "branched" version so that the :meth:`.Connection.close`
1329
method can be called on the returned connection without affecting the
1330
original. Allows symmetry when using :class:`.Engine` and
1331
:class:`.Connection` objects as context managers::
1333
with conn.connect() as c: # leaves the Connection open
1336
with engine.connect() as c: # closes the Connection
1342
The "reflect=True" argument to :class:`MetaData` is deprecated.
1343
Please use the :meth:`.MetaData.reflect` method.
1349
Fixed :meth:`.MetaData.reflect` to correctly use
1350
the given :class:`.Connection`, if given, without
1351
opening a second connection from that connection's
1352
:class:`.Engine`. Also in 0.7.10.
1358
Fixed bug whereby using "key" with Column
1359
in conjunction with "schema" for the owning
1360
Table would fail to locate result rows due
1361
to the MSSQL dialect's "schema rendering"
1362
logic's failure to take .key into account.
1369
Fixed bug in type_coerce() whereby typing information
1370
could be lost if the statement were used as a subquery
1371
inside of another statement, as well as other similar
1372
situations. Among other things, would cause
1373
typing information to be lost when the Oracle/mssql dialects
1374
would apply limit/offset wrappings.
1380
Fixed regression where query.update() would produce
1381
an error if an object matched by the "fetch"
1382
synchronization strategy wasn't locally present.
1383
Courtesy Scott Torborg.
1389
Fixed bug whereby the ".key" of a Column wasn't being
1390
used when producing a "proxy" of the column against
1391
a selectable. This probably didn't occur in 0.7
1392
since 0.7 doesn't respect the ".key" in a wider
1396
:tags: mssql, feature
1399
Support for reflection of the "name" of primary key
1400
constraints added, courtesy Dave Moore.
1405
Some cruft regarding informix transaction handling has been
1406
removed, including a feature that would skip calling
1407
commit()/rollback() as well as some hardcoded isolation level
1408
assumptions on begin().. The status of this dialect is not
1409
well understood as we don't have any users working with it,
1410
nor any access to an Informix database. If someone with
1411
access to Informix wants to help test this dialect, please
1415
:tags: pool, feature
1417
The :class:`.Pool` will now log all connection.close()
1418
operations equally, including closes which occur for
1419
invalidated connections, detached connections, and connections
1420
beyond the pool capacity.
1423
:tags: pool, feature
1426
The :class:`.Pool` now consults the :class:`.Dialect` for
1427
functionality regarding how the connection should be
1428
"auto rolled back", as well as closed. This grants more
1429
control of transaction scope to the dialect, so that we
1430
will be better able to implement transactional workarounds
1431
like those potentially needed for pysqlite and cx_oracle.
1434
:tags: pool, feature
1436
Added new :meth:`.PoolEvents.reset` hook to capture
1437
the event before a connection is auto-rolled back, upon
1438
return to the pool. Together with
1439
:meth:`.ConnectionEvents.rollback` this allows all rollback
1440
events to be intercepted.
1444
:released: October 30, 2012
1450
Fixed bug where keyword arguments passed to
1451
:meth:`.Compiler.process` wouldn't get propagated
1452
to the column expressions present in the columns
1453
clause of a SELECT statement. In particular this would
1454
come up when used by custom compilation schemes that
1455
relied upon special flags.
1460
Added a new method :meth:`.Engine.execution_options`
1461
to :class:`.Engine`. This method works similarly to
1462
:meth:`.Connection.execution_options` in that it creates
1463
a copy of the parent object which will refer to the new
1464
set of options. The method can be used to build
1465
sharding schemes where each engine shares the same
1466
underlying pool of connections. The method
1467
has been tested against the horizontal shard
1468
recipe in the ORM as well.
1472
:meth:`.Engine.execution_options`
1475
:tags: sql, orm, bug
1478
The auto-correlation feature of :func:`.select`, and
1479
by proxy that of :class:`.orm.Query`, will not
1480
take effect for a SELECT statement that is being
1481
rendered directly in the FROM list of the enclosing
1482
SELECT. Correlation in SQL only applies to column
1483
expressions such as those in the WHERE, ORDER BY,
1489
:changeset: c3addcc9ffad
1491
Added :class:`.types.NCHAR`, :class:`.types.NVARCHAR`
1492
to the SQLite dialect's list of recognized type names
1493
for reflection. SQLite returns the name given
1494
to a type as the name returned.
1500
The Beaker caching example has been converted
1501
to use `dogpile.cache <http://dogpilecache.readthedocs.org/>`_.
1502
This is a new caching library written by the same
1503
creator of Beaker's caching internals, and represents a
1504
vastly improved, simplified, and modernized system of caching.
1508
:ref:`examples_caching`
1514
SQLAlchemy 0.8 now targets Python 2.5 and
1515
above. Python 2.4 is no longer supported.
1518
:tags: removed, general
1521
The "sqlalchemy.exceptions"
1522
synonym for "sqlalchemy.exc" is removed
1529
The legacy "mutable" system of the
1530
ORM, including the MutableType class as well
1531
as the mutable=True flag on PickleType
1532
and postgresql.ARRAY has been removed.
1533
In-place mutations are detected by the ORM
1534
using the sqlalchemy.ext.mutable extension,
1535
introduced in 0.7. The removal of MutableType
1536
and associated constructs removes a great
1537
deal of complexity from SQLAlchemy's internals.
1538
The approach performed poorly as it would incur
1539
a scan of the full contents of the Session
1546
The InstrumentationManager interface
1547
and the entire related system of alternate
1548
class implementation is now moved out
1549
to sqlalchemy.ext.instrumentation. This is
1550
a seldom used system that adds significant
1551
complexity and overhead to the mechanics of
1552
class instrumentation. The new architecture
1553
allows it to remain unused until
1554
InstrumentationManager is actually imported,
1555
at which point it is bootstrapped into
1562
Major rewrite of relationship()
1563
internals now allow join conditions which
1564
include columns pointing to themselves
1565
within composite foreign keys. A new
1566
API for very specialized primaryjoin conditions
1567
is added, allowing conditions based on
1568
SQL functions, CAST, etc. to be handled
1569
by placing the annotation functions
1570
remote() and foreign() inline within the
1571
expression when necessary. Previous recipes
1572
using the semi-private _local_remote_pairs
1573
approach can be upgraded to this new
1578
:ref:`feature_relationship_08`
1584
ORM will perform extra effort to determine
1585
that an FK dependency between two tables is
1586
not significant during flush if the tables
1587
are related via joined inheritance and the FK
1588
dependency is not part of the inherit_condition,
1589
saves the user a use_alter directive.
1595
New standalone function with_polymorphic()
1596
provides the functionality of query.with_polymorphic()
1597
in a standalone form. It can be applied to any
1598
entity within a query, including as the target
1599
of a join in place of the "of_type()" modifier.
1603
:tickets: 1106, 2438
1605
The of_type() construct on attributes
1606
now accepts aliased() class constructs as well
1607
as with_polymorphic constructs, and works with
1608
query.join(), any(), has(), and also
1609
eager loaders subqueryload(), joinedload(),
1616
Improvements to event listening for
1617
mapped classes allows that unmapped classes
1618
can be specified for instance- and mapper-events.
1619
The established events will be automatically
1620
set up on subclasses of that class when the
1621
propagate=True flag is passed, and the
1622
events will be set up for that class itself
1623
if and when it is ultimately mapped.
1629
The instrumentation events class_instrument(),
1630
class_uninstrument(), and attribute_instrument()
1631
will now fire off only for descendant classes
1632
of the class assigned to listen(). Previously,
1633
an event listener would be assigned to listen
1634
for all classes in all cases regardless of the
1635
"target" argument passed.
1641
with_polymorphic() produces JOINs
1642
in the correct order and with correct inheriting
1643
tables in the case of sending multi-level
1644
subclasses in an arbitrary order or with
1645
intermediary classes missing.
1651
The "deferred declarative
1652
reflection" system has been moved into the
1653
declarative extension itself, using the
1654
new DeferredReflection class. This
1655
class is now tested with both single
1656
and joined table inheritance use cases.
1662
Added new core function "inspect()",
1663
which serves as a generic gateway to
1664
introspection into mappers, objects,
1665
others. The Mapper and InstanceState
1666
objects have been enhanced with a public
1667
API that allows inspection of mapped
1668
attributes, including filters for column-bound
1669
or relationship-bound properties, inspection
1670
of current object state, history of
1677
Calling rollback() within a
1678
session.begin_nested() will now only expire
1679
those objects that had net changes within the
1680
scope of that transaction, that is objects which
1681
were dirty or were modified on a flush. This
1682
allows the typical use case for begin_nested(),
1683
that of altering a small subset of objects, to
1684
leave in place the data from the larger enclosing
1685
set of objects that weren't modified in
1686
that sub-transaction.
1692
Added utility feature
1693
Session.enable_relationship_loading(),
1694
supersedes relationship.load_on_pending.
1695
Both features should be avoided, however.
1701
Added support for .info dictionary argument to
1702
column_property(), relationship(), composite().
1703
All MapperProperty classes have an auto-creating .info
1704
dict available overall.
1710
Adding/removing None from a mapped collection
1711
now generates attribute events. Previously, a None
1712
append would be ignored in some cases. Related
1719
The presence of None in a mapped collection
1720
now raises an error during flush. Previously,
1721
None values in collections would be silently ignored.
1727
The Query.update() method is now
1728
more lenient as to the table
1729
being updated. Plain Table objects are better
1730
supported now, and additional a joined-inheritance
1731
subclass may be used with update(); the subclass
1732
table will be the target of the update,
1733
and if the parent table is referenced in the
1734
WHERE clause, the compiler will call upon
1735
UPDATE..FROM syntax as allowed by the dialect
1736
to satisfy the WHERE clause. MySQL's multi-table
1737
update feature is also supported if columns
1738
are specified by object in the "values" dicitionary.
1739
PG's DELETE..USING is also not available
1746
New session events after_transaction_create
1747
and after_transaction_end
1748
allows tracking of new SessionTransaction objects.
1749
If the object is inspected, can be used to determine
1750
when a session first becomes active and when
1757
The Query can now load entity/scalar-mixed
1758
"tuple" rows that contain
1759
types which aren't hashable, by setting the flag
1760
"hashable=False" on the corresponding TypeEngine object
1761
in use. Custom types that return unhashable types
1762
(typically lists) can set this flag to False.
1768
Improvements to joined/subquery eager
1769
loading dealing with chains of subclass entities
1770
sharing a common base, with no specific "join depth"
1771
provided. Will chain out to
1772
each subclass mapper individually before detecting
1773
a "cycle", rather than considering the base class
1774
to be the source of the "cycle".
1780
The "passive" flag on Session.is_modified()
1781
no longer has any effect. is_modified() in
1782
all cases looks only at local in-memory
1783
modified flags and will not emit any
1784
SQL or invoke loader callables/initializers.
1790
The warning emitted when using
1791
delete-orphan cascade with one-to-many
1792
or many-to-many without single-parent=True
1793
is now an error. The ORM
1794
would fail to function subsequent to this
1795
warning in any case.
1801
Lazy loads emitted within flush events
1802
such as before_flush(), before_update(),
1803
etc. will now function as they would
1804
within non-event code, regarding consideration
1805
of the PK/FK values used in the lazy-emitted
1807
special flags would be established that
1808
would cause lazy loads to load related items
1809
based on the "previous" value of the
1810
parent PK/FK values specifically when called
1811
upon within a flush; the signal to load
1812
in this way is now localized to where the
1813
unit of work actually needs to load that
1814
way. Note that the UOW does
1815
sometimes load these collections before
1816
the before_update() event is called,
1817
so the usage of "passive_updates" or not
1818
can affect whether or not a collection will
1819
represent the "old" or "new" data, when
1820
accessed within a flush event, based
1821
on when the lazy load was emitted.
1822
The change is backwards incompatible in
1823
the exceedingly small chance that
1824
user event code depended on the old
1831
Query now "auto correlates" by
1832
default in the same way as select() does.
1833
Previously, a Query used as a subquery
1834
in another would require the correlate()
1835
method be called explicitly in order to
1836
correlate a table on the inside to the
1837
outside. As always, correlate(None)
1838
disables correlation.
1844
The after_attach event is now
1845
emitted after the object is established
1846
in Session.new or Session.identity_map
1847
upon Session.add(), Session.merge(),
1848
etc., so that the object is represented
1849
in these collections when the event
1850
is called. Added before_attach
1851
event to accommodate use cases that
1852
need autoflush w pre-attached object.
1858
The Session will produce warnings
1859
when unsupported methods are used inside the
1860
"execute" portion of the flush. These are
1861
the familiar methods add(), delete(), etc.
1862
as well as collection and related-object
1863
manipulations, as called within mapper-level
1865
like after_insert(), after_update(), etc.
1866
It's been prominently documented for a long
1867
time that SQLAlchemy cannot guarantee
1868
results when the Session is manipulated within
1869
the execution of the flush plan,
1870
however users are still doing it, so now
1871
there's a warning. Maybe someday the Session
1872
will be enhanced to support these operations
1873
inside of the flush, but for now, results
1874
can't be guaranteed.
1878
:tickets: 2582, 2566
1880
Continuing regarding extra
1881
state post-flush due to event listeners;
1882
any states that are marked as "dirty" from an
1883
attribute perspective, usually via column-attribute
1884
set events within after_insert(), after_update(),
1885
etc., will get the "history" flag reset
1886
in all cases, instead of only those instances
1887
that were part of the flush. This has the effect
1888
that this "dirty" state doesn't carry over
1889
after the flush and won't result in UPDATE
1890
statements. A warning is emitted to this
1891
effect; the set_committed_state()
1892
method can be used to assign attributes on objects
1893
without producing history events.
1899
ORM entities can be passed
1900
to the core select() construct as well
1901
as to the select_from(),
1902
correlate(), and correlate_except()
1903
methods of select(), where they will be unwrapped
1910
Some support for auto-rendering of a
1911
relationship join condition based on the mapped
1912
attribute, with usage of core SQL constructs.
1913
E.g. select([SomeClass]).where(SomeClass.somerelationship)
1914
would render SELECT from "someclass" and use the
1915
primaryjoin of "somerelationship" as the WHERE
1916
clause. This changes the previous meaning
1917
of "SomeClass.somerelationship" when used in a
1918
core SQL context; previously, it would "resolve"
1919
to the parent selectable, which wasn't generally
1920
useful. Also works with query.filter().
1927
The registry of classes
1928
in declarative_base() is now a
1929
WeakValueDictionary. So subclasses of
1930
"Base" that are dereferenced will be
1931
garbage collected, *if they are not
1932
referred to by any other mappers/superclass
1933
mappers*. See the next note for this ticket.
1939
Conflicts between columns on
1940
single-inheritance declarative subclasses,
1941
with or without using a mixin, can be resolved
1942
using a new @declared_attr usage described
1943
in the documentation.
1949
declared_attr can now be used
1950
on non-mixin classes, even though this is generally
1951
only useful for single-inheritance subclass
1952
column conflict resolution.
1958
declared_attr can now be used with
1959
attributes that are not Column or MapperProperty;
1960
including any user-defined value as well
1961
as association proxy objects.
1967
Fixed a disconnect that slowly evolved
1968
between a @declared_attr Column and a
1969
directly-defined Column on a mixin. In both
1970
cases, the Column will be applied to the
1971
declared class' table, but not to that of a
1972
joined inheritance subclass. Previously,
1973
the directly-defined Column would be placed
1974
on both the base and the sub table, which isn't
1975
typically what's desired.
1981
*Very limited* support for
1982
inheriting mappers to be GC'ed when the
1983
class itself is deferenced. The mapper
1984
must not have its own table (i.e.
1985
single table inh only) without polymorphic
1986
attributes in place.
1987
This allows for the use case of
1988
creating a temporary subclass of a declarative
1989
mapped class, with no table or mapping
1990
directives of its own, to be garbage collected
1991
when dereferenced by a unit test.
1997
Declarative now maintains a registry
1998
of classes by string name as well as by full
1999
module-qualified name. Multiple classes with the
2000
same name can now be looked up based on a module-qualified
2001
string within relationship(). Simple class name
2002
lookups where more than one class shares the same
2003
name now raises an informative error message.
2009
Can now provide class-bound attributes
2010
that override columns which are of any
2011
non-ORM type, not just descriptors.
2017
Added with_labels and
2018
reduce_columns keyword arguments to
2019
Query.subquery(), to provide two alternate
2020
strategies for producing queries with uniquely-
2027
A warning is emitted when a reference
2028
to an instrumented collection is no longer
2029
associated with the parent class due to
2030
expiration/attribute refresh/collection
2031
replacement, but an append
2032
or remove operation is received on the
2033
now-detached collection.
2039
Declarative can now propagate a column
2040
declared on a single-table inheritance subclass
2041
up to the parent class' table, when the parent
2042
class is itself mapped to a join() or select()
2043
statement, directly or via joined inheritance,
2044
and not just a Table.
2050
An error is emitted when uselist=False
2051
is combined with a "dynamic" loader.
2052
This is a warning in 0.7.9.
2058
Deprecated identifiers removed:
2060
* allow_null_pks mapper() argument
2061
(use allow_partial_pks)
2063
* _get_col_to_prop() mapper method
2064
(use get_property_by_column())
2066
* dont_load argument to Session.merge()
2069
* sqlalchemy.orm.shard module
2070
(use sqlalchemy.ext.horizontal_shard)
2073
:tags: engine, feature
2076
Connection event listeners can
2077
now be associated with individual
2078
Connection objects, not just Engine
2082
:tags: engine, feature
2085
The before_cursor_execute event
2086
fires off for so-called "_cursor_execute"
2087
events, which are usually special-case
2088
executions of primary-key bound sequences
2089
and default-generation SQL
2090
phrases that invoke separately when RETURNING
2091
is not used with INSERT.
2094
:tags: engine, feature
2097
The libraries used by the test suite
2098
have been moved around a bit so that they are
2099
part of the SQLAlchemy install again. In addition,
2100
a new suite of tests is present in the
2101
new sqlalchemy.testing.suite package. This is
2102
an under-development system that hopes to provide
2103
a universal testing suite for external dialects.
2104
Dialects which are maintained outside of SQLAlchemy
2105
can use the new test fixture as the framework
2106
for their own tests, and will get for free a
2107
"compliance" suite of dialect-focused tests,
2108
including an improved "requirements" system
2109
where specific capabilities and features can
2110
be enabled or disabled for testing.
2116
The Inspector.get_table_names()
2117
order_by="foreign_key" feature now sorts
2118
tables by dependee first, to be consistent
2119
with util.sort_tables and metadata.sorted_tables.
2125
Fixed bug whereby if a database restart
2126
affected multiple connections, each
2127
connection would individually invoke a new
2128
disposal of the pool, even though only
2129
one disposal is needed.
2132
:tags: engine, feature
2136
for registration of new dialects in-process
2137
without using an entrypoint. See the
2138
docs for "Registering New Dialects".
2141
:tags: engine, feature
2144
The "required" flag is set to
2145
True by default, if not passed explicitly,
2146
on bindparam() if the "value" or "callable"
2147
parameters are not passed.
2148
This will cause statement execution to check
2149
for the parameter being present in the final
2150
collection of bound parameters, rather than
2151
implicitly assigning None.
2154
:tags: engine, feature
2157
Various API tweaks to the "dialect"
2158
API to better support highly specialized
2159
systems such as the Akiban database, including
2160
more hooks to allow an execution context to
2161
access type processors.
2167
The names of the columns on the
2168
.c. attribute of a select().apply_labels()
2169
is now based on <tablename>_<colkey> instead
2170
of <tablename>_<colname>, for those columns
2171
that have a distinctly named .key.
2174
:tags: engine, feature
2177
Inspector.get_primary_keys() is
2178
deprecated; use Inspector.get_pk_constraint().
2179
Courtesy Diana Clarke.
2185
The autoload_replace flag on Table,
2186
when False, will cause any reflected foreign key
2187
constraints which refer to already-declared
2188
columns to be skipped, assuming that the
2189
in-Python declared column will take over
2190
the task of specifying in-Python ForeignKey
2191
or ForeignKeyConstraint declarations.
2197
The ResultProxy methods inserted_primary_key,
2198
last_updated_params(), last_inserted_params(),
2199
postfetch_cols(), prefetch_cols() all
2200
assert that the given statement is a compiled
2201
construct, and is an insert() or update()
2202
statement as is appropriate, else
2203
raise InvalidRequestError.
2206
:tags: engine, feature
2209
New C extension module "utils" has
2210
been added for additional function speedups
2211
as we have time to implement.
2217
ResultProxy.last_inserted_ids is removed,
2218
replaced by inserted_primary_key.
2224
Major rework of operator system
2225
in Core, to allow redefinition of existing
2226
operators as well as addition of new operators
2227
at the type level. New types can be created
2228
from existing ones which add or redefine
2229
operations that are exported out to column
2230
expressions, in a similar manner to how the
2231
ORM has allowed comparator_factory. The new
2232
architecture moves this capability into the
2233
Core so that it is consistently usable in
2234
all cases, propagating cleanly using existing
2235
type propagation behavior.
2239
:tickets: 1534, 2547
2241
To complement, types
2242
can now provide "bind expressions" and
2243
"column expressions" which allow compile-time
2244
injection of SQL expressions into statements
2245
on a per-column or per-bind level. This is
2246
to suit the use case of a type which needs
2247
to augment bind- and result- behavior at the
2248
SQL level, as opposed to in the Python level.
2249
Allows for schemes like transparent encryption/
2250
decryption, usage of Postgis functions, etc.
2256
The Core oeprator system now includes
2257
the `getitem` operator, i.e. the bracket
2258
operator in Python. This is used at first
2259
to provide index and slice behavior to the
2260
Postgresql ARRAY type, and also provides a hook
2261
for end-user definition of custom __getitem__
2262
schemes which can be applied at the type
2263
level as well as within ORM-level custom
2264
operator schemes. `lshift` (<<)
2265
and `rshift` (>>) are also supported as
2268
Note that this change has the effect that
2269
descriptor-based __getitem__ schemes used by
2270
the ORM in conjunction with synonym() or other
2271
"descriptor-wrapped" schemes will need
2272
to start using a custom comparator in order
2273
to maintain this behavior.
2279
Revised the rules used to determine
2280
the operator precedence for the user-defined
2281
operator, i.e. that granted using the ``op()``
2282
method. Previously, the smallest precedence
2283
was applied in all cases, now the default
2284
precedence is zero, lower than all operators
2285
except "comma" (such as, used in the argument
2286
list of a ``func`` call) and "AS", and is
2287
also customizable via the "precedence" argument
2288
on the ``op()`` method.
2294
Added "collation" parameter to all
2295
String types. When present, renders as
2296
COLLATE <collation>. This to support the
2297
COLLATE keyword now supported by several
2298
databases including MySQL, SQLite, and Postgresql.
2304
The Text() type renders the length
2305
given to it, if a length was specified.
2311
Custom unary operators can now be
2312
used by combining operators.custom_op() with
2319
A tweak to column precedence which moves the
2320
"concat" and "match" operators to be the same as
2321
that of "is", "like", and others; this helps with
2322
parenthesization rendering when used in conjunction
2329
Enhanced GenericFunction and func.*
2330
to allow for user-defined GenericFunction
2331
subclasses to be available via the func.*
2332
namespace automatically by classname,
2333
optionally using a package name, as well
2334
as with the ability to have the rendered
2335
name different from the identified name
2342
The cast() and extract() constructs
2343
will now be produced via the func.* accessor
2344
as well, as users naturally try to access these
2345
names from func.* they might as well do
2346
what's expected, even though the returned
2347
object is not a FunctionElement.
2353
Most classes in expression.sql
2354
are no longer preceded with an underscore,
2355
i.e. Label, SelectBase, Generative, CompareMixin.
2356
_BindParamClause is also renamed to
2357
BindParameter. The old underscore names for
2358
these classes will remain available as synonyms
2359
for the foreseeable future.
2365
The Inspector object can now be
2366
acquired using the new inspect() service,
2373
The column_reflect event now
2374
accepts the Inspector object as the first
2375
argument, preceding "table". Code which
2376
uses the 0.7 version of this very new
2377
event will need modification to add the
2378
"inspector" object as the first argument.
2384
The behavior of column targeting
2385
in result sets is now case sensitive by
2386
default. SQLAlchemy for many years would
2387
run a case-insensitive conversion on these values,
2388
probably to alleviate early case sensitivity
2389
issues with dialects like Oracle and
2390
Firebird. These issues have been more cleanly
2391
solved in more modern versions so the performance
2392
hit of calling lower() on identifiers is removed.
2393
The case insensitive comparisons can be re-enabled
2394
by setting "case_insensitive=False" on
2401
Applying a column expression to a select
2402
statement using a label with or without other
2403
modifying constructs will no longer "target" that
2404
expression to the underlying Column; this affects
2405
ORM operations that rely upon Column targeting
2406
in order to retrieve results. That is, a query
2407
like query(User.id, User.id.label('foo')) will now
2408
track the value of each "User.id" expression separately
2409
instead of munging them together. It is not expected
2410
that any users will be impacted by this; however,
2411
a usage that uses select() in conjunction with
2412
query.from_statement() and attempts to load fully
2413
composed ORM entities may not function as expected
2414
if the select() named Column objects with arbitrary
2415
.label() names, as these will no longer target to
2416
the Column objects mapped by that entity.
2422
The "unconsumed column names" warning emitted
2423
when keys are present in insert.values() or update.values()
2424
that aren't in the target table is now an exception.
2430
Added "MATCH" clause to ForeignKey,
2431
ForeignKeyConstraint, courtesy Ryan Kelly.
2437
Added support for DELETE and UPDATE from
2438
an alias of a table, which would assumedly
2439
be related to itself elsewhere in the query,
2440
courtesy Ryan Kelly.
2446
select() features a correlate_except()
2447
method, auto correlates all selectables except those
2454
The prefix_with() method is now available
2455
on each of select(), insert(), update(), delete(),
2456
all with the same API, accepting multiple
2457
prefix calls, as well as a "dialect name" so that
2458
the prefix can be limited to one kind of dialect.
2464
Added reduce_columns() method
2465
to select() construct, replaces columns inline
2466
using the util.reduce_columns utility function
2467
to remove equivalent columns. reduce_columns()
2468
also adds "with_only_synonyms" to limit the
2469
reduction just to those columns which have the same
2470
name. The deprecated fold_equivalents() feature is
2477
Reworked the startswith(), endswith(),
2478
contains() operators to do a better job with
2479
negation (NOT LIKE), and also to assemble them
2480
at compilation time so that their rendered SQL
2481
can be altered, such as in the case for Firebird
2488
Added a hook to the system of rendering
2489
CREATE TABLE that provides access to the render for each
2490
Column individually, by constructing a @compiles
2491
function against the new schema.CreateColumn
2498
"scalar" selects now have a WHERE method
2499
to help with generative building. Also slight adjustment
2500
regarding how SS "correlates" columns; the new methodology
2501
no longer applies meaning to the underlying
2502
Table column being selected. This improves
2503
some fairly esoteric situations, and the logic
2504
that was there didn't seem to have any purpose.
2510
Fixes to the interpretation of the
2511
Column "default" parameter as a callable
2512
to not pass ExecutionContext into a keyword
2519
All of UniqueConstraint, ForeignKeyConstraint,
2520
CheckConstraint, and PrimaryKeyConstraint will
2521
attach themselves to their parent table automatically
2522
when they refer to a Table-bound Column object directly
2523
(i.e. not just string column name), and refer to
2524
one and only one Table. Prior to 0.8 this behavior
2525
occurred for UniqueConstraint and PrimaryKeyConstraint,
2526
but not ForeignKeyConstraint or CheckConstraint.
2532
TypeDecorator now includes a generic repr()
2533
that works in terms of the "impl" type by default.
2534
This is a behavioral change for those TypeDecorator
2535
classes that specify a custom __init__ method; those
2536
types will need to re-define __repr__() if they need
2537
__repr__() to provide a faithful constructor representation.
2543
column.label(None) now produces an
2544
anonymous label, instead of returning the
2545
column object itself, consistent with the behavior
2546
of label(column, None).
2552
An explicit error is raised when
2553
a ForeignKeyConstraint() that was
2554
constructed to refer to multiple remote tables
2558
:tags: access, feature
2561
the MS Access dialect has been
2562
moved to its own project on Bitbucket,
2563
taking advantage of the new SQLAlchemy
2564
dialect compliance suite. The dialect is
2565
still in very rough shape and probably not
2566
ready for general use yet, however
2567
it does have *extremely* rudimental
2569
https://bitbucket.org/zzzeek/sqlalchemy-access
2575
The MaxDB dialect, which hasn't been
2576
functional for several years, is
2577
moved out to a pending bitbucket project,
2578
https://bitbucket.org/zzzeek/sqlalchemy-maxdb.
2581
:tags: sqlite, feature
2584
the SQLite date and time types
2585
have been overhauled to support a more open
2586
ended format for input and output, using
2587
name based format strings and regexps. A
2588
new argument "microseconds" also provides
2589
the option to omit the "microseconds"
2590
portion of timestamps. Thanks to
2591
Nathan Wright for the work and tests on
2595
:tags: mssql, feature
2598
SQL Server dialect can be given
2599
database-qualified schema names,
2600
i.e. "schema='mydatabase.dbo'"; reflection
2601
operations will detect this, split the schema
2602
among the "." to get the owner separately,
2603
and emit a "USE mydatabase" statement before
2604
reflecting targets within the "dbo" owner;
2605
the existing database returned from
2606
DB_NAME() is then restored.
2612
removed legacy behavior whereby
2613
a column comparison to a scalar SELECT via
2614
== would coerce to an IN with the SQL server
2615
dialect. This is implicit
2616
behavior which fails in other scenarios
2617
so is removed. Code which relies on this
2618
needs to be modified to use column.in_(select)
2622
:tags: mssql, feature
2625
updated support for the mxodbc
2626
driver; mxodbc 3.2.1 is recommended for full
2630
:tags: postgresql, feature
2633
postgresql.ARRAY features an optional
2634
"dimension" argument, will assign a specific
2635
number of dimensions to the array which will
2636
render in DDL as ARRAY[][]..., also improves
2637
performance of bind/result processing.
2640
:tags: postgresql, feature
2643
postgresql.ARRAY now supports
2644
indexing and slicing. The Python [] operator
2645
is available on all SQL expressions that are
2646
of type ARRAY; integer or simple slices can be
2647
passed. The slices can also be used on the
2648
assignment side in the SET clause of an UPDATE
2649
statement by passing them into Update.values();
2650
see the docs for examples.
2653
:tags: postgresql, feature
2656
Added new "array literal" construct
2657
postgresql.array(). Basically a "tuple" that
2658
renders as ARRAY[1,2,3].
2661
:tags: postgresql, feature
2664
Added support for the Postgresql ONLY
2665
keyword, which can appear corresponding to a
2666
table in a SELECT, UPDATE, or DELETE statement.
2667
The phrase is established using with_hint().
2671
:tags: postgresql, feature
2674
The "ischema_names" dictionary of the
2675
Postgresql dialect is "unofficially" customizable.
2676
Meaning, new types such as PostGIS types can
2677
be added into this dictionary, and the PG type
2678
reflection code should be able to handle simple
2679
types with variable numbers of arguments.
2680
The functionality here is "unofficial" for
2683
1. this is not an "official" API. Ideally
2684
an "official" API would allow custom type-handling
2685
callables at the dialect or global level
2687
2. This is only implemented for the PG dialect,
2688
in particular because PG has broad support
2689
for custom types vs. other database backends.
2690
A real API would be implemented at the
2691
default dialect level.
2692
3. The reflection code here is only tested against
2693
simple types and probably has issues with more
2694
compositional types.
2696
patch courtesy Éric Lemoine.
2699
:tags: firebird, feature
2702
The "startswith()" operator renders
2703
as "STARTING WITH", "~startswith()" renders
2704
as "NOT STARTING WITH", using FB's more efficient
2708
:tags: firebird, bug
2711
CompileError is raised when VARCHAR with
2712
no length is attempted to be emitted, same
2716
:tags: firebird, bug
2719
Firebird now uses strict "ansi bind rules"
2720
so that bound parameters don't render in the
2721
columns clause of a statement - they render
2725
:tags: firebird, bug
2728
Support for passing datetime as date when
2729
using the DateTime type with Firebird; other
2730
dialects support this.
2733
:tags: firebird, feature
2736
An experimental dialect for the fdb
2737
driver is added, but is untested as I cannot
2738
get the fdb package to build.
2744
Dialect no longer emits expensive server
2745
collations query, as well as server casing,
2746
on first connect. These functions are still
2747
available as semi-private.
2750
:tags: feature, mysql
2753
Added TIME type to mysql dialect,
2754
accepts "fst" argument which is the new
2755
"fractional seconds" specifier for recent
2756
MySQL versions. The datatype will interpret
2757
a microseconds portion received from the driver,
2758
however note that at this time most/all MySQL
2759
DBAPIs do not support returning this value.
2765
Quoting information is now passed along
2766
from a Column with quote=True when generating
2767
a same-named bound parameter to the bindparam()
2768
object, as is the case in generated INSERT and UPDATE
2769
statements, so that unknown reserved names can
2773
:tags: oracle, feature
2776
The types of columns excluded from the
2777
setinputsizes() set can be customized by sending
2778
a list of string DBAPI type names to exclude,
2779
using the exclude_setinputsizes dialect parameter.
2780
This list was previously fixed. The list also
2781
now defaults to STRING, UNICODE, removing
2782
CLOB, NCLOB from the list.
2788
The CreateIndex construct in Oracle
2789
will now schema-qualify the name of the index
2790
to be that of the parent table. Previously this
2791
name was omitted which apparently creates the
2792
index in the default schema, rather than that
2799
Added :meth:`.ColumnOperators.notin_`,
2800
:meth:`.ColumnOperators.notlike`,
2801
:meth:`.ColumnOperators.notilike` to :class:`.ColumnOperators`.
2806
The long-deprecated and non-functional ``assert_unicode`` flag on
2807
:func:`.create_engine` as well as :class:`.String` is removed.