0.5 Changelog

0.5.9

no release date

sql

  • [sql]

Fixed erroneous self_group() call in expression package.References: #1661

0.5.8

Released: Sat Jan 16 2010

sql

  • [sql]

The copy() method on Column now supports uninitialized,unnamed Column objects. This allows easy creation ofdeclarative helpers which place common columns on multiplesubclasses.

  • [sql]

Default generators like Sequence() translate correctlyacross a copy() operation.

  • [sql]

Sequence() and other DefaultGenerator objects are acceptedas the value for the “default” and “onupdate” keywordarguments of Column, in addition to being acceptedpositionally.

  • [sql]

Fixed a column arithmetic bug that affected columncorrespondence for cloned selectables which containfree-standing column expressions. This bug isgenerally only noticeable when exercising newerORM behavior only available in 0.6 via,but is more correct at the SQL expression levelas well.References: #1568, #1617

postgresql

  • [postgresql]

The extract() function, which was slightly improved in0.5.7, needed a lot more work to generate the correcttypecast (the typecasts appear to be necessary in PG’sEXTRACT quite a lot of the time). The typecast isnow generated using a rule dictionary basedon PG’s documentation for date/time/interval arithmetic.It also accepts text() constructs again, which was brokenin 0.5.7.References: #1647

firebird

  • [firebird]

Recognize more errors as disconnections.References: #1646

0.5.7

Released: Sat Dec 26 2009

orm

  • [orm]

contains_eager() now works with the automaticallygenerated subquery that results when you say“query(Parent).join(Parent.somejoinedsubclass)”, i.e.when Parent joins to a joined-table-inheritance subclass.Previously contains_eager() would erroneously add thesubclass table to the query separately producing acartesian product. An example is in the ticketdescription.References: #1543

  • [orm]

query.options() now only propagate to loaded objectsfor potential further sub-loads only for options wheresuch behavior is relevant, keepingvarious unserializable options like those generatedby contains_eager() out of individual instance states.References: #1553

  • [orm]

Session.execute() now locates table- andmapper-specific binds based on a passedin expression which is an insert()/update()/delete()construct.References: #1054

  • [orm]

Session.merge() now properly overwrites a many-to-one oruselist=False attribute to None if the attributeis also None in the given object to be merged.

  • [orm]

Fixed a needless select which would occur when mergingtransient objects that contained a null primary keyidentifier.References: #1618

  • [orm]

Mutable collection passed to the “extension” attributeof relation(), column_property() etc. will not be mutatedor shared among multiple instrumentation calls, preventingduplicate extensions, such as backref populators,from being inserted into the list.References: #1585

  • [orm]

Fixed the call to get_committed_value() on CompositeProperty.References: #1504

  • [orm]

Fixed bug where Query would crash if a join() with no clear“left” side were called when a non-mapped column entityappeared in the columns list.References: #1602

  • [orm]

Fixed bug whereby composite columns wouldn’t load properlywhen configured on a joined-table subclass, introduced inversion 0.5.6 as a result of the fix for. thx to Scott Torborg.References: #1480, #1616

  • [orm]

The “use get” behavior of many-to-one relations, i.e. that alazy load will fallback to the possibly cached query.get()value, now works across join conditions where the two comparedtypes are not exactly the same class, but share the same“affinity” - i.e. Integer and SmallInteger. Also allowscombinations of reflected and non-reflected types to workwith 0.5 style type reflection, such as PGText/Text (note 0.6reflects types as their generic versions).References: #1556

  • [orm]

Fixed bug in query.update() when passing Cls.attributeas keys in the value dict and using synchronize_session=’expire’(‘fetch’ in 0.6).References: #1436

sql

  • [sql]

Fixed bug in two-phase transaction whereby commit() methoddidn’t set the full state which allows subsequent close()call to succeed.References: #1603

  • [sql]

Fixed the “numeric” paramstyle, which apparently is thedefault paramstyle used by Informixdb.

  • [sql]

Repeat expressions in the columns clause of a selectare deduped based on the identity of each clause element,not the actual string. This allows positionalelements to render correctly even if they all renderidentically, such as “qmark” style bind parameters.References: #1574

  • [sql]

The cursor associated with connection pool connections(i.e. CursorFairy) now proxies _iter() to theunderlying cursor correctly.References: #1632

  • [sql]

types now support an “affinity comparison” operation, i.e.that an Integer/SmallInteger are “compatible”, ora Text/String, PickleType/Binary, etc. Part of.References: #1556

  • [sql]

Fixed bug preventing alias() of an alias() from beingcloned or adapted (occurs frequently in ORM operations).References: #1641

postgresql

  • [postgresql]

Added support for reflecting the DOUBLE PRECISION type,via a new postgres.PGDoublePrecision object.This is postgresql.DOUBLE_PRECISION in 0.6.References: #1085

  • [postgresql]

Added support for reflecting the INTERVAL YEAR TO MONTHand INTERVAL DAY TO SECOND syntaxes of the INTERVALtype.References: #460

  • [postgresql]

Corrected the “has_sequence” query to take current schema,or explicit sequence-stated schema, into account.References: #1576

  • [postgresql]

Fixed the behavior of extract() to apply operatorprecedence rules to the “::” operator when applyingthe “timestamp” cast - ensures proper parenthesization.References: #1611

sqlite

  • [sqlite]

sqlite dialect properly generates CREATE INDEX for a tablethat is in an alternate schema.References: #1439

mssql

  • [mssql]

Changed the name of TrustedConnection toTrusted_Connection when constructing pyodbc connectargumentsReferences: #1561

oracle

  • [oracle]

The “table_names” dialect function, used by MetaData.reflect(), omits “index overflow tables”, a systemtable generated by Oracle when “index only tables”with overflow are used. These tables aren’t accessiblevia SQL and can’t be reflected.References: #1637

misc

  • [ext]

A column can be added to a joined-table declarativesuperclass after the class has been constructed(i.e. via class-level attribute assignment), andthe column will be propagated down tosubclasses. This is the reversesituation as that of, fixed in 0.5.6.References: #1523, #1570

  • [ext]

Fixed a slight inaccuracy in the sharding example.Comparing equivalence of columns in the ORM is bestaccomplished using col1.shares_lineage(col2).References: #1491

  • [ext]

Removed unused load() method from ShardedQuery.References: #1606

0.5.6

Released: Sat Sep 12 2009

orm

  • [orm]

Fixed bug whereby inheritance discriminator part of acomposite primary key would fail on updates.Continuation of.References: #1300

  • [orm]

Fixed bug which disallowed one side of a many-to-manybidirectional reference to declare itself as “viewonly”References: #1507

  • [orm]

Added an assertion that prevents a @validates functionor other AttributeExtension from loading an unloadedcollection such that internal state may be corrupted.References: #1526

  • [orm]

Fixed bug which prevented two entities from mutuallyreplacing each other’s primary key values within a singleflush() for some orderings of operations.References: #1519

  • [orm]

Fixed an obscure issue whereby a joined-table subclasswith a self-referential eager load on the base classwould populate the related object’s “subclass” table withdata from the “subclass” table of the parent.References: #1485

  • [orm]

relations() now have greater ability to be “overridden”,meaning a subclass that explicitly specifies a relation()overriding that of the parent class will be honoredduring a flush. This is currently to supportmany-to-many relations from concrete inheritance setups.Outside of that use case, YMMV.References: #1477

  • [orm]

Squeezed a few more unnecessary “lazy loads” out ofrelation(). When a collection is mutated, many-to-onebackrefs on the other side will not fire off to loadthe “old” value, unless “single_parent=True” is set.A direct assignment of a many-to-one still loadsthe “old” value in order to update backref collectionson that value, which may be present in the sessionalready, thus maintaining the 0.5 behavioral contract.References: #1483

  • [orm]

Fixed bug whereby a load/refresh of joined tableinheritance attributes which were based oncolumn_property() or similar would fail to evaluate.References: #1480

  • [orm]

Improved support for MapperProperty objects overridingthat of an inherited mapper for non-concreteinheritance setups - attribute extensions won’t randomlycollide with each other.References: #1488

  • [orm]

UPDATE and DELETE do not support ORDER BY, LIMIT, OFFSET,etc. in standard SQL. Query.update() and Query.delete()now raise an exception if any of limit(), offset(),order_by(), group_by(), or distinct() have beencalled.References: #1487

  • [orm]

Added AttributeExtension to sqlalchemy.orm.all

  • [orm]

Improved error message when query() is called witha non-SQL /entity expression.References: #1476

  • [orm]

Using False or 0 as a polymorphic discriminator nowworks on the base class as well as a subclass.References: #1440

  • [orm]

Added enable_assertions(False) to Query which disablesthe usual assertions for expected state - usedby Query subclasses to engineer custom state.. Seehttp://www.sqlalchemy.org/trac/wiki/UsageRecipes/PreFilteredQueryfor an example.References: #1424

  • [orm]

Fixed recursion issue which occurred if a mapped object’s_len() or _nonzero() method resulted in statechanges.References: #1501

  • [orm]

Fixed incorrect exception raise inWeak/StrongIdentityMap.add()References: #1506

  • [orm]

Fixed the error message for “could not find a FROM clause”in query.join() which would fail to issue correctlyif the query was against a pure SQL construct.References: #1522

  • [orm]

Fixed a somewhat hypothetical issue which would resultin the wrong primary key being calculated for a mapperusing the old polymorphic_union function - but thisis old stuff.References: #1486

sql

  • [sql]

Fixed column.copy() to copy defaults and onupdates.References: #1373

  • [sql]

Fixed a bug in extract() introduced in 0.5.4 wherebythe string “field” argument was getting treated as aClauseElement, causing various errors within morecomplex SQL transformations.

  • [sql]

Unary expressions such as DISTINCT propagate theirtype handling to result sets, allowing conversions likeunicode and such to take place.References: #1420

  • [sql]

Fixed bug in Table and Column whereby passing emptydict for “info” argument would raise an exception.References: #1482

oracle

  • [oracle]

Backported 0.6 fix for Oracle alias names not gettingtruncated.References: #1309

misc

  • [ext]

The collection proxies produced by associationproxy are nowpickleable. A user-defined proxyfactory howeveris still not pickleable unless it defines getstateand _setstate.References: #1446

  • [ext]

Declarative will raise an informative exception iftable_args is passed as a tuple with no dict argument.Improved documentation.References: #1468

  • [ext]

Table objects declared in the MetaData can now be usedin string expressions sent to primaryjoin/secondaryjoin/secondary - the name is pulled from the MetaData of thedeclarative base.References: #1527

  • [ext]

A column can be added to a joined-table subclass afterthe class has been constructed (i.e. via class-levelattribute assignment). The column is added to the underlyingTable as always, but now the mapper will rebuild its“join” to include the new column, instead of raisingan error about “no such column, use column_property()instead”.References: #1523

  • [test]

Added examples into the test suite so they get exercisedregularly and cleaned up a couple deprecation warnings.

0.5.5

Released: Mon Jul 13 2009

general

  • [general]

unit tests have been migrated from unittest to nose. SeeREADME.unittests for information on how to run the tests.References: #970

orm

  • [orm]

The “foreign_keys” argument of relation() will now propagateautomatically to the backref in the same way that primaryjoinand secondaryjoin do. For the extremely rare use case wherethe backref of a relation() has intentionally different“foreign_keys” configured, both sides now need to beconfigured explicitly (if they do in fact require this setting,see the next note…).

  • [orm]

…the only known (and really, really rare) use case where adifferent foreign_keys setting was used on theforwards/backwards side, a composite foreign key thatpartially points to its own columns, has been enhanced suchthat the fk->itself aspect of the relation won’t be used todetermine relation direction.

  • [orm]

Session.mapper is now deprecated.

Call session.add() if you’d like a free-standing object to bepart of your session. Otherwise, a DIY version ofSession.mapper is now documented athttp://www.sqlalchemy.org/trac/wiki/UsageRecipes/SessionAwareMapperThe method will remain deprecated throughout 0.6.

  • [orm]

Fixed Query being able to join() from individual columns of ajoined-table subclass entity, i.e. query(SubClass.foo,SubClass.bar).join(). In most cases, an error“Could not find a FROM clause to join from” would beraised. In a few others, the result would be returned in termsof the base class rather than the subclass - so applicationswhich relied on this erroneous result need to beadjusted.References: #1431

  • [orm]

Fixed a bug involving contains_eager(), which would applyitself to a secondary (i.e. lazy) load in a particular rarecase, producing cartesian products. improved the targeting ofquery.options() on secondary loads overall.References: #1461

  • [orm]

Fixed bug introduced in 0.5.4 whereby Composite types failwhen default-holding columns are flushed.

  • [orm]

Fixed another 0.5.4 bug whereby mutable attributes(i.e. PickleType) wouldn’t be deserialized correctly when thewhole object was serialized.References: #1426

  • [orm]

Fixed bug whereby session.is_modified() would raise anexception if any synonyms were in use.

  • [orm]

Fixed potential memory leak whereby previously pickled objectsplaced back in a session would not be fully garbage collectedunless the Session were explicitly closed out.

  • [orm]

Fixed bug whereby list-based attributes, like pickletype andPGArray, failed to be merged() properly.

  • [orm]

Repaired non-working attributes.set_committed_value function.

  • [orm]

Trimmed the pickle format for InstanceState which shouldfurther reduce the memory footprint of pickled instances. Theformat should be backwards compatible with that of 0.5.4 andprevious.

  • [orm]

sqlalchemy.orm.join and sqlalchemy.orm.outerjoin are nowadded to all in sqlalchemy.orm.*.References: #1463

  • [orm]

Fixed bug where Query exception raise would fail whena too-short composite primary key value were passed toget().References: #1458

sql

  • [sql]

Removed an obscure feature of execute() (including connection,engine, Session) whereby a bindparam() construct can be sentas a key to the params dictionary. This usage is undocumentedand is at the core of an issue whereby the bindparam() objectcreated implicitly by a text() construct may have the samehash value as a string placed in the params dictionary and mayresult in an inappropriate match when computing the final bindparameters. Internal checks for this condition would addsignificant latency to the critical task of parameterrendering, so the behavior is removed. This is a backwardsincompatible change for any application that may have beenusing this feature, however the feature has never beendocumented.

misc

  • [engine/pool]

Implemented recreate() for StaticPool.

0.5.4p2

Released: Tue May 26 2009

sql

  • [sql]

Repaired the printing of SQL exceptions which are notbased on parameters or are not executemany() style.

postgresql

  • [postgresql]

Deprecated the hardcoded TIMESTAMP function, which whenused as func.TIMESTAMP(value) would render “TIMESTAMP value”.This breaks on some platforms as PostgreSQL doesn’t allowbind parameters to be used in this context. The hard-codeduppercase is also inappropriate and there’s lots of otherPG casts that we’d need to support. So instead, usetext constructs i.e. select([“timestamp ‘12/05/09’”]).

0.5.4p1

Released: Mon May 18 2009

orm

  • [orm]

Fixed an attribute error introduced in 0.5.4 which wouldoccur when merge() was used with an incomplete object.

0.5.4

Released: Sun May 17 2009

orm

  • [orm]

Significant performance enhancements regarding Sessions/flush()in conjunction with large mapper graphs, large numbers ofobjects:

  • Removed all* O(N) scanning behavior from the flush() process,i.e. operations that were scanning the full session,including an extremely expensive one that was erroneouslyassuming primary key values were changing when thiswas not the case.

    • one edge case remains which may invoke a full scan,if an existing primary key attribute is modifiedto a new value.
  • The Session’s “weak referencing” behavior is now full -no strong references whatsoever are made to a mapped objector related items/collections in its dict. Backrefs andother cycles in objects no longer affect the Session’s abilityto lose all references to unmodified objects. Objects withpending changes still are maintained strongly until flush.

The implementation also improves performance by movingthe “resurrection” process of garbage collected itemsto only be relevant for mappings that map “mutable”attributes (i.e. PickleType, composite attrs). This removesoverhead from the gc process and simplifies internalbehavior.

If a “mutable” attribute change is the sole change on an objectwhich is then dereferenced, the mapper will not have access toother attribute state when the UPDATE is issued. This may presentitself differently to some MapperExtensions.

The change also affects the internal attribute API, but notthe AttributeExtension interface nor any of the publiclydocumented attribute functions.

  • The unit of work no longer generates a graph of “dependency”processors for the full graph of mappers during flush(), insteadcreating such processors only for those mappers which representobjects with pending changes. This saves a tremendous numberof method calls in the context of a large interconnectedgraph of mappers.

  • Cached a wasteful “table sort” operation that previouslyoccurred multiple times per flush, also removing significantmethod call count from flush().

  • Other redundant behaviors have been simplified inmapper._save_obj().References: #1398

  • [orm]

Modified query_cls on DynamicAttributeImpl to accept a fullmixin version of the AppenderQuery, which allows subclassingthe AppenderMixin.

  • [orm]

The “polymorphic discriminator” column may be part of aprimary key, and it will be populated with the correctdiscriminator value.References: #1300

  • [orm]

Fixed the evaluator not being able to evaluate IS NULL clauses.

  • [orm]

Fixed the “set collection” function on “dynamic” relations toinitiate events correctly. Previously a collection could onlybe assigned to a pending parent instance, otherwise modifiedevents would not be fired correctly. Set collection is nowcompatible with merge(), fixes.References: #1352

  • [orm]

Allowed pickling of PropertyOption objects constructed withinstrumented descriptors; previously, pickle errors would occurwhen pickling an object which was loaded with a descriptor-basedoption, such as query.options(eagerload(MyClass.foo)).

  • [orm]

Lazy loader will not use get() if the “lazy load” SQL clausematches the clause used by get(), but contains some parametershardcoded. Previously the lazy strategy would fail with theget(). Ideally get() would be used with the hardcodedparameters but this would require further development.References: #1357

  • [orm]

MapperOptions and other state associated with query.options()is no longer bundled within callables associated with eachlazy/deferred-loading attribute during a load.The options are now associated with the instance’sstate object just once when it’s populated. This removesthe need in most cases for per-instance/attribute loaderobjects, improving load speed and memory overhead forindividual instances.References: #1391

  • [orm]

Fixed another location where autoflush was interferingwith session.merge(). autoflush is disabled completelyfor the duration of merge() now.References: #1360

  • [orm]

Fixed bug which prevented “mutable primary key” dependencylogic from functioning properly on a one-to-onerelation().References: #1406

  • [orm]

Fixed bug in relation(), introduced in 0.5.3,whereby a self referential relationfrom a base class to a joined-table subclass wouldnot configure correctly.

  • [orm]

Fixed obscure mapper compilation issue when inheritingmappers are used which would result in un-initializedattributes.

  • [orm]

Fixed documentation for session weak_identity_map -the default value is True, indicating a weakreferencing map in use.

  • [orm]

Fixed a unit of work issue whereby the foreignkey attribute on an item contained within a collectionowned by an object being deleted would not be set toNone if the relation() was self-referential.References: #1376

  • [orm]

Fixed Query.update() and Query.delete() failures with eagerloadedrelations.References: #1378

  • [orm]

It is now an error to specify both columns of a binary primaryjoincondition in the foreign_keys or remote_side collection. Whereaspreviously it was just nonsensical, but would succeed in anon-deterministic way.

sql

  • [sql]

Back-ported the “compiler” extension from SQLA 0.6. Thisis a standardized interface which allows the creation of customClauseElement subclasses and compilers. In particular it’shandy as an alternative to text() when you’d like tobuild a construct that has database-specific compilations.See the extension docs for details.

  • [sql]

Exception messages are truncated when the list of boundparameters is larger than 10, preventing enormousmulti-page exceptions from filling up screens and logfilesfor large executemany() statements.References: #1413

  • [sql]

sqlalchemy.extract() is now dialect sensitive and canextract components of timestamps idiomatically across thesupported databases, including SQLite.

  • [sql]

Fixed repr() and other getcolspec() methods onForeignKey constructed from __clause_element() styleconstruct (i.e. declarative columns).References: #1353

schema

  • [schema] [1341] [ticket: 594]

Added a quote_schema() method to the IdentifierPreparer classso that dialects can override how schemas get handled. Thisenables the MSSQL dialect to treat schemas as multipartidentifiers, such as ‘database.owner’.

mysql

  • [mysql]

Reflecting a FOREIGN KEY construct will take into accounta dotted schema.tablename combination, if the foreign keyreferences a table in a remote schema.References: #1405

sqlite

  • [sqlite]

Corrected the SLBoolean type so that it properly treats only 1as True.References: #1402

  • [sqlite]

Corrected the float type so that it correctly maps to aSLFloat type when being reflected.References: #1273

mssql

  • [mssql]

Modified how savepoint logic works to prevent it fromstepping on non-savepoint oriented routines. Savepointsupport is still very experimental.

  • [mssql]

Added in reserved words for MSSQL that covers version 2008and all prior versions.References: #1310

  • [mssql]

Corrected problem with information schema not working with abinary collation based database. Cleaned up information schemasince it is only used by mssql now.References: #1343

misc

  • [extensions]

Fixed adding of deferred or other column properties to adeclarative class.References: #1379

0.5.3

Released: Tue Mar 24 2009

orm

  • [orm]

The “objects” argument to session.flush() is deprecated.State which represents the linkage between a parent andchild object does not support “flushed” status onone side of the link and not the other, so supportingthis operation leads to misleading results.References: #1315

  • [orm]

Query now implements clause_element() which producesits selectable, which means a Query instance can be acceptedin many SQL expressions, including col.in_(query),union(query1, query2), select([foo]).select_from(query),etc.

  • [orm]

Query.join() can now construct multiple FROM clauses, ifneeded. Such as, query(A, B).join(A.x).join(B.y)might say SELECT A., B. FROM A JOIN X, B JOIN Y.Eager loading can also tack its joins onto thosemultiple FROM clauses.References: #1337

  • [orm]

Fixed bug in dynamic_loader() where append/remove eventsafter construction time were not being propagated to theUOW to pick up on flush().References: #1347

  • [orm]

Fixed bug where column_prefix wasn’t being checked beforenot mapping an attribute that already had class-levelname present.

  • [orm]

a session.expire() on a particular collection attributewill clear any pending backref additions as well, so thatthe next access correctly returns only what was presentin the database. Presents some degree of a workaround for, although we are considering removing theflush([objects]) feature altogether.References: #1315

  • [orm]

Session.scalar() now converts raw SQL strings to text()the same way Session.execute() does and accepts samealternative **kw args.

  • [orm]

improvements to the “determine direction” logic ofrelation() such that the direction of tricky situationslike mapper(A.join(B)) -> relation-> mapper(B) can bedetermined.

  • [orm]

When flushing partial sets of objects using session.flush([somelist]),pending objects which remain pending after the operation won’tinadvertently be added as persistent.References: #1306

  • [orm]

Added “post_configure_attribute” method to InstrumentationManager,so that the “listen_for_events.py” example works again.References: #1314

  • [orm]

a forward and complementing backwards reference which are bothof the same direction, i.e. ONETOMANY or MANYTOONE,is now detected, and an error message is raised.Saves crazy CircularDependencyErrors later on.

  • [orm]

Fixed bugs in Query regarding simultaneous selection ofmultiple joined-table inheritance entities with common baseclasses:

  • previously the adaption applied to “B” on“A JOIN B” would be erroneously partially appliedto “A”.

  • comparisons on relations (i.e. A.related==someb)were not getting adapted when they should.

  • Other filterings, likequery(A).join(A.bs).filter(B.foo==’bar’), were erroneouslyadapting “B.foo” as though it were an “A”.

  • [orm]

Fixed adaptation of EXISTS clauses via any(), has(), etc.in conjunction with an aliased object on the left andof_type() on the right.References: #1325

  • [orm]

Added an attribute helper method set_committed_value insqlalchemy.orm.attributes. Given an object, attribute name,and value, will set the value on the object as part of its“committed” state, i.e. state that is understood to havebeen loaded from the database. Helps with the creation ofhomegrown collection loaders and such.

  • [orm]

Query won’t fail with weakref error when a non-mapper/classinstrumented descriptor is passed, raises“Invalid column expression”.

  • [orm]

Query.group_by() properly takes into account aliasing appliedto the FROM clause, such as with select_from(), usingwith_polymorphic(), or using from_self().

sql

  • [sql]

An alias() of a select() will convert to a “scalar subquery”when used in an unambiguously scalar context, i.e. it’s usedin a comparison operation. This applies tothe ORM when using query.subquery() as well.

  • [sql]

Fixed missing _label attribute on Function object, otherswhen used in a select() with use_labels (such as when usedin an ORM column_property()).References: #1302

  • [sql]

anonymous alias names now truncate down to the max lengthallowed by the dialect. More significant on DBs likeOracle with very small character limits.References: #1309

  • [sql]

the selectable() interface has been replaced entirelyby clause_element().

  • [sql]

The per-dialect cache used by TypeEngine to cachedialect-specific types is now a WeakKeyDictionary.This to prevent dialect objects frombeing referenced forever for an application thatcreates an arbitrarily large number of enginesor dialects. There is a small performance penaltywhich will be resolved in 0.6.References: #1299

postgresql

  • [postgresql]

Index reflection won’t fail when an index withmultiple expressions is encountered.

  • [postgresql]

Added PGUuid and PGBit types tosqlalchemy.databases.postgres.References: #1327

  • [postgresql]

Refection of unknown PG types won’t crash when thosetypes are specified within a domain.References: #1327

sqlite

  • [sqlite]

Fixed SQLite reflection methods so that non-presentcursor.description, which triggers an auto-cursorclose, will be detected so that no results doesn’tfail on recent versions of pysqlite which raisean error when fetchone() called with no rows present.

mssql

  • [mssql]

Preliminary support for pymssql 1.0.1

  • [mssql]

Corrected issue on mssql where max_identifier_length wasnot being respected.

misc

  • [extensions]

Fixed a recursive pickling issue in serializer, triggeredby an EXISTS or other embedded FROM construct.

  • [extensions]

Declarative locates the “inherits” class using a searchthrough bases, to skip over mixins that are localto subclasses.

  • [extensions]

Declarative figures out joined-table inheritance primary joincondition even if “inherits” mapper argument is givenexplicitly.

  • [extensions]

Declarative will properly interpret the “foreign_keys” argumenton a backref() if it’s a string.

  • [extensions]

Declarative will accept a table-bound column as a propertywhen used in conjunction with table, if the column is alreadypresent in table. The column will be remapped to the givenkey the same way as when added to the mapper() properties dict.

0.5.2

Released: Sat Jan 24 2009

orm

  • [orm]

Further refined 0.5.1’s warning about delete-orphan cascadeplaced on a many-to-many relation. First, the bad news:the warning will apply to both many-to-many as well asmany-to-one relations. This is necessary since in bothcases, SQLA does not scan the full set of potential parentswhen determining “orphan” status - for a persistent objectit only detects an in-python de-association event to establishthe object as an “orphan”. Next, the good news: to supportone-to-one via a foreign key or association table, or tosupport one-to-many via an association table, a new flagsingle_parent=True may be set which indicates objectslinked to the relation are only meant to have a single parent.The relation will raise an error if multiple parent-associationevents occur within Python.

  • [orm]

Adjusted the attribute instrumentation change from 0.5.1 tofully establish instrumentation for subclasses where the mapperwas created after the superclass had already been fullyinstrumented.References: #1292

  • [orm]

Fixed bug in delete-orphan cascade whereby two one-to-onerelations from two different parent classes to the same targetclass would prematurely expunge the instance.

  • [orm]

Fixed an eager loading bug whereby self-referential eagerloading would prevent other eager loads, self referential or not,from joining to the parent JOIN properly. Thanks to Alex Kfor creating a great test case.

  • [orm]

session.expire() and related methods will not expire() unloadeddeferred attributes. This prevents them from being needlesslyloaded when the instance is refreshed.

  • [orm]

query.join()/outerjoin() will now properly join an aliased()construct to the existing left side, even if query.from_self()or query.select_from(someselectable) has been called.References: #1293

sql

  • [sql]

    • Further fixes to the “percent signs and spaces in column/table
    • names” functionality.References: #1284

mssql

  • [mssql]

Restored convert_unicode handling. Results were being passedon through without conversion.References: #1291

  • [mssql]

Really fixing the decimal handling this time..References: #1282

  • [mssql] [Ticket:1289]

Modified table reflection code to use only kwargs whenconstructing tables.

0.5.1

Released: Sat Jan 17 2009

orm

  • [orm]

Removed an internal join cache which could potentially leakmemory when issuing query.join() repeatedly to ad-hocselectables.

  • [orm]

The “clear()”, “save()”, “update()”, “save_or_update()”Session methods have been deprecated, replaced by“expunge_all()” and “add()”. “expunge_all()” has alsobeen added to ScopedSession.

  • [orm]

Modernized the “no mapped table” exception and added a moreexplicit table/tablename exception to declarative.

  • [orm]

Concrete inheriting mappers now instrument attributes whichare inherited from the superclass, but are not defined forthe concrete mapper itself, with an InstrumentedAttribute thatissues a descriptive error when accessed.References: #1237

  • [orm]

Added a new relation() keyword back_populates. Thisallows configuration of backreferences using explicitrelations. This is required when creatingbidirectional relations between a hierarchy of concretemappers and another class.References: #1237, #781

  • [orm]

Test coverage added for relation() objects specified onconcrete mappers.References: #1237

  • [orm]

Query.from_self() as well as query.subquery() both disablethe rendering of eager joins inside the subquery produced.The “disable all eager joins” feature is available publiclyvia a new query.enable_eagerloads() generative.References: #1276

  • [orm]

Added a rudimental series of set operations to Query thatreceive Query objects as arguments, including union(),unionall(), intersect(), except(), intersect_all(),except_all(). See the API documentation forQuery.union() for examples.

  • [orm]

Fixed bug that prevented Query.join() and eagerloads fromattaching to a query that selected from a union or aliased union.

  • [orm]

A short documentation example added for bidirectionalrelations specified on concrete mappers.References: #1237

  • [orm]

Mappers now instrument class attributes upon constructionwith the final InstrumentedAttribute object which remainspersistent. The CompileOnAttr/getattribute__()_methodology has been removed. The net effect is thatColumn-based mapped class attributes can now be used fullyat the class level without invoking a mapper compilationoperation, greatly simplifying typical usage patternswithin declarative.References: #1269

  • [orm]

ColumnProperty (and front-end helpers such as deferred) nolonger ignores unknown **keyword arguments.

  • [orm]

Fixed a bug with the unitofwork’s “row switch” mechanism,i.e. the conversion of INSERT/DELETE into an UPDATE, whencombined with joined-table inheritance and an objectwhich contained no defined values for the child table wherean UPDATE with no SET clause would be rendered.

  • [orm]

Using delete-orphan on a many-to-many relation is deprecated.This produces misleading or erroneous results since SQLA doesnot retrieve the full list of “parents” for m2m. To get delete-orphanbehavior with an m2m table, use an explicit association classso that the individual association row is treated as a parent.References: #1281

  • [orm]

delete-orphan cascade always requires delete cascade. Specifyingdelete-orphan without delete now raises a deprecation warning.References: #1281

sql

  • [sql]

Improved the methodology to handling percent signs in columnnames from. Added more tests. MySQL andPostgreSQL dialects still do not issue correct CREATE TABLEstatements for identifiers with percent signs in them.References: #1256

schema

  • [schema]

Index now accepts column-oriented InstrumentedAttributes(i.e. column-based mapped class attributes) as columnarguments.References: #1214

  • [schema]

Column with no name (as in declarative) won’t raise aNoneType error when its string output is requested(such as in a stack trace).

  • [schema]

Fixed bug when overriding a Column with a ForeignKeyon a reflected table, where derived columns (i.e. the“virtual” columns of a select, etc.) would inadvertentlycall upon schema-level cleanup logic intended onlyfor the original column.References: #1278

mysql

  • [mysql]

Added the missing keywords from MySQL 4.1 so they get escapedproperly.

mssql

  • [mssql]

Corrected handling of large decimal values with more robusttests. Removed string manipulation on floats.References: #1280

  • [mssql]

Modified the do_begin handling in mssql to use the Cursor notthe Connection so it is DBAPI compatible.

  • [mssql]

Corrected SAVEPOINT support on adodbapi by changing thehandling of savepoint_release, which is unsupported on mssql.

misc

  • [declarative]

Can now specify Column objects on subclasses which have notable of their own (i.e. use single table inheritance).The columns will be appended to the base table, but onlymapped by the subclass.

  • [declarative]

For both joined and single inheriting subclasses, the subclasswill only map those columns which are already mapped on thesuperclass and those explicit on the subclass. Othercolumns that are present on the Table will be excludedfrom the mapping by default, which can be disabledby passing a blank exclude_properties collection to themapper_args. This is so that single-inheritingclasses which define their own columns are the only classesto map those columns. The effect is actually a more organizedmapping than you’d normally get with explicit mapper()_calls unless you set up the _exclude_properties argumentsexplicitly.

  • [declarative]

It’s an error to add new Column objects to a declarative classthat specified an existing table using table.

0.5.0

Released: Tue Jan 06 2009

general

  • [general]

Documentation has been converted to Sphinx. In particular,the generated API documentation has been constructed into afull blown “API Reference” section which organizes editorialdocumentation combined with generated docstrings. Crosslinking between sections and API docs are vastly improved, ajavascript-powered search feature is provided, and a fullindex of all classes, functions and members is provided.

  • [general]

setup.py now imports setuptools only optionally. If notpresent, distutils is used. The new “pip” installer isrecommended over easy_install as it installs in a moresimplified way.

  • [general]

added an extremely basic illustration of a PostGIS integrationto the examples folder.

orm

  • [orm]

Query.with_polymorphic() now accepts a third argument“discriminator” which will replace the value ofmapper.polymorphic_on for that query. Mappers themselves nolonger require polymorphic_on to be set, even if the mapperhas a polymorphic_identity. When not set, the mapper willload non-polymorphically by default. Together, these twofeatures allow a non-polymorphic concrete inheritance setup touse polymorphic loading on a per-query basis, since concretesetups are prone to many issues when used polymorphically inall cases.

  • [orm]

dynamic_loader accepts a query_class= to customize the Queryclasses used for both the dynamic collection and the queriesbuilt from it.

  • [orm]

query.order_by() accepts None which will remove any pendingorder_by state from the query, as well as cancel out anymapper/relation configured ordering. This is primarily usefulfor overriding the ordering specified on a dynamic_loader().References: #1079

  • [orm]

Exceptions raised during compile_mappers() are now preservedto provide “sticky behavior” - if a hasattr() call on apre-compiled mapped attribute triggers a failing compile andsuppresses the exception, subsequent compilation is blockedand the exception will be reiterated on the next compile()call. This issue occurs frequently when using declarative.

  • [orm]

property.of_type() is now recognized on a single-tableinheriting target, when used in the context ofprop.of_type(..).any()/has(), as well asquery.join(prop.of_type(…)).

  • [orm]

query.join() raises an error when the target of the joindoesn’t match the property-based attribute - while it’sunlikely anyone is doing this, the SQLAlchemy author wasguilty of this particular loosey-goosey behavior.

  • [orm]

Fixed bug when using weak_instance_map=False where modifiedevents would not be intercepted for a flush().References: #1272

  • [orm]

Fixed some deep “column correspondence” issues which couldimpact a Query made against a selectable containing multipleversions of the same table, as well as unions and similarwhich contained the same table columns in different columnpositions at different levels.References: #1268

  • [orm]

Custom comparator classes used in conjunction withcolumnproperty(), relation() etc. can define new comparisonmethods on the Comparator, which will become available via_getattr() on the InstrumentedAttribute. In the case ofsynonym() or comparable_property(), attributes are resolvedfirst on the user-defined descriptor, then on the user-definedcomparator.

  • [orm]

Added ScopedSession.is_active accessor.References: #976

  • [orm]

Can pass mapped attributes and column objects as keys toquery.update({}).References: #1262

  • [orm]

Mapped attributes passed to the values() of an expressionlevel insert() or update() will use the keys of the mappedcolumns, not that of the mapped attribute.

  • [orm]

Corrected problem with Query.delete() and Query.update() notworking properly with bind parameters.References: #1242

  • [orm]

Query.select_from(), from_statement() ensure that the givenargument is a FromClause, or Text/Select/Union, respectively.

  • [orm]

Query() can be passed a “composite” attribute as a columnexpression and it will be expanded. Somewhat related to.References: #1253

  • [orm]

Query() is a little more robust when passed various columnexpressions such as strings, clauselists, text() constructs(which may mean it just raises an error more nicely).

  • [orm]

first() works as expected with Query.from_statement().

  • [orm]

Fixed bug introduced in 0.5rc4 involving eager loading notfunctioning for properties which were added to a mapperpost-compile using add_property() or equivalent.

  • [orm]

Fixed bug where many-to-many relation() with viewonly=Truewould not correctly reference the link betweensecondary->remote.

  • [orm]

Duplicate items in a list-based collection will be maintainedwhen issuing INSERTs to a “secondary” table in a many-to-manyrelation. Assuming the m2m table has a unique or primary keyconstraint on it, this will raise the expected constraintviolation instead of silently dropping the duplicateentries. Note that the old behavior remains for a one-to-manyrelation since collection entries in that case don’t result inINSERT statements and SQLA doesn’t manually policecollections.References: #1232

  • [orm]

Query.add_column() can accept FromClause objects in the samemanner as session.query() can.

  • [orm]

Comparison of many-to-one relation to NULL is properlyconverted to IS NOT NULL based on not_().

  • [orm]

Extra checks added to ensure explicitprimaryjoin/secondaryjoin are ClauseElement instances, toprevent more confusing errors later on.References: #1087

  • [orm]

Improved mapper() check for non-class classes.References: #1236

  • [orm]

comparator_factory argument is now documented and supported byall MapperProperty types, including column_property(),relation(), backref(), and synonym().References: #5051

  • [orm]

Changed the name of PropertyLoader to RelationProperty, to beconsistent with all the other names. PropertyLoader is stillpresent as a synonym.

  • [orm]

fixed “double iter()” call causing bus errors in shard API,removed errant result.close() left over from the 0.4version.References: #1099, #1228

  • [orm]

made Session.merge cascades not trigger autoflush. Fixesmerged instances getting prematurely inserted with missingvalues.

  • [orm]

Two fixes to help prevent out-of-band columns from beingrendered in polymorphic_union inheritance scenarios (whichthen causes extra tables to be rendered in the FROM clausecausing cartesian products):

  • improvements to “column adaption” for a->b->c inheritancesituations to better locate columns that are related toone another via multiple levels of indirection, ratherthan rendering the non-adapted column.

  • the “polymorphic discriminator” column is only renderedfor the actual mapper being queried against. The columnwon’t be “pulled in” from a subclass or superclass mappersince it’s not needed.

  • [orm]

Fixed shard_id argument on ShardedSession.execute().References: #1072

sql

  • [sql]

RowProxy objects can be used in place of dictionary argumentssent to connection.execute() and friends.References: #935

  • [sql]

Columns can again contain percent signs within theirnames.References: #1256

  • [sql]

sqlalchemy.sql.expression.Function is now a public class. Itcan be subclassed to provide user-defined SQL functions in animperative style, including with pre-established behaviors.The postgis.py example illustrates one usage of this.

  • [sql]

PickleType now favors == comparison by default, if theincoming object (such as a dict) implements eq(). If theobject does not implement eq() and mutable=True, adeprecation warning is raised.

  • [sql]

Fixed the import weirdness in sqlalchemy.sql to not exportnames.References: #1215

  • [sql]

Using the same ForeignKey object repeatedly raises an errorinstead of silently failing later.References: #1238

  • [sql]

Added NotImplementedError for params() method onInsert/Update/Delete constructs. These items currently don’tsupport this functionality, which also would be a littlemisleading compared to values().

  • [sql]

Reflected foreign keys will properly locate their referencedcolumn, even if the column was given a “key” attributedifferent from the reflected name. This is achieved via a newflag on ForeignKey/ForeignKeyConstraint called “link_to_name”,if True means the given name is the referred-to column’s name,not its assigned key.References: #650

  • [sql]

select() can accept a ClauseList as a column in the same wayas a Table or other selectable and the interior expressionswill be used as column elements.References: #1253

  • [sql]

the “passive” flag on session.is_modified() is correctlypropagated to the attribute manager.

  • [sql]

union() and union_all() will not whack any order_by() that hasbeen applied to the select()s inside. If you union() aselect() with order_by() (presumably to support LIMIT/OFFSET),you should also call self_group() on it to apply parenthesis.

mysql

  • [mysql]

“%” signs in text() constructs are automatically escaped to“%%”. Because of the backwards incompatible nature of thischange, a warning is emitted if ‘%%’ is detected in thestring.

  • [mysql]

Fixed bug in exception raise when FK columns not presentduring reflection.References: #1241

  • [mysql]

Fixed bug involving reflection of a remote-schema table with aforeign key ref to another table in that schema.

sqlite

  • [sqlite]

Table reflection now stores the actual DefaultClause value forthe column.References: #1266

  • [sqlite]

bugfixes, behavioral changes

mssql

  • [mssql]

Added in a new MSGenericBinary type. This maps to the Binarytype so it can implement the specialized behavior of treatinglength specified types as fixed-width Binary types andnon-length types as an unbound variable length Binary type.

  • [mssql]

Added in new types: MSVarBinary and MSImage.References: #1249

  • [mssql]

Added in the MSReal, MSNText, MSSmallDateTime, MSTime,MSDateTimeOffset, and MSDateTime2 types

  • [mssql]

Refactored the Date/Time types. The smalldatetime datatype no longer truncates to a date only, and will now bemapped to the MSSmallDateTime type.References: #1254

  • [mssql]

Corrected an issue with Numerics to accept an int.

  • [mssql]

Mapped char_length to the LEN() function.

  • [mssql]

If an INSERT includes a subselect the INSERT isconverted from an INSERT INTO VALUES construct to aINSERT INTO SELECT construct.

  • [mssql]

If the column is part of a primary_key it will be NOTNULL since MSSQL doesn’t allow NULL in primary_keycolumns.

  • [mssql]

MSBinary now returns a BINARY instead of anIMAGE. This is a backwards incompatible change in thatBINARY is a fixed length data type whereas IMAGE is avariable length data type.References: #1249

  • [mssql]

get_default_schema_name is now reflected from the databasebased on the user’s default schema. This only works with MSSQL2005 and later.References: #1258

  • [mssql]

Added collation support through the use of a new collationargument. This is supported on the following types: char,nchar, varchar, nvarchar, text, ntext.References: #1248

  • [mssql]

Changes to the connection string parameters favor DSN as thedefault specification for pyodbc. See the mssql.py docstringfor detailed usage instructions.

  • [mssql]

Added experimental support of savepoints. It currently doesnot work fully with sessions.

  • [mssql]

Support for three levels of column nullability: NULL, NOTNULL, and the database’s configured default. The defaultColumn configuration (nullable=True) will now generate NULL inthe DDL. Previously no specification was emitted and thedatabase default would take effect (usually NULL, but notalways). To explicitly request the database default,configure columns with nullable=None and no specification willbe emitted in DDL. This is backwards incompatiblebehavior.References: #1243

oracle

  • [oracle]

Adjusted the format of create_xid() to repair two-phasecommit. We now have field reports of Oracle two-phase commitworking properly with this change.

  • [oracle]

Added OracleNVarchar type, produces NVARCHAR2, and alsosubclasses Unicode so that convert_unicode=True by default.NVARCHAR2 reflects into this type automatically so thesecolumns pass unicode on a reflected table with no explicitconvert_unicode=True flags.References: #1233

  • [oracle]

Fixed bug which was preventing out params of certain typesfrom being received; thanks a ton to huddlej at wwu.edu !References: #1265

misc

  • [dialect]

Added a new description_encoding attribute on the dialect thatis used for encoding the column name when processing themetadata. This usually defaults to utf-8.

  • [engine/pool]

Connection.invalidate() checks for closed status to avoidattribute errors.References: #1246

  • [engine/pool]

NullPool supports reconnect on failure behavior.References: #1094

  • [engine/pool]

Added a mutex for the initial pool creation when usingpool.manage(dbapi). This prevents a minor case of “dogpile”behavior which would otherwise occur upon a heavy loadstartup.References: #799

  • [engine/pool]

_execute_clauseelement() goes back to being a private method.Subclassing Connection is not needed now that ConnectionProxyis available.

  • [documentation]

Tickets.References: #1149, #1200

  • [documentation]

Added note about create_session() defaults.

  • [documentation]

Added section about metadata.reflect().

  • [documentation]

Updated TypeDecorator section.

  • [documentation]

Rewrote the “threadlocal” strategy section of the docs due torecent confusion over this feature.

  • [documentation]

Removed badly out of date ‘polymorphic_fetch’ and‘select_table’ docs from inheritance, reworked the second halfof “joined table inheritance”.

  • [documentation]

Documented comparator_factory kwarg, added new doc section“Custom Comparators”.

  • [postgres]

“%” signs in text() constructs are automatically escaped to“%%”. Because of the backwards incompatible nature of thischange, a warning is emitted if ‘%%’ is detected in thestring.References: #1267

  • [postgres]

Calling alias.execute() in conjunction withserver_side_cursors won’t raise AttributeError.

  • [postgres]

Added Index reflection support to PostgreSQL, using a greatpatch we long neglected, submitted by KenKuhlman.References: #714

  • [associationproxy]

The association proxy properties are make themselves availableat the class level, e.g. MyClass.aproxy. Previously thisevaluated to None.

  • [declarative]

The full list of arguments accepted as string by backref()includes ‘primaryjoin’, ‘secondaryjoin’, ‘secondary’,‘foreign_keys’, ‘remote_side’, ‘order_by’.

0.5.0rc4

Released: Fri Nov 14 2008

general

  • [general]

global “propigate”->”propagate” change.

orm

  • [orm]

Query.count() has been enhanced to do the “right thing” in awider variety of cases. It can now count multiple-entityqueries, as well as column-based queries. Note that this meansif you say query(A, B).count() without any joining criterion,it’s going to count the cartesian product of A*B. Any querywhich is against column-based entities will automaticallyissue “SELECT count(1) FROM (SELECT…)” so that the realrowcount is returned, meaning a query such asquery(func.count(A.name)).count() will return a value of one,since that query would return one row.

  • [orm]

Lots of performance tuning. A rough guesstimate over variousORM operations places it 10% faster over 0.5.0rc3, 25-30% over0.4.8.

  • [orm]

bugfixes and behavioral changes

  • [orm]

Adjustments to the enhanced garbage collection onInstanceState to better guard against errors due to loststate.

  • [orm]

Query.get() returns a more informative error message whenexecuted against multiple entities.References: #1220

  • [orm]

Restored NotImplementedError on Cls.relation.in_()References: #1140, #1221

  • [orm]

Fixed PendingDeprecationWarning involving order_by parameteron relation().References: #1226

sql

  • [sql]

Removed the ‘properties’ attribute of the Connection object,Connection.info should be used.

  • [sql]

Restored “active rowcount” fetch before ResultProxy autoclosesthe cursor. This was removed in 0.5rc3.

  • [sql]

Rearranged the load_dialect_impl() method in TypeDecorator_such that it will take effect even if the user-defined_TypeDecorator uses another TypeDecorator as its impl.

mssql

  • [mssql]

Lots of cleanup and fixes to correct problems with limit andoffset.

  • [mssql]

Correct situation where subqueries as part of a binaryexpression need to be translated to use the IN and NOT INsyntax.

  • [mssql]

Fixed E Notation issue that prevented the ability to insertdecimal values less than 1E-6.References: #1216

  • [mssql]

Corrected problems with reflection when dealing with schemas,particularly when those schemas are the defaultschema.References: #1217

  • [mssql]

Corrected problem with casting a zero length item to avarchar. It now correctly adjusts the CAST.

misc

  • [access]

Added support for Currency type.

  • [access]

Functions were not return their result.References: #1017

  • [access]

Corrected problem with joins. Access only support LEFT OUTERor INNER not just JOIN by itself.References: #1017

  • [ext]

Can now use a custom “inherit_condition” in mapper_argswhen using declarative.

  • [ext]

fixed string-based “remote_side”, “order_by” and others notpropagating correctly when used in backref().

0.5.0rc3

Released: Fri Nov 07 2008

orm

  • [orm]

Added two new hooks to SessionExtension: after_bulk_delete()and after_bulk_update(). after_bulk_delete() is called aftera bulk delete() operation on a query. after_bulk_update() iscalled after a bulk update() operation on a query.

  • [orm]

“not equals” comparisons of simple many-to-one relation to aninstance will not drop into an EXISTS clause and will compareforeign key columns instead.

  • [orm]

Removed not-really-working use cases of comparing a collectionto an iterable. Use contains() to test for collectionmembership.

  • [orm]

Improved the behavior of aliased() objects such that they moreaccurately adapt the expressions generated, which helpsparticularly with self-referential comparisons.References: #1171

  • [orm]

Fixed bug involving primaryjoin/secondaryjoin conditionsconstructed from class-bound attributes (as often occurs whenusing declarative), which later would be inappropriatelyaliased by Query, particularly with the various EXISTS basedcomparators.

  • [orm]

Fixed bug when using multiple query.join() with analiased-bound descriptor which would lose the left alias.

  • [orm]

Improved weakref identity map memory management to no longerrequire mutexing, resurrects garbage collected instance on alazy basis for an InstanceState with pending changes.

  • [orm]

InstanceState object now removes circular references to itselfupon disposal to keep it outside of cyclic garbage collection.

  • [orm]

relation() won’t hide unrelated ForeignKey errors inside ofthe “please specify primaryjoin” message when determining joincondition.

  • [orm]

Fixed bug in Query involving order_by() in conjunction withmultiple aliases of the same class (will add tests in)References: #1218

  • [orm]

When using Query.join() with an explicit clause for the ONclause, the clause will be aliased in terms of the left sideof the join, allowing scenarios like query(Source).from_self().join((Dest, Source.id==Dest.source_id)) to workproperly.

  • [orm]

polymorphic_union() function respects the “key” of each Columnif they differ from the column’s name.

  • [orm]

Repaired support for “passive-deletes” on a many-to-onerelation() with “delete” cascade.References: #1183

  • [orm]

Fixed bug in composite types which prevented a primary-keycomposite type from being mutated.References: #1213

  • [orm]

Added more granularity to internal attribute access, such thatcascade and flush operations will not initialize unloadedattributes and collections, leaving them intact for alazy-load later on. Backref events still initialize attributesand collections for pending instances.References: #1202

sql

  • [sql]

SQL compiler optimizations and complexity reduction. The callcount for compiling a typical select() construct is 20% lessversus 0.5.0rc2.

  • [sql]

Dialects can now generate label names of adjustablelength. Pass in the argument “label_length=” tocreate_engine() to adjust how many characters max will bepresent in dynamically generated column labels, i.e.“somecolumn AS somelabel”. Any value less than 6 will resultin a label of minimal size, consisting of an underscore and anumeric counter. The compiler uses the value ofdialect.max_identifier_length as a default.References: #1211

  • [sql]

Simplified the check for ResultProxy “autoclose withoutresults” to be based solely on presence ofcursor.description. All the regexp-based guessing aboutstatements returning rows has been removed.References: #1212

  • [sql]

Direct execution of a union() construct will properly set upresult-row processing.References: #1194

  • [sql]

The internal notion of an “OID” or “ROWID” column has beenremoved. It’s basically not used by any dialect, and thepossibility of its usage with psycopg2’s cursor.lastrowid isbasically gone now that INSERT..RETURNING is available.

  • [sql]

Removed “default_order_by()” method on all FromClause objects.

  • [sql]

Repaired the table.tometadata() method so that a passed-inschema argument is propagated to ForeignKey constructs.

  • [sql]

Slightly changed behavior of IN operator for comparing toempty collections. Now results in inequality comparisonagainst self. More portable, but breaks with stored proceduresthat aren’t pure functions.

mysql

  • [mysql]

Fixed foreign key reflection in the edge case where a Table’sexplicit schema= is the same as the schema (database) theconnection is attached to.

  • [mysql]

No longer expects include_columns in table reflection to belower case.

oracle

  • [oracle]

Wrote a docstring for Oracle dialect. Apparently that Ohloh“few source code comments” label is starting to sting :).

  • [oracle]

Removed FIRST_ROWS() optimize flag when using LIMIT/OFFSET,can be reenabled with optimize_limits=True create_engine()flag.References: #536

  • [oracle]

bugfixes and behavioral changes

  • [oracle]

Setting the auto_convert_lobs to False on create_engine() willalso instruct the OracleBinary type to return the cx_oracleLOB object unchanged.

misc

  • [ext]

Added a new extension sqlalchemy.ext.serializer. ProvidesSerializer/Deserializer “classes” which mirrorPickle/Unpickle, as well as dumps() and loads(). Thisserializer implements an “external object” pickler which keepskey context-sensitive objects, including engines, sessions,metadata, Tables/Columns, and mappers, outside of the picklestream, and can later restore the pickle using anyengine/metadata/session provider. This is used not forpickling regular object instances, which are pickleablewithout any special logic, but for pickling expression objectsand full Query objects, such that all mapper/engine/sessiondependencies can be restored at unpickle time.

  • [ext]

Fixed bug preventing declarative-bound “column” objects frombeing used in column_mapped_collection().References: #1174

  • [misc]

util.flatteniterator() func doesn’t interpret strings with_iter() methods as iterators, such as in pypy.References: #1077

0.5.0rc2

Released: Sun Oct 12 2008

orm

  • [orm]

Fixed bug involving read/write relation()s that containliteral or other non-column expressions within theirprimaryjoin condition equated to a foreign key column.

  • [orm]

“non-batch” mode in mapper(), a feature which allows mapperextension methods to be called as each instance isupdated/inserted, now honors the insert order of the objectsgiven.

  • [orm]

Fixed RLock-related bug in mapper which could deadlock uponreentrant mapper compile() calls, something that occurs whenusing declarative constructs inside of ForeignKey objects.

  • [orm]

ScopedSession.query_property now accepts a query_cls factory,overriding the session’s configured query_cls.

  • [orm]

Fixed shared state bug interfering with ScopedSession.mapper’sability to apply default init implementations on objectsubclasses.

  • [orm]

Fixed up slices on Query (i.e. query[x:y]) to work properlyfor zero length slices, slices with None on either end.References: #1177

  • [orm]

Added an example illustrating Celko’s “nested sets” as aSQLA mapping.

  • [orm]

contains_eager() with an alias argument works even whenthe alias is embedded in a SELECT, as when sent to theQuery via query.select_from().

  • [orm]

contains_eager() usage is now compatible with a Query thatalso contains a regular eager load and limit/offset, in thatthe columns are added to the Query-generated subquery.References: #1180

  • [orm]

session.execute() will execute a Sequence object passed toit (regression from 0.4).

  • [orm]

Removed the “raiseerror” keyword argument from object_mapper()and class_mapper(). These functions raise in all casesif the given class/instance is not mapped.

  • [orm]

Fixed session.transaction.commit() on a autocommit=Falsesession not starting a new transaction.

  • [orm]

Some adjustments to Session.identity_map’s weak referencingbehavior to reduce asynchronous GC side effects.

  • [orm]

Adjustment to Session’s post-flush accounting of newly“clean” objects to better protect against operating onobjects as they’re asynchronously gc’ed.References: #1182

sql

  • [sql]

column.in_(someselect) can now be used as a columns-clauseexpression without the subquery bleeding into the FROM clauseReferences: #1074

mysql

  • [mysql]

Temporary tables are now reflectable.

sqlite

  • [sqlite]

Overhauled SQLite date/time bind/result processing to useregular expressions and format strings, rather thanstrptime/strftime, to generically support pre-1900 dates,dates with microseconds.References: #968

  • [sqlite]

String’s (and Unicode’s, UnicodeText’s, etc.) convert_unicodelogic disabled in the sqlite dialect, to adjust for pysqlite2.5.0’s new requirement that only Python unicode objects areaccepted;http://itsystementwicklung.de/pipermail/list-pysqlite/2008-March/000018.html

oracle

  • [oracle]

Oracle will detect string-based statements which containcomments at the front before a SELECT as SELECT statements.References: #1187

0.5.0rc1

Released: Thu Sep 11 2008

orm

  • [orm]

Query now has delete() and update(values) methods. This allowsto perform bulk deletes/updates with the Query object.

  • [orm]

The RowTuple object returned by Query(*cols) now featureskeynames which prefer mapped attribute names over column keys,column keys over column names, i.e. Query(Class.foo,Class.bar) will have names “foo” and “bar” even if those arenot the names of the underlying Column objects. Direct Columnobjects such as Query(table.c.col) will return the “key”attribute of the Column.

  • [orm]

Added scalar() and value() methods to Query, each return asingle scalar value. scalar() takes no arguments and isroughly equivalent to first()[0], value()takes a single column expression and is roughly equivalent tovalues(expr).next()[0].

  • [orm]

Improved the determination of the FROM clause when placing SQLexpressions in the query() list of entities. In particularscalar subqueries should not “leak” their inner FROM objectsout into the enclosing query.

  • [orm]

Joins along a relation() from a mapped class to a mappedsubclass, where the mapped subclass is configured with singletable inheritance, will include an IN clause which limits thesubtypes of the joined class to those requested, within the ONclause of the join. This takes effect for eager load joins aswell as query.join(). Note that in some scenarios the INclause will appear in the WHERE clause of the query as wellsince this discrimination has multiple trigger points.

  • [orm]

AttributeExtension has been refined such that the eventis fired before the mutation actually occurs. Additionally,the append() and set() methods must now return the given value,which is used as the value to be used in the mutation operation.This allows creation of validating AttributeListeners whichraise before the action actually occurs, and which can changethe given value into something else before its used.

  • [orm]

column_property(), composite_property(), and relation() nowaccept a single or list of AttributeExtensions using the“extension” keyword argument.

  • [orm]

query.order_by().get() silently drops the “ORDER BY” fromthe query issued by GET but does not raise an exception.

  • [orm]

Added a Validator AttributeExtension, as well as a@validates decorator which is used in a similar fashionas @reconstructor, and marks a method as validatingone or more mapped attributes.

  • [orm]

class.someprop.in() raises NotImplementedError pending theimplementation of “in” for relationReferences: #1140

  • [orm]

Fixed primary key update for many-to-many collections wherethe collection had not been loaded yetReferences: #1127

  • [orm]

Fixed bug whereby deferred() columns with a group in conjunctionwith an otherwise unrelated synonym() would producean AttributeError during deferred load.

  • [orm]

The before_flush() hook on SessionExtension takes place beforethe list of new/dirty/deleted is calculated for the finaltime, allowing routines within before_flush() to furtherchange the state of the Session before the flush proceeds.References: #1128

  • [orm]

The “extension” argument to Session and others can nowoptionally be a list, supporting events sent to multipleSessionExtension instances. Session places SessionExtensionsin Session.extensions.

  • [orm]

Reentrant calls to flush() raise an error. This also servesas a rudimentary, but not foolproof, check against concurrentcalls to Session.flush().

  • [orm]

Improved the behavior of query.join() when joining tojoined-table inheritance subclasses, using explicit joincriteria (i.e. not on a relation).

  • [orm]

@orm.attributes.reconstitute andMapperExtension.reconstitute have been renamed to@orm.reconstructor and MapperExtension.reconstruct_instance

  • [orm]

Fixed @reconstructor hook for subclasses which inherit from abase class.References: #1129

  • [orm]

The composite() property type now supports aset_composite_values() method on the composite class whichis required if the class represents state using attributenames other than the column’s keynames; default-generatedvalues now get populated properly upon flush. Also,composites with attributes set to None compare correctly.References: #1132

  • [orm]

The 3-tuple of iterables returned by attributes.get_history()may now be a mix of lists and tuples. (Previously memberswere always lists.)

  • [orm]

Fixed bug whereby changing a primary key attribute on anentity where the attribute’s previous value had been expiredwould produce an error upon flush().References: #1151

  • [orm]

Fixed custom instrumentation bug whereby get_instance_dict()was not called for newly constructed instances not loadedby the ORM.

  • [orm]

Session.delete() adds the given object to the session ifnot already present. This was a regression bug from 0.4.References: #1150

  • [orm]

The echo_uow flag on Session is deprecated, and unit-of-worklogging is now application-level only, not per-session level.

  • [orm]

Removed conflicting contains() operator fromInstrumentedAttribute which didn’t accept escape kwaarg.References: #1153

sql

  • [sql]

Temporarily rolled back the “ORDER BY” enhancement from. This feature is on hold pending furtherdevelopment.References: #1068

  • [sql]

The exists() construct won’t “export” its contained listof elements as FROM clauses, allowing them to be used moreeffectively in the columns clause of a SELECT.

  • [sql]

and() and or() now generate a ColumnElement, allowingboolean expressions as result columns, i.e.select([and_(1, 0)]).References: #798

  • [sql]

Bind params now subclass ColumnElement which allows them to beselectable by orm.query (they already had most ColumnElementsemantics).

  • [sql]

Added select_from() method to exists() construct, which becomesmore and more compatible with a regular select().

  • [sql]

Added func.min(), func.max(), func.sum() as “generic functions”,which basically allows for their return type to be determinedautomatically. Helps with dates on SQLite, decimal types,others.References: #1160

  • [sql]

added decimal.Decimal as an “auto-detect” type; bind parametersand generic functions will set their type to Numeric when aDecimal is used.

schema

  • [schema]

Added “sorted_tables” accessor to MetaData, which returnsTable objects sorted in order of dependency as a list.This deprecates the MetaData.table_iterator() method.The “reverse=False” keyword argument has also beenremoved from util.sort_tables(); use the Python‘reversed’ function to reverse the results.References: #1033

  • [schema]

The ‘length’ argument to all Numeric types has been renamedto ‘scale’. ‘length’ is deprecated and is still acceptedwith a warning.

  • [schema]

Dropped 0.3-compatibility for user defined types(convert_result_value, convert_bind_param).

mysql

  • [mysql]

The ‘length’ argument to MSInteger, MSBigInteger, MSTinyInteger,MSSmallInteger and MSYear has been renamed to ‘display_width’.

  • [mysql]

Added MSMediumInteger type.References: #1146

  • [mysql]

the function func.utc_timestamp() compiles to UTC_TIMESTAMP, withoutthe parenthesis, which seem to get in the way when using inconjunction with executemany().

oracle

  • [oracle]

limit/offset no longer uses ROW NUMBER OVER to limit rows,and instead uses subqueries in conjunction with a specialOracle optimization comment. Allows LIMIT/OFFSET to workin conjunction with DISTINCT.References: #536

  • [oracle]

has_sequence() now takes the current “schema” argument intoaccountReferences: #1155

  • [oracle]

added BFILE to reflected type namesReferences: #1121

misc

  • [declarative]

Fixed bug whereby mapper couldn’t initialize if a compositeprimary key referenced another table that was not definedyet.References: #1161

  • [declarative]

Fixed exception throw which would occur when string-basedprimaryjoin condition was used in conjunction with backref.

0.5.0beta3

Released: Mon Aug 04 2008

orm

  • [orm]

The “entity_name” feature of SQLAlchemy mappers has beenremoved. For rationale, see http://tinyurl.com/6nm2ne

  • [orm]

the “autoexpire” flag on Session, sessionmaker(), andscoped_session() has been renamed to “expire_on_commit”. Itdoes not affect the expiration behavior of rollback().

  • [orm]

fixed endless loop bug which could occur within a mapper’sdeferred load of inherited attributes.

  • [orm]

a legacy-support flag “_enable_transaction_accounting” flagadded to Session which when False, disables alltransaction-level object accounting, including expire onrollback, expire on commit, new/deleted list maintenance, andautoflush on begin.

  • [orm]

The ‘cascade’ parameter to relation() accepts None as a value,which is equivalent to no cascades.

  • [orm]

A critical fix to dynamic relations allows the “modified”history to be properly cleared after a flush().

  • [orm]

user-defined @properties on a class are detected and left inplace during mapper initialization. This means that atable-bound column of the same name will not be mapped at allif a @property is in the way (and the column is not remappedto a different name), nor will an instrumented attribute froman inherited class be applied. The same rules apply for namesexcluded using the include_properties/exclude_propertiescollections.

  • [orm]

Added a new SessionExtension hook called after_attach(). Thisis called at the point of attachment for objects via add(),add_all(), delete(), and merge().

  • [orm]

A mapper which inherits from another, when inheriting thecolumns of its inherited mapper, will use any reassignedproperty names specified in that inheriting mapper.Previously, if “Base” had reassigned “base_id” to the name“id”, “SubBase(Base)” would still get an attribute called“base_id”. This could be worked around by explicitly statingthe column in each submapper as well but this is fairlyunworkable and also impossible when using declarative.References: #1111

  • [orm]

Fixed a series of potential race conditions in Session wherebyasynchronous GC could remove unmodified, no longer referenceditems from the session as they were present in a list of itemsto be processed, typically during session.expunge_all() anddependent methods.

  • [orm]

Some improvements to the _CompileOnAttr mechanism which shouldreduce the probability of “Attribute x was not replaced duringcompile” warnings. (this generally applies to SQLA hackers,like Elixir devs).

  • [orm]

Fixed bug whereby the “unsaved, pending instance” FlushErrorraised for a pending orphan would not take superclass mappersinto account when generating the list of relations responsiblefor the error.

sql

  • [sql]

func.count() with no arguments renders as COUNT(), equivalentto func.count(text(‘’)).

  • [sql]

simple label names in ORDER BY expressions render asthemselves, and not as a re-statement of their correspondingexpression. This feature is currently enabled only forSQLite, MySQL, and PostgreSQL. It can be enabled on otherdialects as each is shown to support thisbehavior.References: #1068

mysql

  • [mysql]

Quoting of MSEnum values for use in CREATE TABLE is nowoptional & will be quoted on demand as required. (Quoting wasalways optional for use with existing tables.)References: #1110

misc

  • [ext]

Class-bound attributes sent as arguments to relation()’sremote_side and foreign_keys parameters are now accepted,allowing them to be used with declarative. Additionally fixedbugs involving order_by being specified as a class-boundattribute in conjunction with eager loading.

  • [ext]

declarative initialization of Columns adjusted so thatnon-renamed columns initialize in the same way as a nondeclarative mapper. This allows an inheriting mapper to setup its same-named “id” columns in particular such that theparent “id” column is favored over the child column, reducingdatabase round trips when this value is requested.

0.5.0beta2

Released: Mon Jul 14 2008

orm

  • [orm]

In addition to expired attributes, deferred attributes alsoload if their data is present in the result set.References: #870

  • [orm]

session.refresh() raises an informative error message if thelist of attributes does not include any column-basedattributes.

  • [orm]

query() raises an informative error message if no columns ormappers are specified.

  • [orm]

lazy loaders now trigger autoflush before proceeding. Thisallows expire() of a collection or scalar relation to functionproperly in the context of autoflush.

  • [orm]

column_property() attributes which represent SQL expressionsor columns that are not present in the mapped tables (such asthose from views) are automatically expired after an INSERT orUPDATE, assuming they have not been locally modified, so thatthey are refreshed with the most recent data upon access.References: #887

  • [orm]

Fixed explicit, self-referential joins between twojoined-table inheritance mappers when using query.join(cls,aliased=True).References: #1082

  • [orm]

Fixed query.join() when used in conjunction with acolumns-only clause and a SQL-expression ON clause in thejoin.

  • [orm]

The “allow_column_override” flag from mapper() has beenremoved. This flag is virtually always misunderstood. Itsspecific functionality is available via theinclude_properties/exclude_properties mapper arguments.

  • [orm]

Repaired _str()_ method on Query.References: #1066

  • [orm]

Session.bind gets used as a default even when table/mapperspecific binds are defined.

sql

  • [sql]

Added new match() operator that performs a full-text search.Supported on PostgreSQL, SQLite, MySQL, MS-SQL, and Oraclebackends.

schema

  • [schema]

Added prefixes option to Table that accepts a list ofstrings to insert after CREATE in the CREATE TABLE statement.References: #1075

  • [schema]

Unicode, UnicodeText types now set “assert_unicode” and“convert_unicode” by default, but accept overriding**kwargs for these values.

sqlite

  • [sqlite]

Modified SQLite’s representation of “microseconds” to matchthe output of str(somedatetime), i.e. in that the microsecondsare represented as fractional seconds in string format. Thismakes SQLA’s SQLite date type compatible with datetimes thatwere saved directly using Pysqlite (which just calls str()).Note that this is incompatible with the existing microsecondsvalues in a SQLA 0.4 generated SQLite database file.

To get the old behavior globally:

from sqlalchemy.databases.sqlite import DateTimeMixinDateTimeMixin.legacy_microseconds = True

To get the behavior on individual DateTime types:

t = sqlite.SLDateTime()t.legacy_microseconds = True

Then use “t” as the type on the Column.References: #1090

  • [sqlite]

SQLite Date, DateTime, and Time types only accept Pythondatetime objects now, not strings. If you’d like to formatdates as strings yourself with SQLite, use a String type. Ifyou’d like them to return datetime objects anyway despitetheir accepting strings as input, make a TypeDecorator aroundString - SQLA doesn’t encourage this pattern.

misc

  • [extensions]

Declarative supports a table_args class variable, which iseither a dictionary, or tuple of the form (arg1, arg2, …,{kwarg1:value, …}) which contains positional + kw argumentsto be passed to the Table constructor.References: #1096

0.5.0beta1

Released: Thu Jun 12 2008

general

  • [general]

global “propigate”->”propagate” change.

orm

  • [orm]

polymorphic_union() function respects the “key” of eachColumn if they differ from the column’s name.

  • [orm]

Fixed 0.4-only bug preventing composite columnsfrom working properly with inheriting mappersReferences: #1199

  • [orm]

Fixed RLock-related bug in mapper which could deadlock uponreentrant mapper compile() calls, something that occurs whenusing declarative constructs inside of ForeignKey objects.Ported from 0.5.

  • [orm]

Fixed bug in composite types which prevented a primary-keycomposite type from being mutated.References: #1213

  • [orm]

Added ScopedSession.is_active accessor.References: #976

  • [orm]

Class-bound accessor can be used as the argument torelation() order_by.References: #939

  • [orm]

Fixed shard_id argument on ShardedSession.execute().References: #1072

sql

  • [sql]

Connection.invalidate() checks for closed statusto avoid attribute errors.References: #1246

  • [sql]

NullPool supports reconnect on failure behavior.References: #1094

  • [sql]

The per-dialect cache used by TypeEngine to cachedialect-specific types is now a WeakKeyDictionary.This to prevent dialect objects frombeing referenced forever for an application thatcreates an arbitrarily large number of enginesor dialects. There is a small performance penaltywhich will be resolved in 0.6.References: #1299

  • [sql]

Fixed SQLite reflection methods so that non-presentcursor.description, which triggers an auto-cursorclose, will be detected so that no results doesn’tfail on recent versions of pysqlite which raisean error when fetchone() called with no rows present.

mysql

  • [mysql]

Fixed bug in exception raise when FK columns not presentduring reflection.References: #1241

oracle

  • [oracle]

Fixed bug which was preventing out params of certain typesfrom being received; thanks a ton to huddlej at wwu.edu !References: #1265

firebird

  • [firebird]

Added support for returning values from inserts (2.0+ only),updates and deletes (2.1+ only).

misc

The “init” trigger/decorator added by mapper now attemptsto exactly mirror the argument signature of the originalinit. The pass-through for ‘_sa_session’ is no longerimplicit- you must allow for this keyword argument in yourconstructor.

ClassState is renamed to ClassManager.

Classes may supply their own InstrumentationManager byproviding a sa_instrumentation_manager property.

Custom instrumentation may use any mechanism to associate aClassManager with a class and an InstanceState with aninstance. Attributes on those objects are still the defaultassociation mechanism used by SQLAlchemy’s nativeinstrumentation.

Moved entity_name, _sa_session_id, and _instance_key from theinstance object to the instance state. These values are stillavailable in the old way, which is now deprecated, usingdescriptors attached to the class. A deprecation warning willbe issued when accessed.

The _prepare_instrumentation alias for prepare_instrumentationhas been removed.

sqlalchemy.exceptions has been renamed to sqlalchemy.exc. Themodule may be imported under either name.

ORM-related exceptions are now defined in sqlalchemy.orm.exc.ConcurrentModificationError, FlushError, andUnmappedColumnError compatibility aliases are installed insqlalchemy.exc during the import of sqlalchemy.orm.

sqlalchemy.logging has been renamed to sqlalchemy.log.

The transitional sqlalchemy.log.SADeprecationWarning alias forthe warning’s definition in sqlalchemy.exc has been removed.

exc.AssertionError has been removed and usage replaced withPython’s built-in AssertionError.

The behavior of MapperExtensions attached to multiple,entity_name= primary mappers for a single class has beenaltered. The first mapper() defined for a class is the onlymapper eligible for the MapperExtension ‘instrument_class’,‘init_instance’ and ‘init_failed’ events. This is backwardsincompatible; previously the extensions of last mapper definedwould receive these events.

  • [postgres]

Added Index reflection support to Postgres, using agreat patch we long neglected, submitted byKen Kuhlman.References: #714