0.7 Changelog

0.7.11

no release date

orm

  • [orm] [bug]

Fixed bug where list instrumentation would fail to represent asetslice of [0:0] correctly, which in particular could occurwhen using insert(0, item) with the association proxy. Dueto some quirk in Python collections, the issue was much more likelywith Python 3 rather than 2.References: #2807

  • [orm] [bug]

Fixed bug when a query of the form:query(SubClass).options(subqueryload(Baseclass.attrname)),where SubClass is a joined inh of BaseClass,would fail to apply the JOIN inside the subqueryon the attribute load, producing a cartesian product.The populated results still tended to be correct as additionalrows are just ignored, so this issue may be present as aperformance degradation in applications that areotherwise working correctly.References: #2699

  • [orm] [bug]

Fixed bug in unit of work whereby a joined-inheritancesubclass could insert the row for the “sub” tablebefore the parent table, if the two tables had noForeignKey constraints set up between them.References: #2689

  • [orm] [bug]

Improved the error message emitted when a “backref loop” is detected,that is when an attribute event triggers a bidirectionalassignment between two other attributes with no end.This condition can occur not just when an object of the wrongtype is assigned, but also when an attribute is mis-configuredto backref into an existing backref pair.References: #2674

  • [orm] [bug]

A warning is emitted when a MapperProperty is assigned to a mapperthat replaces an existing property, if the properties in questionaren’t plain column-based properties. Replacement of relationshipproperties is rarely (ever?) what is intended and usually refers to amapper mis-configuration. This will also warn if a backref configuresitself on top of an existing one in an inheritance relationship(which is an error in 0.8).References: #2674

engine

  • [engine] [bug]

The regexp used by the make_url() function now parsesipv6 addresses, e.g. surrounded by brackets.References: #2851

sql

  • [sql] [bug]

Fixed regression dating back to 0.7.9 whereby the name of a CTE mightnot be properly quoted if it was referred to in multiple FROM clauses.References: #2801

  • [sql] [bug] [cte]

Fixed bug in common table expression system where if the CTE wereused only as an alias() construct, it would not render using theWITH keyword.References: #2783

  • [sql] [bug]

Fixed bug in CheckConstraint DDL where the “quote” flag from aColumn object would not be propagated.References: #2784

postgresql

  • [postgresql] [feature]

Added support for PostgreSQL’s traditional SUBSTRINGfunction syntax, renders as “SUBSTRING(x FROM y FOR z)”when regular func.substring() is used.Courtesy Gunnlaugur Þór Briem.References: #2676

mysql

  • [mysql] [bug]

Updates to MySQL reserved words for versions 5.5, 5.6, courtesyHanno Schlichting.References: #2791

misc

  • [bug] [tests]

Fixed an import of “logging” in test_execute which was notworking on some linux platforms.References: #2669, pull request 41

0.7.10

Released: Thu Feb 7 2013

orm

  • [orm] [bug]

Fixed potential memory leak which could occur if anarbitrary number of sessionmaker objectswere created. The anonymous subclass created bythe sessionmaker, when dereferenced, would not be garbagecollected due to remaining class-level references from theevent package. This issue also applies to any custom systemthat made use of ad-hoc subclasses in conjunction withan event dispatcher.References: #2650

  • [orm] [bug]

Query.merge_result() can now load rows from an outer joinwhere an entity may be None without throwing an error.References: #2640

  • [orm] [bug]

The MutableComposite type did not allow for theMutableBase.coerce() method to be used, even thoughthe code seemed to indicate this intent, so this now worksand a brief example is added. As a side-effect,the mechanics of this event handler have been changed so thatnew MutableComposite types no longer add per-typeglobal event handlers. Also in 0.8.0b2.References: #2624

  • [orm] [bug]

Fixed Session accounting bug whereby replacinga deleted object in the identity map with anotherobject of the same primary key would raise a“conflicting state” error on rollback(),if the replaced primary key were established eithervia non-unitofwork-established INSERT statementor by primary key switch of another instance.References: #2583

engine

  • [engine] [bug]

Fixed MetaData.reflect() to correctly usethe given Connection, if given, withoutopening a second connection from that connection’sEngine.References: #2604

sql

  • [sql] [bug]

Backported adjustment to repr forTypeDecorator to 0.7, allows PickleTypeto produce a clean repr() to help with Alembic.References: #2584, #2594

  • [sql] [bug]

Fixed bug where Table.tometadata() would fail if aColumn had both a foreign key as well as analternate “.key” name for the column.References: #2643

  • [sql] [bug]

Fixed bug where using server_onupdate=without passing the “for_update=True” flag would apply the defaultobject to the server_default, blowing away whatever was there.The explicit for_update=True argument shouldn’t be needed with this usage(especially since the documentation shows an example without it beingused) so it is now arranged internally using a copy of the given defaultobject, if the flag isn’t set to what corresponds to that argument.References: #2631

  • [sql] [gae] [mysql]

Added a conditional import to the gaerdbms dialect which attemptsto import rdbms_apiproxy vs. rdbms_googleapi to workon both dev and production platforms. Also now honors theinstance attribute. Courtesy Sean Lynch. Also backportedenhancements to allow username/password as well asfixing error code interpretation from 0.8.References: #2649

mysql

  • [mysql] [feature]

Added “raise_on_warnings” flag to OurSQLdialect.References: #2523

  • [mysql] [feature]

Added “read_timeout” flag to MySQLdbdialect.References: #2554

sqlite

  • [sqlite] [bug]

More adjustment to this SQLite related issue which was released in0.7.9, to intercept legacy SQLite quoting characters when reflectingforeign keys. In addition to intercepting double quotes, otherquoting characters such as brackets, backticks, and single quotesare now also intercepted.References: #2568

mssql

  • [mssql] [bug]

Fixed bug whereby using “key” with Columnin conjunction with “schema” for the owningTable would fail to locate result rows dueto the MSSQL dialect’s “schema rendering”logic’s failure to take .key into account.

  • [mssql] [bug]

Added a Py3K conditional around unnecessary .decode()call in mssql information schema, fixes reflectionin Py3k.References: #2638

oracle

  • [oracle] [bug]

The Oracle LONG type, while an unbounded text type, does not appearto use the cx_Oracle.LOB type when result rows are returned,so the dialect has been repaired to exclude LONG fromhaving cx_Oracle.LOB filtering applied.References: #2620

  • [oracle] [bug]

Repaired the usage of .prepare() in conjunction withcx_Oracle so that a return value of False will resultin no call to connection.commit(), hence avoiding“no transaction” errors. Two-phase transactions havenow been shown to work in a rudimental fashion withSQLAlchemy and cx_oracle, however are subject to caveatsobserved with the driver; check the documentationfor details.References: #2611

  • [oracle] [bug]

changed the list of cx_oracle types that areexcluded from the setinputsizes() step to only includeSTRING and UNICODE; CLOB and NCLOB are removed. Thisis to work around cx_oracle behavior which is brokenfor the executemany() call. In 0.8, this same changeis applied however it is also configurable via theexclude_setinputsizes argument.References: #2561

0.7.9

Released: Mon Oct 01 2012

orm

  • [orm] [bug]

Fixed bug mostly local to newAbstractConcreteBase helper where the “type”attribute from the superclass would notbe overridden on the subclass to produce the“reserved for base” error message, instead placinga do-nothing attribute there. This was inconsistentvs. using ConcreteBase as well as all the behaviorof classical concrete mappings, where the “type”column from the polymorphic base would be explicitlydisabled on subclasses, unless overriddenexplicitly.

  • [orm] [bug]

A warning is emitted when lazy=’dynamic’is combined with uselist=False. This is anexception raise in 0.8.

  • [orm] [bug]

Fixed bug whereby user error in related-objectassignment could cause recursion overflow if theassignment triggered a backref of the same nameas a bi-directional attribute on the incorrectclass to the same target. An informativeerror is raised now.

  • [orm] [bug]

Fixed bug where incorrect type informationwould be passed when the ORM would bind the“version” column, when using the “version” feature.Tests courtesy Daniel Miller.References: #2539

  • [orm] [bug]

Extra logic has been added to the “flush”that occurs within Session.commit(), such that theextra state added by an after_flush() orafter_flush_postexec() hook is also flushed in asubsequent flush, before the “commit” completes.Subsequent calls to flush() will continue untilthe after_flush hooks stop adding new state.An “overflow” counter of 100 is also in place,in the event of a broken after_flush() hookadding new content each time.References: #2566

engine

  • [engine] [feature]

Dramatic improvement in memoryusage of the event system; instance-levelcollections are no longer created for aparticular type of event untilinstance-level listeners are establishedfor that event.References: #2516

  • [engine] [bug]

Fixed bug wherebya disconnect detect + dispose that occurswhen the QueuePool has threads waitingfor connections would leave thosethreads waiting for the duration ofthe timeout on the old pool (or indefinitelyif timeout was disabled). The fixnow notifies those waiters with a specialexception case and has them move ontothe new pool.References: #2522

  • [engine] [bug]

Added gaerdbms import to mysql/init.py,the absence of which was preventing the newGAE dialect from being loaded.References: #2529

  • [engine] [bug]

Fixed cextension bug whereby the“ambiguous column error” would fail tofunction properly if the given index werea Column object and not a string.Note there are still some column-targetingissues here which are fixed in 0.8.References: #2553

  • [engine] [bug]

Fixed the repr() of Enum to includethe “name” and “native_enum” flags. HelpsAlembic autogenerate.

sql

  • [sql] [bug]

Fixed the DropIndex construct to supportan Index associated with a Table in a remoteschema.References: #2571

  • [sql] [bug]

Fixed bug in over() construct wherebypassing an empty list for either partition_byor order_by, as opposed to None, would failto generate correctly.Courtesy Gunnlaugur Þór Briem.References: #2574

  • [sql] [bug]

Fixed CTE bug whereby positionalbound parameters present in the CTEs themselveswould corrupt the overall ordering ofbound parameters. This primarilyaffected SQL Server as the platform withpositional binds + CTE support.References: #2521

  • [sql] [bug]

Fixed more un-intuitivenesses in CTEswhich prevented referring to a CTE in a unionof itself without it being aliased.CTEs now render uniquelyon name, rendering the outermost CTE of a givenname only - all other references are renderedjust as the name. This even includes otherCTE/SELECTs that refer to different versionsof the same CTE object, such as a SELECTor a UNION ALL of that SELECT. We aresomewhat loosening the usual link between objectidentity and lexical identity in this case.A true name conflict between two unrelatedCTEs now raises an error.

  • [sql] [bug]

quoting is applied to the column namesinside the WITH RECURSIVE clause of acommon table expression according to thequoting rules for the originating Column.References: #2512

  • [sql] [bug]

Fixed regression introduced in 0.7.6whereby the FROM list of a SELECT statementcould be incorrect in certain “clone+replace”scenarios.References: #2518

  • [sql] [bug]

Fixed bug whereby usage of a UNIONor similar inside of an embedded subquerywould interfere with result-column targeting,in the case that a result-column had the sameultimate name as a name inside the embeddedUNION.References: #2552

  • [sql] [bug]

Fixed a regression since 0.6 regardingresult-row targeting. It should be possibleto use a select() statement with stringbased columns in it, that isselect([‘id’, ‘name’]).select_from(‘mytable’),and have this statement be targetable byColumn objects with those names; this is themechanism by whichquery(MyClass).from_statement(some_statement)works. At some point the specific case ofusing select([‘id’]), which is equivalent toselect([literal_column(‘id’)]), stopped workinghere, so this has been re-instated and ofcourse tested.References: #2558

  • [sql] [bug]

Added missing operators is_(), isnot()to the ColumnOperators base, so that these long-availableoperators are present as methods like allthe other operators.References: #2544

postgresql

  • [postgresql] [bug]

Columns in reflected primary key constraintare now returned in the order in which the constraintitself defines them, rather than how the tableorders them. Courtesy Gunnlaugur Þór Briem..References: #2531

  • [postgresql] [bug]

Added ‘terminating connection’ to the listof messages we use to detect a disconnect with PG, whichappears to be present in some versions when the serveris restarted.References: #2570

mysql

  • [mysql] [bug]

Updated mysqlconnector interface to useupdated “client flag” and “charset” APIs,courtesy David McNelis.

sqlite

  • [sqlite] [feature]

Added support for the localtimestamp()SQL function implemented in SQLite, courtesyRichard Mitchell.

  • [sqlite] [bug]

Adjusted a very old bugfix which attemptedto work around a SQLite issue that itself was“fixed” as of sqlite 3.6.14, regarding quotessurrounding a table name when usingthe “foreignkey_list” pragma. The fix has beenadjusted to not interfere with quotes thatare _actually in the name of a column or table,to as much a degree as possible; sqlite stilldoesn’t return the correct result for foreignkey_list()if the target table actually has quotes surroundingits name, as _part of its name (i.e. “”“mytable”“”).References: #2568

  • [sqlite] [bug]

Adjusted column default reflection code toconvert non-string values to string, to accommodateold SQLite versions that don’t deliverdefault info as a string.References: #2265

mssql

  • [mssql] [bug]

Fixed compiler bug whereby using a correlatedsubquery within an ORDER BY would fail to render correctlyif the statement also used LIMIT/OFFSET, due to mis-renderingwithin the ROW_NUMBER() OVER clause. Fix courtesysayapReferences: #2538

  • [mssql] [bug]

Fixed compiler bug whereby a givenselect() would be modified if it had an “offset”attribute, causing the construct to not compilecorrectly a second time.References: #2545

  • [mssql] [bug]

Fixed bug where reflection of primary key constraintwould double up columns if the same constraint/tableexisted in multiple schemas.

0.7.8

Released: Sat Jun 16 2012

orm

  • [orm] [feature]

The ‘objects’ argument toflush() is no longer deprecated, as somevalid use cases have been identified.

  • [orm] [bug]

Fixed bug whereby subqueryload() froma polymorphic mapping to a target would incura new invocation of the query for eachdistinct class encountered in the polymorphicresult.References: #2480

  • [orm] [bug]

Fixed bug in declarativewhereby the precedence of columnsin a joined-table, compositecolumn (typically for id) would fail tobe correct if the columns containednames distinct from their attributenames. This would cause things likeprimaryjoin conditions made against theentity attributes to be incorrect. Relatedto as this was supposedto be part of that, this is.References: #1892, #2491

  • [orm] [bug]

Fixed identity_key() function whichwas not accepting a scalar argumentfor the identity. .References: #2508

  • [orm] [bug]

Fixed bug whereby populate_existingoption would not propagate to subqueryeager loaders. .References: #2497

engine

  • [engine] [bug]

Fixed memory leak in C version ofresult proxy whereby DBAPIs which don’t deliverpure Python tuples for result rows wouldfail to decrement refcounts correctly.The most prominently affected DBAPIis pyodbc.References: #2489

  • [engine] [bug]

Fixed bug affecting Py3K wherebystring positional parameters passed toengine/connection execute() would fail to beinterpreted correctly, due to iterbeing present on Py3K string..References: #2503

sql

  • [sql] [bug]

added BIGINT to types.all,BIGINT, BINARY, VARBINARY to sqlalchemymodule namespace, plus test to ensurethis breakage doesn’t occur again.References: #2499

  • [sql] [bug]

Repaired common table expressionrendering to function correctly when theSELECT statement contains UNION or othercompound expressions, courtesy btbuilder.References: #2490

  • [sql] [bug]

Fixed bug whereby append_column()wouldn’t function correctly on a clonedselect() construct, courtesyGunnlaugur Þór Briem.References: #2482

postgresql

  • [postgresql] [bug]

removed unnecessary table clause whenreflecting enums,. CourtesyGunnlaugur Þór Briem.References: #2510

mysql

  • [mysql] [feature]

Added a new dialect for Google AppEngine. Courtesy Richie Foreman.References: #2484

oracle

  • [oracle] [bug]

Added ROWID to oracle.*.References: #2483

0.7.7

Released: Sat May 05 2012

orm

  • [orm] [feature]

Added prefix_with() methodto Query, calls upon select().prefix_with()to allow placement of MySQL SELECTdirectives in statements. CourtesyDiana ClarkeReferences: #2443

  • [orm] [feature]

Added new flag to @validatesinclude_removes. When True, collectionremove and attribute del eventswill also be sent to the validation function,which accepts an additional argument“is_remove” when this flag is used.

  • [orm] [bug]

Fixed issue in unit of workwhereby setting a non-None self-referentialmany-to-one relationship to Nonewould fail to persist the change if theformer value was not already loaded..References: #2477

  • [orm] [bug]

Fixed bug in 0.7.6 introduced by whereby column_mapped_collectionused against columns that were mapped asjoins or other indirect selectableswould fail to function.References: #2409

  • [orm] [bug]

Fixed bug whereby polymorphic_oncolumn that’s not otherwise mapped on theclass would be incorrectly includedin a merge() operation, raising an error.References: #2449

  • [orm] [bug]

Fixed bug in expression annotationmechanics which could lead to incorrectrendering of SELECT statements with aliasesand joins, particularly when usingcolumn_property().References: #2453

  • [orm] [bug]

Fixed bug which would preventOrderingList from being pickleable. Courtesy Jeff DairikiReferences: #2454

  • [orm] [bug]

Fixed bug in relationship comparisonswhereby calling unimplemented methods likeSomeClass.somerelationship.like() wouldproduce a recursion overflow, insteadof NotImplementedError.

sql

  • [sql] [feature]

Added new connection eventdbapi_error(). Is called for all DBAPI-levelerrors passing the original DBAPI exceptionbefore SQLAlchemy modifies the stateof the cursor.

  • [sql] [bug]

Removed warning when Index is createdwith no columns; while this might not be whatthe user intended, it is a valid use caseas an Index could be a placeholder for just anindex of a certain name.

  • [sql] [bug]

If conn.begin() fails when calling“with engine.begin()”, the newly acquiredConnection is closed explicitly beforepropagating the exception onward normally.

  • [sql] [bug]

Add BINARY, VARBINARY to types.all.References: #2474

postgresql

  • [postgresql] [feature]

Added new for_update/with_lockmode()options for PostgreSQL: for_update=”read”/with_lockmode(“read”),for_update=”read_nowait”/with_lockmode(“read_nowait”).These emit “FOR SHARE” and “FOR SHARE NOWAIT”,respectively. Courtesy Diana ClarkeReferences: #2445

  • [postgresql] [bug]

removed unnecessary table clausewhen reflecting domains.References: #2473

mysql

  • [mysql] [bug]

Fixed bug whereby column name insideof “KEY” clause for autoincrement compositecolumn with InnoDB would double quote aname that’s a reserved word. Courtesy JeffDairiki.References: #2460

  • [mysql] [bug]

Fixed bug whereby get_view_names() for“information_schema” schema would failto retrieve views marked as “SYSTEM VIEW”.courtesy Matthew Turland.

  • [mysql] [bug]

Fixed bug whereby if cast() is usedon a SQL expression whose type is not supportedby cast() and therefore CAST isn’t rendered bythe dialect, the order of evaluation could changeif the casted expression required that it begrouped; grouping is now applied to thoseexpressions.References: #2467

sqlite

  • [sqlite] [feature]

Added SQLite execution option“sqlite_raw_colnames=True”, will bypassattempts to remove “.” from column namesreturned by SQLite cursor.description.References: #2475

  • [sqlite] [bug]

When the primary key column of a Tableis replaced, such as via extend_existing,the “auto increment” column used by insert()constructs is reset. Previously it wouldremain referring to the previous primarykey column.References: #2525

mssql

  • [mssql] [feature]

Added interim create_engine flagsupports_unicode_binds to PyODBC dialect,to force whether or not the dialectpasses Python unicode literals to PyODBCor not.

  • [mssql] [bug]

Repaired the use_scope_identitycreate_engine() flag when using the pyodbcdialect. Previously this flag would beignored if set to False. When set to False,you’ll get “SELECT @@identity” after eachINSERT to get at the last inserted ID,for those tables which have “implicit_returning”set to False.

  • [mssql] [bug]

UPDATE..FROM syntax with SQL Serverrequires that the updated table be presentin the FROM clause when an alias of thattable is also present in the FROM clause.The updated table is now always presentin the FROM, when FROM is presentin the first place. Courtesy sayap.References: #2468

0.7.6

Released: Wed Mar 14 2012

orm

  • [orm] [feature]

Added “no_autoflush” contextmanager to Session, used with with:will temporarily disable autoflush.

  • [orm] [feature]

Added cte() method to Query,invokes common table expression supportfrom the Core (see below).References: #1859

  • [orm] [feature]

Added the ability to query forTable-bound column names when usingquery(sometable).filter_by(colname=value).References: #2400

  • [orm] [bug]

Fixed event registration bugwhich would primarily show up asevents not being registered withsessionmaker() instances createdafter the event was associatedwith the Session class.References: #2424

  • [orm] [bug]

Fixed bug whereby a primaryjoincondition with a “literal” in it wouldraise an error on compile with certainkinds of deeply nested expressionswhich also needed to render the samebound parameter name more than once.References: #2425

  • [orm] [bug]

Removed the check for number ofrows affected when doing a multi-deleteagainst mapped objects. If an ON DELETECASCADE exists between two rows, we can’tget an accurate rowcount from the DBAPI;this particular count is not supportedon most DBAPIs in any case, MySQLdbis the notable case where it is.References: #2403

  • [orm] [bug]

Fixed bug whereby objects usingattribute_mapped_collection orcolumn_mapped_collection could not bepickled.References: #2409

  • [orm] [bug]

Fixed bug whereby MappedCollectionwould not get the appropriate collectioninstrumentation if it were only usedin a custom subclass that used@collection.internally_instrumented.References: #2406

  • [orm] [bug]

Fixed bug whereby SQL adaption mechanicswould fail in a very nested scenario involvingjoined-inheritance, joinedload(), limit(), and aderived function in the columns clause.References: #2419

  • [orm] [bug]

Fixed the repr() for CascadeOptions toinclude refresh-expire. Also reworkedCascadeOptions to be a .References: #2417

  • [orm] [bug]

Improved the “declarative reflection”example to support single-table inheritance,multiple calls to prepare(), tables thatare present in alternate schemas,establishing only a subset of classesas reflected.

  • [orm] [bug]

Scaled back the test applied withinflush() to check for UPDATE against partiallyNULL PK within one table to only actuallyhappen if there’s really an UPDATE to occur.References: #2390

  • [orm] [bug]

Fixed bug whereby if a method nameconflicted with a column name, aTypeError would be raised when the mappertried to inspect the get() methodon the method object.References: #2352

engine

  • [engine] [feature]

Added “no_parameters=True” executionoption for connections. If no parametersare present, will pass the statementas cursor.execute(statement), thereby invokingthe DBAPIs behavior when no parameter collectionis present; for psycopg2 and mysql-python, thismeans not interpreting % signs in the string.This only occurs with this option, and notjust if the param list is blank, as otherwisethis would produce inconsistent behaviorof SQL expressions that normally escape percentsigns (and while compiling, can’t know ahead oftime if parameters will be present insome cases).References: #2407

  • [engine] [feature]

Added pool_reset_on_return argumentto create_engine, allows control over“connection return” behavior. Also addednew arguments ‘rollback’, ‘commit’, Noneto pool.reset_on_return to allow more controlover connection return activity.References: #2378

  • [engine] [feature]

Added some decent context managersto Engine, Connection:

  1. with engine.begin() as conn:
  2. <work with conn in a transaction>

and:

  1. with engine.connect() as conn:
  2. <work with conn>

Both close out the connection when done,commit or rollback transaction with errorson engine.begin().

  • [engine] [bug]

Added execution_options() call toMockConnection (i.e., that used withstrategy=”mock”) which acts as a pass throughfor arguments.

sql

  • [sql] [feature]

Added support for SQL standardcommon table expressions (CTE), allowingSELECT objects as the CTE source (DMLnot yet supported). This is invoked viathe cte() method on any select() construct.References: #1859

  • [sql] [bug]

Fixed memory leak in core which wouldoccur when C extensions were used withparticular types of result fetches,in particular when orm query.count()were called.References: #2427

  • [sql] [bug]

Fixed issue whereby attribute-basedcolumn access on a row would raiseAttributeError with non-C version,NoSuchColumnError with C version. Nowraises AttributeError in both cases.References: #2398

  • [sql] [bug]

Added support for using the .keyof a Column as a string identifier in aresult set row. The .key is currentlylisted as an “alternate” name for a column,and is superseded by the name of a columnwhich has that key value as its regular name.For the next major releaseof SQLAlchemy we may reverse this precedenceso that .key takes precedence, but thisis not decided on yet.References: #2392

  • [sql] [bug]

A warning is emitted when a not-presentcolumn is stated in the values() clauseof an insert() or update() construct.Will move to an exception in 0.8.References: #2413

  • [sql] [bug]

A significant change to how labelingis applied to columns in SELECT statementsallows “truncated” labels, that is label namesthat are generated in Python which exceedthe maximum identifier length (note this isconfigurable via label_length on create_engine()),to be properly referenced when rendered insideof a subquery, as well as to be presentin a result set row using their originalin-Python names.References: #2396

  • [sql] [bug]

Fixed bug in new “autoload_replace” flagwhich would fail to preserve the primarykey constraint of the reflected table.References: #2402

  • [sql] [bug]

Index will raise when arguments passedcannot be interpreted as columns or expressions.Will warn when Index is createdwith no columns at all.References: #2380

mysql

  • [mysql] [feature]

Added support for MySQL index andprimary key constraint types(i.e. USING) via new mysql_using parameterto Index and PrimaryKeyConstraint,courtesy Diana Clarke.References: #2386

  • [mysql] [feature]

Added support for the “isolation_level”parameter to all MySQL dialects. Thanksto mu_mind for the patch here.References: #2394

sqlite

  • [sqlite] [bug]

Fixed bug in C extensions wherebystring format would not be applied to aNumeric value returned as integer; thisaffected primarily SQLite which doesnot maintain numeric scale settings.References: #2432

mssql

  • [mssql] [feature]

Added support for MSSQL INSERT,UPDATE, and DELETE table hints, usingnew with_hint() method on UpdateBase.References: #2430

oracle

  • [oracle] [feature]

Added a new create_engine() flagcoerce_to_decimal=False, disables the precisionnumeric handling which can add lots of overheadby converting all numeric values toDecimal.References: #2399

  • [oracle] [bug]

Added missing compilation support forLONGReferences: #2401

  • [oracle] [bug]

Added ‘LEVEL’ to the list of reservedwords for Oracle.References: #2435

misc

  • [bug] [examples]

Altered _params_from_query() functionin Beaker example to pull bindparams from thefully compiled statement, as a quick meansto get everything including subqueries in thecolumns clause, etc.

0.7.5

Released: Sat Jan 28 2012

orm

  • [orm] [feature]

Added “class_registry” argument todeclarative_base(). Allows two or more declarativebases to share the same registry of class names.

  • [orm] [feature]

query.filter() accepts multiplecriteria which will join via AND, i.e.query.filter(x==y, z>q, …)

  • [orm] [feature]

Added new capability to relationshiploader options to allow “default” loader strategies.Pass ‘*’ to any of joinedload(), lazyload(),subqueryload(), or noload() and that becomes theloader strategy used for all relationships,except for those explicitly stated in theQuery. Thanks to up-and-coming contributorKent Bower for an exhaustive and wellwritten test suite !References: #2351

  • [orm] [feature]

New declarative reflection exampleadded, illustrates how best to mix table reflectionwith declarative as well as uses some new featuresfrom.References: #2356

  • [orm] [bug]

Fixed issue where modified session stateestablished after a failed flush would be committedas part of the subsequent transaction thatbegins automatically after manual callto rollback(). The state of the session ischecked within rollback(), and if new stateis present, a warning is emitted andrestore_snapshot() is called a second time,discarding those changes.References: #2389

  • [orm] [bug]

Fixed regression from 0.7.4 wherebyusing an already instrumented column from asuperclass as “polymorphic_on” failed to resolvethe underlying Column.References: #2345

  • [orm] [bug]

Raise an exception if xyzload_all() isused inappropriately with two non-connectedrelationships.References: #2370

  • [orm] [bug]

Fixed bug whereby event.listen(SomeClass)forced an entirely unnecessary compile of themapper, making events very hard to set upat module import time (nobody noticed this ??)References: #2367

  • [orm] [bug]

Fixed bug whereby hybrid_property didn’twork as a kw arg in any(), has().

  • [orm] [bug]

ensure pickleability of all ORM exceptionsfor multiprocessing compatibility.References: #2371

  • [orm] [bug]

implemented standard “can’t set attribute” /“can’t delete attribute” AttributeError whensetattr/delattr used on a hybrid that doesn’tdefine fset or fdel.References: #2353

  • [orm] [bug]

Fixed bug where unpickled object didn’thave enough of its state set up to workcorrectly within the unpickle() event establishedby the mutable object extension, if the objectneeded ORM attribute access withineq() or similar.References: #2362

  • [orm] [bug]

Fixed bug where “merge” cascade couldmis-interpret an unloaded attribute, if theload_on_pending flag were used withrelationship(). Thanks to Kent Bowerfor tests.References: #2374

  • [orm]

Fixed regression from 0.6 whereby if“load_on_pending” relationship() flag were usedwhere a non-“get()” lazy clause needed to beemitted on a pending object, it would failto load.

engine

  • [engine] [bug]

Added reduce to StatementError,DBAPIError, column errors so that exceptionsare pickleable, as when using multiprocessing.However, notall DBAPIs support this yet, such aspsycopg2.References: #2371

  • [engine] [bug]

Improved error messages when a non-stringor invalid string is passed to any of thedate/time processors used by SQLite, includingC and Python versions.References: #2382

  • [engine] [bug]

Fixed bug whereby a table-bound Columnobject named “” which matched a columnlabeled as “” could matchinappropriately when targeting in a resultset row.References: #2377

  • [engine] [bug]

Fixed bug in “mock” strategy wherebycorrect DDL visit method wasn’t called, resultingin “CREATE/DROP SEQUENCE” statements beingduplicatedReferences: #2384

sql

  • [sql] [feature]

New reflection feature “autoload_replace”;when set to False on Table, the Table can be autoloadedwithout existing columns being replaced. Allowsmore flexible chains of Table construction/reflectionto be constructed, including that it helps withcombining Declarative with table reflection.See the new example on the wiki.References: #2356

  • [sql] [feature]

Added “false()” and “true()” expressionconstructs to sqlalchemy.sql namespace, thoughnot part of all as of yet.

  • [sql] [feature]

Dialect-specific compilers now raiseCompileError for all type/statement compilationissues, instead of InvalidRequestError or ArgumentError.The DDL for CREATE TABLE will re-raiseCompileError to include table/column informationfor the problematic column.References: #2361

  • [sql] [bug]

Improved the API for add_column() such thatif the same column is added to its own table,an error is not raised and the constraintsdon’t get doubled up. Also helps with somereflection/declarative patterns.References: #2356

  • [sql] [bug]

Fixed issue where the “required” exceptionwould not be raised for bindparam() with required=True,if the statement were given no parameters at all.References: #2381

mysql

  • [mysql] [bug]

fixed regexp that filters out warningsfor non-reflected “PARTITION” directives,thanks to George ReillyReferences: #2376

sqlite

  • [sqlite] [bug]

the “name” of an FK constraint in SQLiteis reflected as “None”, not “0” or otherinteger value.SQLite does not appear to support constraintnaming in any case.References: #2364

  • [sqlite] [bug]

sql.false() and sql.true() compile to0 and 1, respectively in sqliteReferences: #2368

  • [sqlite] [bug]

removed an erroneous “raise” in theSQLite dialect when getting table namesand view names, where logic is in placeto fall back to an older version ofSQLite that doesn’t have the“sqlite_temp_master” table.

mssql

  • [mssql] [bug]

Adjusted the regexp used in themssql.TIME type to ensure only six digitsare received for the “microseconds” portionof the value, which is expected byPython’s datetime.time(). Note thatsupport for sending microseconds doesn’tseem to be possible yet with pyodbcat least.References: #2340

  • [mssql] [bug]

Dropped the “30 char” limit on pymssql,based on reports that it’s doing thingsbetter these days. pymssql hasn’t beenwell tested and as the DBAPI is in fluxit’s still not clear what the statusis on this driver and how SQLAlchemy’simplementation should adapt.References: #2347

oracle

  • [oracle] [bug]

Added ORA-03135 to the never endinglist of oracle “connection lost” errorsReferences: #2388

misc

  • [feature] [examples]

Simplified the versioning examplea bit to use a declarative mixin as wellas an event listener, instead of a metaclass +SessionExtension.References: #2313

  • [bug] [core]

Changed LRUCache, used by the mapperto cache INSERT/UPDATE/DELETE statements,to use an incrementing counter insteadof a timestamp to track entries, for greaterreliability versus using time.time(), whichcan cause test failures on some platforms.References: #2379

  • [bug] [core]

Added a boolean check for the “finalize”function within the pool connection proxy’sweakref callback before calling it, so that awarning isn’t emitted that this function is Nonewhen the application is exiting and gc hasremoved the function from the module before theweakref callback was invoked.References: #2383

  • [bug] [py3k]

Fixed inappropriate usage of util.py3kflag and renamed it to util.py3k_warning, sincethis flag is intended to detect the -3 flagseries of import restrictions only.References: #2348

  • [bug] [examples]

Fixed large_collection.py to close thesession before dropping tables.References: #2346

0.7.4

Released: Fri Dec 09 2011

orm

  • [orm] [feature]

polymorphic_on now accepts manynew kinds of values:

  • standalone expressions that aren’totherwise mapped

  • column_property() objects

  • string names of any column_property()or attribute name of a mapped Column

The docs include an example usingthe case() construct, which is likely to bea common constructed used here. and part of

Standalone expressions in polymorphic_onpropagate to single-table inheritancesubclasses so that they are used in theWHERE /JOIN clause to limit rows to thatsubclass as is the usual behavior.References: #2238, #2345

  • [orm] [feature]

IdentitySet supports the - operatoras the same as difference(), handy when dealingwith Session.dirty etc.References: #2301

  • [orm] [feature]

Added new value for Column autoincrementcalled “ignore_fk”, can be used to force autoincrementon a column that’s still part of a ForeignKeyConstraint.New example in the relationship docs illustratesits use.

  • [orm] [bug]

Fixed backref behavior when “popping” thevalue off of a many-to-one in response toa removal from a stale one-to-many - the operationis skipped, since the many-to-one has sincebeen updated.References: #2315

  • [orm] [bug]

After some years of not doing this, addedmore granularity to the “is X a parent of Y”functionality, which is used when determiningif the FK on “Y” needs to be “nulled out” as wellas if “Y” should be deleted with delete-orphancascade. The test now takes into account thePython identity of the parent as well its identitykey, to see if the last known parent of Y isdefinitely X. If a decisioncan’t be made, a StaleDataError is raised. Theconditions where this error is raised are fairlyrare, requiring that the previous parent wasgarbage collected, and previouslycould very well inappropriately update/deletea record that’s since moved onto a new parent,though there may be some cases where“silent success” occurred previously that will nowraise in the face of ambiguity.Expiring “Y” resets the “parent” tracker, meaningX.remove(Y) could then end up deleting Y evenif X is stale, but this is the same behavioras before; it’s advised to expire X also in thatcase.References: #2264

  • [orm] [bug]

fixed inappropriate evaluation of user-mappedobject in a boolean context within query.get(). Also in 0.6.9.References: #2310

  • [orm] [bug]

Added missing comma to PASSIVE_RETURN_NEVER_SETsymbolReferences: #2304

  • [orm] [bug]

Cls.column.collate(“some collation”) nowworks. Also in 0.6.9References: #1776

  • [orm] [bug]

the value of a composite attribute is nowexpired after an insert or update operation, insteadof regenerated in place. This ensures that acolumn value which is expired within a flushwill be loaded first, before the compositeis regenerated using that value.References: #2309

  • [orm] [bug]

The fix in also emits the“refresh” event when the composite value isloaded on access, even if all columnvalues were already present, as is appropriate.This fixes the “mutable” extension which reliesupon the “load” event to ensure the _parentsdictionary is up to date, fixes.Thanks to Scott Torborg for the test case here.References: #2308, #2309

  • [orm] [bug]

Fixed bug whereby a subclass of a subclassusing concrete inheritance in conjunction withthe new ConcreteBase or AbstractConcreteBasewould fail to apply the subclasses deeper thanone level to the “polymorphic loader” of eachbaseReferences: #2312

  • [orm] [bug]

Fixed bug whereby a subclass of a subclassusing the new AbstractConcreteBase would failto acquire the correct “base_mapper” attributewhen the “base” mapper was generated, therebycausing failures later on.References: #2312

  • [orm] [bug]

Fixed bug whereby column_property() createdagainst ORM-level column could be treated asa distinct entity when producing certainkinds of joined-inh joins.References: #2316

  • [orm] [bug]

Fixed the error formatting raised whena tuple is inadvertently passed to session.query(). Also in 0.6.9.References: #2297

  • [orm] [bug]

Calls to query.join() to a single-tableinheritance subclass are now tracked, andare used to eliminate the additional WHERE..IN criterion normally tacked on with singletable inheritance, since the join shouldaccommodate it. This allows OUTER JOINto a single table subclass to producethe correct results, and overall will producefewer WHERE criterion when dealing withsingle table inheritance joins.References: #2328

  • [orm] [bug]

table_args can now be passed asan empty tuple as well as an empty dict.. Thanks to Fayaz Yusuf Khanfor the patch.References: #2339

  • [orm] [bug]

Updated warning message when settingdelete-orphan without delete to no longerrefer to 0.6, as we never got around toupgrading this to an exception. Ideallythis might be better as an exception butit’s not critical either way.References: #2325

  • [orm] [bug]

Fixed bug in get_history() when referringto a composite attribute that has no value;added coverage for get_history() regardingcomposites which is otherwise just a userlandfunction.

engine

  • [engine] [bug]

Fixed bug whereby transaction.rollback()would throw an error on an invalidatedconnection if the transaction were atwo-phase or savepoint transaction.For plain transactions, rollback() is a no-opif the connection is invalidated, so whileit wasn’t 100% clear if it should be a no-op,at least now the interface is consistent.References: #2317

sql

  • [sql] [feature]

The update() construct can now accommodatemultiple tables in the WHERE clause, which willrender an “UPDATE..FROM” construct, recognized byPostgreSQL and MSSQL. When compiled on MySQL,will instead generate “UPDATE t1, t2, ..”. MySQLadditionally can render against multiple tables in theSET clause, if Column objects are used as keysin the “values” parameter or generative method.References: #1944, #2166

  • [sql] [feature]

Added accessor to types called “python_type”,returns the rudimentary Python type objectfor a particular TypeEngine instance, if known,else raises NotImplementedError.References: #77

  • [sql] [bug]

related to, made someadjustments to the change fromregarding the “from” list on a select(). The_froms collection is no longer memoized, as thissimplifies various use cases and removes theneed for a “warning” if a column is attachedto a table after it was already used in anexpression - the select() construct will nowalways produce the correct expression.There’s probably no real-worldperformance hit here; select() objects arealmost always made ad-hoc, and systems thatwish to optimize the re-use of a select()would be using the “compiled_cache” feature.A hit which would occur when calling select.bindhas been reduced, but the vast majorityof users shouldn’t be using “bound metadata”anyway :).References: #2261, #2316

  • [sql] [bug]

further tweak to the fix from,so that generative methods work a bit betteroff of cloned (this is almost a non-use case though).In particular this allows with_only_columns()to behave more consistently. Added additionaldocumentation to with_only_columns() to clarifyexpected behavior, which changed as a resultof.References: #2261, #2319

schema

  • [schema] [feature]

Added new support for remote “schemas”:

  • [schema] [feature]

The “extendexisting” flag on Tablenow allows for the reflection process to takeeffect for a Table object that’s already beendefined; when autoload=True and extend_existing=Trueare both set, the full set of columns will bereflected from the Table which will then_overwrite those columns already present,rather than no activity occurring. Columns thatare present directly in the autoload runwill be used as always, however.References: #1410

  • [schema] [bug]

Fixed bug whereby TypeDecorator wouldreturn a stale value for _type_affinity, whenusing a TypeDecorator that “switches” types,like the CHAR/UUID type.

  • [schema] [bug]

Fixed bug whereby “order_by=’foreign_key’”option to Inspector.get_table_nameswasn’t implementing the sort properly, replacedwith the existing sort algorithm

  • [schema] [bug]

the “name” of a column-level CHECK constraint,if present, is now rendered in the CREATE TABLEstatement using “CONSTRAINT CHECK ”.References: #2305

  • [schema]

MetaData() accepts “schema” and “quote_schema”arguments, which will be applied to the same-namedarguments of a Tableor Sequence which leaves these at their defaultof None.

  • [schema]

Sequence accepts “quote_schema” argument

  • [schema]

tometadata() for Table will use the “schema”of the incoming MetaData for the new Tableif the schema argument is explicitly “None”

  • [schema]

Added CreateSchema and DropSchema DDLconstructs - these accept just the stringname of a schema and a “quote” flag.

  • [schema]

When using default “schema” with MetaData,ForeignKey will also assume the “default” schemawhen locating remote table. This allows the “schema”argument on MetaData to be applied to anyset of Table objects that otherwise don’t havea “schema”.

  • [schema]

a “has_schema” method has been implementedon dialect, but only works on PostgreSQL so far.Courtesy Manlio Perillo.References: #1679

postgresql

  • [postgresql] [feature]

Added create_type constructor argumentto pg.ENUM. When False, no CREATE/DROP orchecking for the type will be performed as partof a table create/drop event; only thecreate()/drop)() methods called directlywill do this. Helps with Alembic “offline”scripts.

  • [postgresql] [bug]

PostgreSQL dialect memoizes that an ENUM of aparticular name was processedduring a create/drop sequence. This allowsa create/drop sequence to work without anycalls to “checkfirst”, and also means with“checkfirst” turned on it only needs tocheck for the ENUM once.References: #2311

mysql

  • [mysql] [bug]

Unicode adjustments allow latest pymysql(post 0.4) to pass 100% on Python 2.

mssql

  • [mssql] [feature]

lifted the restriction on SAVEPOINTfor SQL Server. All tests pass using it,it’s not known if there are deeper issueshowever.References: #822

  • [mssql] [bug]

repaired the with_hint() feature whichwasn’t implemented correctly on MSSQL -usually used for the “WITH (NOLOCK)” hint(which you shouldn’t be using anyway !use snapshot isolation instead :) )References: #2336

  • [mssql] [bug]

use new pyodbc version detection for_need_decimal_fix option.References: #2318

  • [mssql] [bug]

don’t cast “table name” as NVARCHARon SQL Server 2000. Still mostly in the darkwhat incantations are needed to make PyODBCwork fully with FreeTDS 0.91 here, however.References: #2343

  • [mssql] [bug]

Decode incoming values when retrievinglist of index names and the names of columnswithin those indexes.References: #2269

misc

  • [feature] [ext]

Added an example to the hybrid docsof a “transformer” - a hybrid that returns aquery-transforming callable in combinationwith a custom comparator. Uses a new methodon Query called with_transformation(). The usecase here is fairly experimental, but onlyadds one line of code to Query.

  • [bug] [pyodbc]

pyodbc-based dialects now parse thepyodbc accurately as far as observedpyodbc strings, including such gemsas “py3-3.0.1-beta4”References: #2318

  • [bug] [ext]

the @compiles decorator raises aninformative error message when no “default”compilation handler is present, ratherthan KeyError.

  • [bug] [examples]

Fixed bug in history_meta.py example wherethe “unique” flag was not removed from asingle-table-inheritance subclass whichgenerates columns to put up onto the base.

0.7.3

Released: Sun Oct 16 2011

general

  • [general]

Adjusted the “importlater” mechanism, which isused internally to resolve import cycles,such that the usage of import is completedwhen the import of sqlalchemy or sqlalchemy.ormis done, thereby avoiding any usage of importafter the application starts new threads,fixes. Also in 0.6.9.References: #2279

orm

  • [orm]

Improved query.join() such that the “left” sidecan more flexibly be a non-ORM selectable,such as a subquery. A selectable placedin select_from() will now be used as the leftside, favored over implicit usageof a mapped entity.If the join still fails based on lack offoreign keys, the error message includesthis detail. Thanks to brianrhudeon IRC for the test case.References: #2298

  • [orm]

Added after_soft_rollback() Session event. Thisevent fires unconditionally whenever rollback()is called, regardless of if an actual DBAPIlevel rollback occurred. This eventis specifically designed to allow operationswith the Session to proceed after a rollbackwhen the Session.is_active is True.References: #2241

  • [orm]

added “adapt_on_names” boolean flag to orm.aliased()construct. Allows an aliased() constructto link the ORM entity to a selectable that containsaggregates or other derived forms of a particularattribute, provided the name is the same as thatof the entity mapped column.

  • [orm]

Added new flag expire_on_flush=False to column_property(),marks those properties that would otherwise be consideredto be “readonly”, i.e. derived from SQL expressions,to retain their value after a flush has occurred, includingif the parent object itself was involved in an update.

  • [orm]

Enhanced the instrumentation in the ORM to supportPy3K’s new argument style of “required kw arguments”,i.e. fn(a, b, , c, d), fn(a, b, args, c, d).Argument signatures of mapped object’s initmethod will be preserved, including required kw rules.References: #2237

  • [orm]

Fixed bug in unit of work whereby detection of“cycles” among classes in highly interlinked patternswould not produce a deterministicresult; thereby sometimes missing some nodes thatshould be considered cycles and causing furtherissues down the road. Note this bug is in 0.6also; not backported at the moment.References: #2282

  • [orm]

Fixed a variety of synonym()-related regressionsfrom 0.6:

  • making a synonym against a synonym now works.

  • synonyms made against a relationship() canbe passed to query.join(), options sentto query.options(), passed by nameto query.with_parent().

  • [orm]

Fixed bug whereby mapper.order_by attribute wouldbe ignored in the “inner” query within asubquery eager load. .Also in 0.6.9.References: #2287

  • [orm]

Identity map .discard() uses dict.pop(,None)internally instead of “del” to avoid KeyError/warningduring a non-determinate gc teardownReferences: #2267

  • [orm]

Fixed regression in new composite rewrite wheredeferred=True option failed due to missingimportReferences: #2253

  • [orm]

Reinstated “comparator_factory” argument tocomposite(), removed when 0.7 was released.References: #2248

  • [orm]

Fixed bug in query.join() which would occurin a complex multiple-overlapping path scenario,where the same table could be joined totwice. Thanks much to Dave Vitekfor the excellent fix here.References: #2247

  • [orm]

Query will convert an OFFSET of zero whenslicing into None, so that needless OFFSETclauses are not invoked.

  • [orm]

Repaired edge case where mapper would failto fully update internal state when a relationshipon a new mapper would establish a backref on thefirst mapper.

  • [orm]

Fixed bug whereby if eq() wasredefined, a relationship many-to-one lazyloadwould hit the eq() and fail.Does not apply to 0.6.9.References: #2260

  • [orm]

Calling class_mapper() and passing in an objectthat is not a “type” (i.e. a class that couldpotentially be mapped) now raises an informativeArgumentError, rather than UnmappedClassError.References: #2196

  • [orm]

New event hook, MapperEvents.after_configured().Called after a configure() step has completed andmappers were in fact affected. Theoretically thisevent is called once per application, unless new mappingsare constructed after existing ones have been usedalready.

  • [orm]

When an open Session is garbage collected, the objectswithin it which remain are considered detached againwhen they are add()-ed to a new Session.This is accomplished by an extra check that the previous“session_key” doesn’t actually exist among the poolof Sessions.References: #2281

  • [orm]

New declarative features:

  • declare_last() method, establishes an eventlistener for the class method that will be calledwhen mappers are completed with the final “configure”step.

  • abstract flag. The class will not be mappedat all when this flag is present on the class.

  • New helper classes ConcreteBase, AbstractConcreteBase.Allow concrete mappings using declarative which automaticallyset up the “polymorphic_union” when the “configure”mapper step is invoked.

  • The mapper itself has semi-private methods that allowthe “with_polymorphic” selectable to be assignedto the mapper after it has already been configured.

References: #2239

  • [orm]

Declarative will warn when a subclass’ base uses@declared_attr for a regular column - this attributedoes not propagate to subclasses.References: #2283

  • [orm]

The integer “id” used to link a mapped instance withits owning Session is now generated by a sequencegeneration function rather than id(Session), toeliminate the possibility of recycled id() valuescausing an incorrect result, no need to check thatobject actually in the session.References: #2280

  • [orm]

Behavioral improvement: emptyconjunctions such as and() and or() will beflattened in the context of an enclosing conjunction,i.e. and(x, or()) will produce ‘X’ and not ‘X AND()’..References: #2257

  • [orm]

Fixed bug regarding calculation of “from” listfor a select() element. The “from” calc is nowdelayed, so that if the construct uses a Columnobject that is not yet attached to a Table,but is later associated with a Table, it generatesSQL using the table as a FROM. This changeimpacted fairly deeply the mechanics of howthe FROM list as well as the “correlates” collectionis calculated, as some “clause adaption” schemes(these are used very heavily in the ORM)were relying upon the fact that the “froms”collection would typically be cached before theadaption completed. The rework allows itsuch that the “froms” collection can be clearedand re-generated at any time.References: #2261

  • [orm]

Fixed bug whereby with_only_columns() method ofSelect would fail if a selectable were passed.. Also in 0.6.9.References: #2270

engine

  • [engine]

The recreate() method in all pool classes usesself.class to get at the type of poolto produce, in the case of subclassing. Notethere’s no usual need to subclass pools.References: #2254

  • [engine]

Improvement to multi-param statement logging,long lists of bound parameter sets will becompressed with an informative indicatorof the compression taking place. Exceptionmessages use the same improved formatting.References: #2243

  • [engine]

Added optional “sa_pool_key” argument topool.manage(dbapi).connect() so that serializationof args is not necessary.

  • [engine]

The entry point resolution supported bycreate_engine() now supports resolution ofindividual DBAPI drivers on top of a built-inor entry point-resolved dialect, using thestandard ‘+’ notation - it’s converted toa ‘.’ before being resolved as an entrypoint.References: #2286

  • [engine]

Added an exception catch + warning for the“return unicode detection” step within connect,allows databases that crash on NVARCHAR tocontinue initializing, assuming no NVARCHARtype implemented.References: #2299

schema

  • [schema]

Modified Column.copy() to use constructor(),which defaults to self._class, in order tocreate the new object. This allows easier supportof subclassing Column.References: #2284

  • [schema]

Added a slightly nicer repr() to SchemaItemclasses. Note the repr here can’t fully supportthe “repr is the constructor” idea since schemaitems can be very deeply nested/cyclical, havelate initialization of some things, etc.References: #2223

postgresql

  • [postgresql]

Added “postgresql_using” argument to Index(), producesUSING clause to specify index implementation forPG. . Thanks to Ryan P. Kelly forthe patch.References: #2290

  • [postgresql]

Added client_encoding parameter to create_engine()when the postgresql+psycopg2 dialect is used;calls the psycopg2 set_client_encoding() methodwith the value upon connect.References: #1839

  • [postgresql]

Fixed bug related to whereby thesame modified index behavior in PG 9 affectedprimary key reflection on a renamed column.. Also in 0.6.9.References: #2141, #2291

  • [postgresql]

Reflection functions for Table, Sequence no longercase insensitive. Names can be differ only in caseand will be correctly distinguished.References: #2256

  • [postgresql]

Use an atomic counter as the “random number”source for server side cursor names;conflicts have been reported in rare cases.

  • [postgresql]

Narrowed the assumption made when reflectinga foreign-key referenced table with schema inthe current search path; an explicit schema willbe applied to the referenced table only ifit actually matches that of the referencing table,which also has an explicit schema. Previouslyit was assumed that “current” schema was synonymouswith the full search_path.References: #2249

mysql

  • [mysql]

a CREATE TABLE will put the COLLATE optionafter CHARSET, which appears to be part ofMySQL’s arbitrary rules regarding if it will actuallywork or not. Also in 0.6.9.References: #2225

  • [mysql]

Added mysql_length parameter to Index construct,specifies “length” for indexes.References: #2293

sqlite

  • [sqlite]

Ensured that the same ValueError is raised forillegal date/time/datetime string parsed fromthe database regardless of whether Cextensions are in use or not.

mssql

  • [mssql]

Changes to attempt support of FreeTDS 0.91 withPyodbc. This includes that string binds are sent asPython unicode objects when FreeTDS 0.91 is detected,and a CAST(? AS NVARCHAR) is used when we detectfor a table. However, I’d continueto characterize Pyodbc + FreeTDS 0.91 behavior aspretty crappy, there are still many queries suchas used in reflection which cause a core dump onLinux, and it is not really usable at allon OSX, MemoryErrors abound and just plain brokenunicode support.References: #2273

  • [mssql]

The behavior of =/!= when comparing a scalar selectto a value will no longer produce IN/NOT IN as of 0.8;this behavior is a little too heavy handed (use in_() ifyou want to emit IN) and now emits a deprecation warning.To get the 0.8 behavior immediately and remove the warning,a compiler recipe is given athttp://www.sqlalchemy.org/docs/07/dialects/mssql.html#scalar-select-comparisonsto override the behavior of visit_binary().References: #2277

  • [mssql]

“0” is accepted as an argument for limit() whichwill produce “TOP 0”.References: #2222

oracle

  • [oracle]

Fixed ReturningResultProxy for zxjdbc dialect.. Regression from 0.6.References: #2272

  • [oracle]

The String type now generates VARCHAR2 on Oraclewhich is recommended as the default VARCHAR.Added an explicit VARCHAR2 and NVARCHAR2 to the Oracledialect as well. Using NVARCHAR still generates“NVARCHAR2” - there is no “NVARCHAR” on Oracle -this remains a slight breakage of the “uppercase typesalways give exactly that” policy. VARCHAR stillgenerates “VARCHAR”, keeping with the policy. IfOracle were to ever define “VARCHAR” as somethingdifferent as they claim (IMHO this will never happen),the type would be available.References: #2252

misc

  • [types]

Extra keyword arguments to the base Floattype beyond “precision” and “asdecimal” are ignored;added a deprecation warning here and additionaldocs, related toReferences: #2258

  • [ext]

SQLSoup will not be included in version 0.8of SQLAlchemy; while useful, we would like tokeep SQLAlchemy itself focused on one ORMusage paradigm. SQLSoup will hopefullysoon be superseded by a third partyproject.References: #2262

  • [ext]

Added local_attr, remote_attr, attr accessorsto AssociationProxy, providing quick accessto the proxied attributes at the classlevel.References: #2236

  • [ext]

Changed the update() method on association proxydictionary to use a duck typing approach, i.e.checks for “keys”, to discern between update({})and update((a, b)). Previously, passing adictionary that had tuples as keys would be misinterpretedas a sequence.References: #2275

  • [examples]

Adjusted dictlike-polymorphic.py exampleto apply the CAST such that it works onPG, other databases.Also in 0.6.9.References: #2266

0.7.2

Released: Sun Jul 31 2011

orm

  • [orm]

Feature enhancement: joined and subqueryloading will now traverse already-present relatedobjects and collections in search of unpopulatedattributes throughout the scope of the eager loadbeing defined, so that the eager loading that isspecified via mappings or query optionsunconditionally takes place for the full depth,populating whatever is not already populated.Previously, this traversal would stop if a relatedobject or collection were already present leadingto inconsistent behavior (though would save onloads/cycles for an already-loaded graph). For asubqueryload, this means that the additionalSELECT statements emitted by subqueryload willinvoke unconditionally, no matter how much of theexisting graph is already present (hence thecontroversy). The previous behavior of “stopping”is still in effect when a query is the result ofan attribute-initiated lazyload, as otherwise an“N+1” style of collection iteration can becomeneedlessly expensive when the same related objectis encountered repeatedly. There’s also anas-yet-not-public generative Query method_with_invoke_all_eagers()which selects old/new behaviorReferences: #2213

  • [orm]

A rework of “replacement traversal” withinthe ORM as it alters selectables to be againstaliases of things (i.e. clause adaption) includesa fix for multiply-nested any()/has() constructsagainst a joined table structure.References: #2195

  • [orm]

Fixed bug where query.join() + aliased=Truefrom a joined-inh structure to itself onrelationship() with join condition on the childtable would convert the lead entity into thejoined one inappropriately.Also in 0.6.9.References: #2234

  • [orm]

Fixed regression from 0.6 where Session.add()against an object which contained None in acollection would raise an internal exception.Reverted this to 0.6’s behavior which is toaccept the None but obviously nothing ispersisted. Ideally, collections with Nonepresent or on append() should at least emit awarning, which is being considered for 0.8.References: #2205

  • [orm]

Load of a deferred() attribute on an objectwhere row can’t be located raisesObjectDeletedError instead of failing lateron; improved the message in ObjectDeletedErrorto include other conditions besides a simple“delete”.References: #2191

  • [orm]

Fixed regression from 0.6 where a get historyoperation on some relationship() based attributeswould fail when a lazyload would emit; this couldtrigger within a flush() under certain conditions. Thanks to the user who submittedthe great test for this.References: #2224

  • [orm]

Fixed bug apparent only in Python 3 wherebysorting of persistent + pending objects duringflush would produce an illegal comparison,if the persistent object primary keyis not a single integer.Also in 0.6.9References: #2228

  • [orm]

Fixed bug whereby the source clauseused by query.join() would be inconsistentif against a column expression that combinedmultiple entities together.Also in 0.6.9References: #2197

  • [orm]

Fixed bug whereby if a mapped classredefined hash() or eq() to somethingnon-standard, which is a supported use caseas SQLA should never consult these,the methods would be consulted if the classwas part of a “composite” (i.e. non-single-entity)result set.Also in 0.6.9.References: #2215

  • [orm]

Added public attribute “.validators” toMapper, an immutable dictionary view ofall attributes that have been decoratedwith the @validates decorator. courtesy Stefano FontanelliReferences: #2240

  • [orm]

Fixed subtle bug that caused SQL to blowup if: column_property() against subquery +joinedload + LIMIT + order by the columnproperty() occurred. .Also in 0.6.9References: #2188

  • [orm]

The join condition produced by with_parentas well as when using a “dynamic” relationshipagainst a parent will generate uniquebindparams, rather than incorrectly repeatingthe same bindparam. .Also in 0.6.9.References: #2207

  • [orm]

Added the same “columns-only” check tomapper.polymorphic_on as used whenreceiving user arguments torelationship.order_by, foreign_keys,remote_side, etc.

  • [orm]

Fixed bug whereby comparison of columnexpression to a Query() would not callas_scalar() on the underlying SELECTstatement to produce a scalar subquery,in the way that occurs if you calledit on Query().subquery().References: #2190

  • [orm]

Fixed declarative bug where a class inheritingfrom a superclass of the same name would faildue to an unnecessary lookup of the namein the _decl_class_registry.References: #2194

  • [orm]

Repaired the “no statement condition”assertion in Query which would attemptto raise if a generative method were calledafter from_statement() were called.. Also in 0.6.9.References: #2199

engine

  • [engine]

Context manager provided by Connection.begin()will issue rollback() if the commit() fails,not just if an exception occurs.

  • [engine]

Use urllib.parse_qsl() in Python 2.6 and above,no deprecation warning about cgi.parse_qsl()References: #1682

  • [engine]

Added mixin class sqlalchemy.ext.DontWrapMixin.User-defined exceptions of this type are neverwrapped in StatementException when theyoccur in the context of a statementexecution.

  • [engine]

StatementException wrapping will display theoriginal exception class in the message.

  • [engine]

Failures on connect which raise dbapi.Errorwill forward the error to dialect.is_disconnect()and set the “connection_invalidated” flag ifthe dialect knows this to be a potentially“retryable” condition. Only Oracle ORA-01033implemented for now.References: #2201

sql

  • [sql]

Fixed two subtle bugs involving columncorrespondence in a selectable,one with the same labeled subquery repeated, the otherwhen the label has been “grouped” andloses itself. Affects.References: #2188

schema

  • [schema]

New feature: with_variant() method onall types. Produces an instance of Variant(),a special TypeDecorator which will selectthe usage of a different type based on thedialect in use.References: #2187

  • [schema]

Added an informative error message whenForeignKeyConstraint refers to a column name inthe parent that is not found. Also in 0.6.9.

  • [schema]

Fixed bug whereby adaptation of old append_ddl_listener()function was passing unexpected **kw throughto the Table event. Table gets no kws, the MetaDataevent in 0.6 would get “tables=somecollection”,this behavior is preserved.References: #2206

  • [schema]

Fixed bug where “autoincrement” detection onTable would fail if the type had no “affinity”value, in particular this would occur when usingthe UUID example on the site that uses TypeEngineas the “impl”.

  • [schema]

Added an improved repr() to TypeEngine objectsthat will only display constructor args whichare positional or kwargs that deviatefrom the default.References: #2209

postgresql

  • [postgresql]

Added new “postgresql_ops” argument toIndex, allows specification of PostgreSQLoperator classes for indexed columns. Courtesy Filip Zyzniewski.References: #2198

mysql

  • [mysql]

Fixed OurSQL dialect to use ansi-neutralquote symbol “’” for XA commands insteadof ‘”’. . Also in 0.6.9.References: #2186

sqlite

  • [sqlite]

SQLite dialect no longer strips quotesoff of reflected default value, allowinga round trip CREATE TABLE to work.This is consistent with other dialectsthat also maintain the exact form ofthe default.References: #2189

mssql

  • [mssql]

Adjusted the pyodbc dialect such that boundvalues are passed as bytes and not unicodeif the “Easysoft” unix drivers are detected.This is the same behavior as occurs withFreeTDS. Easysoft appears to segfaultif Python unicodes are passed undercertain circumstances.

oracle

  • [oracle]

Added ORA-00028 to disconnect codes, usecx_oracle _Error.code to get at the code,. Also in 0.6.9.References: #2200

  • [oracle]

Added ORA-01033 to disconnect codes, whichcan be caught during a connectionevent.References: #2201

  • [oracle]

repaired the oracle.RAW type which did notgenerate the correct DDL.Also in 0.6.9.References: #2220

  • [oracle]

added CURRENT to reserved word list. Also in 0.6.9.References: #2212

  • [oracle]

Fixed bug in the mutable extension wherebyif the same type were used twice in onemapping, the attributes beyond the firstwould not get instrumented.

  • [oracle]

Fixed bug in the mutable extension wherebyif None or a non-corresponding type were set,an error would be raised. None is now acceptedwhich assigns None to all attributes,illegal values raise ValueError.

misc

  • [examples]

Repaired the examples/versioning test runnerto not rely upon SQLAlchemy test libs,nosetests must be run from withinexamples/versioning to get around setup.cfgbreaking it.

  • [examples]

Tweak to examples/versioning to pick thecorrect foreign key in a multi-levelinheritance situation.

  • [examples]

Fixed the attribute shard example to checkfor bind param callable correctly in 0.7style.

0.7.1

Released: Sun Jun 05 2011

general

  • [general]

Added a workaround for Python bug 7511 wherefailure of C extension build does notraise an appropriate exception on Windows 64bit + VC expressReferences: #2184

orm

  • [orm]

“delete-orphan” cascade is now allowed onself-referential relationships - this sinceSQLA 0.7 no longer enforces “parent with nochild” at the ORM level; this check is leftup to foreign key nullability.Related toReferences: #1912

  • [orm]

Repaired new “mutable” extension to propagateevents to subclasses correctly; don’tcreate multiple event listeners forsubclasses either.References: #2180

  • [orm]

Modify the text of the message which occurswhen the “identity” key isn’t detected onflush, to include the common cause thatthe Column isn’t set up to detectauto-increment correctly;.Also in 0.6.8.References: #2170

  • [orm]

Fixed bug where transaction-level “deleted”collection wouldn’t be cleared of expungedstates, raising an error if they laterbecame transient.Also in 0.6.8.References: #2182

engine

  • [engine]

Deprecate schema/SQL-oriented methods onConnection/Engine that were never well knownand are redundant: reflecttable(), create(),drop(), text(), engine.func

  • [engine]

Adjusted the contains() method ofa RowProxy result row such that no exceptionthrow is generated internally;NoSuchColumnError() also will generate itsmessage regardless of whether or not the columnconstruct can be coerced to a string.. Also in 0.6.8.References: #2178

sql

  • [sql]

Fixed bug whereby metadata.reflect(bind)would close a Connection passed as abind argument. Regression from 0.6.

  • [sql]

Streamlined the process by which a Selectdetermines what’s in its ‘.c’ collection.Behaves identically, except that araw ClauseList() passed to select([])(which is not a documented case anyway) willnow be expanded into its individual columnelements instead of being ignored.

postgresql

  • [postgresql]

Some unit test fixes regarding numeric arrays,MATCH operator. A potential floating-pointinaccuracy issue was fixed, and certain testsof the MATCH operator only execute within anEN-oriented locale for now. .Also in 0.6.8.References: #2175

mysql

  • [mysql]

Unit tests pass 100% on MySQL installedon windows.

  • [mysql]

Removed the “adjust casing” step that wouldfail when reflecting a table on MySQLon windows with a mixed case name. After someexperimenting with a windows MySQL server, it’sbeen determined that this step wasn’t reallyhelping the situation much; MySQL does not returnFK names with proper casing on non-windowsplatforms either, and removing the step atleast allows the reflection to act more likeit does on other OSes. A warning herehas been considered but its difficult todetermine under what conditions such a warningcan be raised, so punted on that for now -added some docs instead.References: #2181

  • [mysql]

supports_sane_rowcount will be set to Falseif using MySQLdb and the DBAPI doesn’t providethe constants.CLIENT module.

sqlite

  • [sqlite]

Accept None from cursor.fetchone() when“PRAGMA read_uncommitted” is called to determinecurrent isolation mode at connect time anddefault to SERIALIZABLE; this to support SQLiteversions pre-3.3.0 that did not have thisfeature.References: #2173

0.7.0

Released: Fri May 20 2011

orm

  • [orm]

Fixed regression introduced in 0.7b4 (!) wherebyquery.options(someoption(“nonexistent name”)) wouldfail to raise an error. Also added additionalerror catching for cases where the option wouldtry to build off a column-based element, furtherfixed up some of the error messages tailoredinReferences: #2069

  • [orm]

query.count() emits “count(*)” instead of“count(1)”.References: #2162

  • [orm]

Fine tuning of Query clause adaptation whenfromself(), union(), or other “select frommyself” operation, such that plain SQL expressionelements added to filter(), order_by() etc.which are present in the nested “from myself”query _will be adapted in the same way an ORMexpression element will, since theseelements are otherwise not easily accessible.References: #2155

  • [orm]

Fixed bug where determination of “self referential”relationship would fail with no workaroundfor joined-inh subclass related to itself,or joined-inh subclass related to a subclassof that with no cols in the sub-sub classin the join condition.Also in 0.6.8.References: #2149

  • [orm]

mapper() will ignore non-configured foreign keysto unrelated tables when determining inheritcondition between parent and child class,but will raise as usual for unresolvedcolumns and table names regarding the inheritedtable. This is an enhanced generalization ofbehavior that was already applied to declarativepreviously. 0.6.8 has a moreconservative version of this which doesn’tfundamentally alter how join conditionsare determined.References: #2153

  • [orm]

It is an error to call query.get() when thegiven entity is not a single, full classentity or mapper (i.e. a column). This isa deprecation warning in 0.6.8.References: #2144

  • [orm]

Fixed a potential KeyError which under somecircumstances could occur with the identitymap, part ofReferences: #2148

  • [orm]

added Query.with_session() method, switchesQuery to use a different session.

  • [orm]

horizontal shard query should use executionoptions per connection as perReferences: #2131

  • [orm]

a non_primary mapper will inherit the _identity_classof the primary mapper. This so that a non_primaryestablished against a class that’s normally in aninheritance mapping will produce results that areidentity-map compatible with that of the primarymapper (also in 0.6.8)References: #2151

  • [orm]

Fixed the error message emitted for “can’texecute syncrule for destination column ‘q’;mapper ‘X’ does not map this column” toreference the correct mapper. .Also in 0.6.8.References: #2163

  • [orm]

polymorphic_union() gets a “cast_nulls” option,disables the usage of CAST when it rendersthe labeled NULL columns.References: #1502

  • [orm]

polymorphic_union() renders the columns in theiroriginal table order, as according to the firsttable/selectable in the list of polymorphicunions in which they appear. (which is itselfan unordered mapping unless you pass an OrderedDict).

  • [orm]

Fixed bug whereby mapper mapped to an anonymousalias would fail if logging were used, due tounescaped % sign in the alias name.Also in 0.6.8.References: #2171

sql

  • [sql]

Fixed bug whereby nesting a label of a select()with another label in it would produce incorrectexported columns. Among other things this wouldbreak an ORM column_property() mapping againstanother column_property(). .Also in 0.6.8References: #2167

  • [sql]

Changed the handling in determination of joinconditions such that foreign key errors areonly considered between the two given tables.That is, t1.join(t2) will report FK errorsthat involve ‘t1’ or ‘t2’, but anythinginvolving ‘t3’ will be skipped. This affectsjoin(), as well as ORM relationship andinherit condition logic.

  • [sql]

Some improvements to error handling insideof the execute procedure to ensure auto-closeconnections are really closed when veryunusual DBAPI errors occur.

  • [sql]

metadata.reflect() and reflection.Inspector()had some reliance on GC to close connectionswhich were internally procured, fixed this.

  • [sql]

Added explicit check for when Column .nameis assigned as blank stringReferences: #2140

  • [sql]

Fixed bug whereby if FetchedValue was passedto column server_onupdate, it would nothave its parent “column” assigned, addedtest coverage for all column default assignmentpatterns. also in 0.6.8References: #2147

postgresql

  • [postgresql]

Fixed the psycopg2_version parsing in thepsycopg2 dialect.

  • [postgresql]

Fixed bug affecting PG 9 whereby index reflectionwould fail if against a column whose namehad changed. . Also in 0.6.8.References: #2141

mssql

  • [mssql]

Fixed bug in MSSQL dialect whereby the aliasingapplied to a schema-qualified table would leakinto enclosing select statements.Also in 0.6.8.References: #2169

misc

This section documents those changes from 0.7b4to 0.7.0. For an overview of what’s new inSQLAlchemy 0.7, seehttp://docs.sqlalchemy.org/en/latest/changelog/migration_07.html

  • [documentation]

Removed the usage of the “collections.MutableMapping”abc from the ext.mutable docs as it was being usedincorrectly and makes the example more difficultto understand in any case.References: #2152

  • [examples]

removed the ancient “polymorphic association”examples and replaced with an updated set ofexamples that use declarative mixins,“generic_associations”. Each presents an alternativetable layout.

  • [ext]

Fixed bugs in sqlalchemy.ext.mutable extension whereNone was not appropriately handled, replacementevents were not appropriately handled.References: #2143

0.7.0b4

Released: Sun Apr 17 2011

general

  • [general]

Changes to the format of CHANGES, this file.The format changes have been applied tothe 0.7 releases.

  • [general]

The “-declarative” changes will now be listeddirectly under the “-orm” section, as theseare closely related.

  • [general]

The 0.5 series changes have been moved tothe file CHANGES_PRE_06 which replacesCHANGES_PRE_05.

  • [general]

The changelog for 0.6.7 and subsequent withinthe 0.6 series is now listed only in theCHANGES file within the 0.6 branch.In the 0.7 CHANGES file (i.e. this file), all the0.6 changes are listed inline within the 0.7section in which they were also applied(since all 0.6 changes are in 0.7 as well).Changes that apply to an 0.6 version hereare noted as are if any differences inimplementation/behavior are present.

orm

  • [orm]

Some fixes to “evaluate” and “fetch” evaluationwhen query.update(), query.delete() are called.The retrieval of records is done after autoflushin all cases, and before update/delete isemitted, guarding against unflushed data presentas well as expired objects failing duringthe evaluation.References: #2122

  • [orm]

Reworded the exception raised when a flushis attempted of a subclass that is not polymorphicagainst the supertype.References: #2063

  • [orm]

Still more wording adjustments when a query optioncan’t find the target entity. Explain that thepath must be from one of the root entities.

  • [orm]

Some fixes to the state handling regardingbackrefs, typically when autoflush=False, wherethe back-referenced collection wouldn’tproperly handle add/removes with no netchange. Thanks to Richard Murri for thetest case + patch.(also in 0.6.7).References: #2123

  • [orm]

Added checks inside the UOW to detect the unusualcondition of being asked to UPDATE or DELETEon a primary key value that contains NULLin it.References: #2127

  • [orm]

Some refinements to attribute history. Morechanges are pending possibly in 0.8, butfor now history has been modified such thatscalar history doesn’t have a “side effect”of populating None for a non-present value.This allows a slightly better ability todistinguish between a None set and no actualchange, affects as well.References: #2127

  • [orm]

a “having” clause would be copied from theinside to the outside query if from_self()were used; in particular this would breakan 0.7 style count() query.(also in 0.6.7)References: #2130

  • [orm]

the Query.execution_options() method now passesthose options to the Connection rather thanthe SELECT statement, so that all availableoptions including isolation level andcompiled cache may be used.References: #2131

engine

  • [engine]

The C extension is now enabled by default on CPython2.x with a fallback to pure python if it fails tocompile.References: #2129

sql

  • [sql]

The “compiled_cache” execution option now raisesan error when passed to a SELECT statementrather than a Connection. Previously it wasbeing ignored entirely. We may look intohaving this option work on a per-statementlevel at some point.References: #2131

  • [sql]

Restored the “catchall” constructor on the baseTypeEngine class, with a deprecation warning.This so that code which does something likeInteger(11) still succeeds.

  • [sql]

Fixed regression whereby MetaData() comingback from unpickling did not keep track ofnew things it keeps track of now, i.e.collection of Sequence objects, listof schema names.References: #2104

  • [sql]

The limit/offset keywords to select() as wellas the value passed to select.limit()/offset()will be coerced to integer.(also in 0.6.7)References: #2116

  • [sql]

fixed bug where “from” clause gathering from anover() clause would be an itertools.chain() andnot a list, causing “can only concatenate list”TypeError when combined with other clauses.

  • [sql]

Fixed incorrect usage of “,” in over() clausebeing placed between the “partition” and “order by”clauses.References: #2134

  • [sql]

Before/after attach events for PrimaryKeyConstraintnow function, tests added for before/after eventson all constraint types.References: #2105

  • [sql]

Added explicit true()/false() constructs to expressionlib - coercion rules will intercept “False”/”True”into these constructs. In 0.6, the constructs weretypically converted straight to string, which wasno longer accepted in 0.7.References: #2117

schema

  • [schema]

The ‘useexisting’ flag on Table has been supersededby a new pair of flags ‘keep_existing’ and‘extend_existing’. ‘extend_existing’ is equivalentto ‘useexisting’ - the existing Table is returned,and additional constructor elements are added.With ‘keep_existing’, the existing Table is returned,but additional constructor elements are not added -these elements are only applied when the Tableis newly created.References: #2109

postgresql

  • [postgresql]

Psycopg2 for Python 3 is now supported.

  • [postgresql]

Fixed support for precision numerics when usingpg8000.References: #2132

sqlite

  • [sqlite]

Fixed bug where reflection of foreign keycreated as “REFERENCES ” withoutcol name would fail.(also in 0.6.7)References: #2115

oracle

  • [oracle]

Using column names that would require quotesfor the column itself or for a name-generatedbind parameter, such as names with specialcharacters, underscores, non-ascii characters,now properly translate bind parameter keys whentalking to cx_oracle. (Alsoin 0.6.7)References: #2100

  • [oracle]

Oracle dialect adds use_binds_for_limits=Falsecreate_engine() flag, will render the LIMIT/OFFSETvalues inline instead of as binds, reported tomodify the execution plan used by Oracle. (Also in 0.6.7)References: #2116

misc

  • [types]

REAL has been added to the core types. Supportedby PostgreSQL, SQL Server, MySQL, SQLite. Notethat the SQL Server and MySQL versions, whichadd extra arguments, are also still availablefrom those dialects.References: #2081

  • [types]

Added @event.listens_for() decorator, giventarget + event name, applies the decoratedfunction as a listener.References: #2106

  • [pool]

AssertionPool now stores the traceback indicatingwhere the currently checked out connection wasacquired; this traceback is reported withinthe assertion raised upon a second concurrentcheckout; courtesy Gunnlaugur BriemReferences: #2103

  • [pool]

The “pool.manage” feature doesn’t use pickleanymore to hash the arguments for each pool.

  • [documentation]

Documented SQLite DATE/TIME/DATETIME types. (also in 0.6.7)References: #2029

  • [documentation]

Fixed mutable extension docs to show thecorrect type-association methods.References: #2118

0.7.0b3

Released: Sun Mar 20 2011

general

  • [general]

Lots of fixes to unit tests when run under PyPy(courtesy Alex Gaynor).

orm

  • [orm]

Changed the underlying approach to query.count().query.count() is now in all cases exactly:

query.

from_self(func.count(literal_column(‘1’))).scalar()

That is, “select count(1) from ()”.This produces a subquery in all cases, butvastly simplifies all the guessing count()tried to do previously, which would stillfail in many scenarios particularly whenjoined table inheritance and other joinswere involved. If the subquery producedfor an otherwise very simple count is reallyan issue, use query(func.count()) as anoptimization.References: #2093

  • [orm]

some changes to the identity map regardingrare weakref callbacks during iterations.The mutex has been removed as it apparentlycan cause a reentrant (i.e. in one thread) deadlock,perhaps when gc collects objects at the point ofiteration in order to gain more memory. It is hopedthat “dictionary changed during iteration” willbe exceedingly rare as iteration methods internallyacquire the full list of objects in a single values()call. Note 0.6.7 has a more conservative fix herewhich still keeps the mutex in place.References: #2087

  • [orm]

A tweak to the unit of work causes it to orderthe flush along relationship() dependencies even ifthe given objects don’t have any inter-attributereferences in memory, which was the behavior in0.5 and earlier, so a flush of Parent/Child withonly foreign key/primary key set will succeed.This while still maintaining 0.6 and above’s notgenerating a ton of useless internal dependencystructures within the flush that don’t correspondto state actually within the current flush.References: #2082

  • [orm]

Improvements to the error messages emitted whenquerying against column-only entities in conjunctionwith (typically incorrectly) using loader options,where the parent entity is not fully present.References: #2069

  • [orm]

Fixed bug in query.options() whereby a pathapplied to a lazyload using string keys couldoverlap a same named attribute on the wrongentity. Note 0.6.7 has a more conservative fixto this.References: #2098

engine

  • [engine]

Fixed AssertionPool regression bug.References: #2097

  • [engine]

Changed exception raised to ArgumentError when aninvalid dialect is specified.References: #2060

sql

  • [sql]

Added a fully descriptive error message for thecase where Column is subclassed and _make_proxy()fails to make a copy due to TypeError on theconstructor. The method _constructor shouldbe implemented in this case.

  • [sql]

Added new event “column_reflect” for Table objects.Receives the info dictionary about a Column beforethe object is generated within reflection, and allowsmodification to the dictionary for control overmost aspects of the resulting Column includingkey, name, type, info dictionary.References: #2095

  • [sql]

To help with the “column_reflect” event being usedwith specific Table objects instead of all instancesof Table, listeners can be added to a Table objectinline with its construction using a new argument“listeners”, a list of tuples of the form(, ), which are applied to the Tablebefore the reflection process begins.

  • [sql]

Added new generic function “next_value()”, acceptsa Sequence object as its argument and renders theappropriate “next value” generation string on thetarget platform, if supported. Also provides“.next_value()” method on Sequence itself.References: #2085

  • [sql]

func.next_value() or other SQL expression canbe embedded directly into an insert() construct,and if implicit or explicit “returning” is usedin conjunction with a primary key column,the newly generated value will be present inresult.inserted_primary_key.References: #2084

  • [sql]

Added accessors to ResultProxy “returns_rows”,“is_insert” (also in 0.6.7)References: #2089

postgresql

  • [postgresql]

Added RESERVED_WORDS for postgresql dialect.(also in 0.6.7)References: #2092

  • [postgresql]

Fixed the BIT type to allow a “length” parameter, “varying”parameter. Reflection also fixed.(also in 0.6.7)References: #2073

mssql

  • [mssql]

Rewrote the query used to get the definition of a view,typically when using the Inspector interface, touse sys.sql_modules instead of the information schema,thereby allowing views definitions longer than 4000characters to be fully returned.(also in 0.6.7)References: #2071

firebird

  • [firebird]

The “implicit_returning” flag on create_engine() ishonored if set to False. (also in 0.6.7)References: #2083

misc

  • [declarative]

Arguments in mapper_args that aren’t “hashable”aren’t mistaken for always-hashable, possibly-columnarguments. (also in 0.6.7)References: #2091

  • [informix]

Added RESERVED_WORDS informix dialect.(also in 0.6.7)References: #2092

  • [ext]

The horizontal_shard ShardedSession class accepts the commonSession argument “query_cls” as a constructor argument,to enable further subclassing of ShardedQuery. (also in 0.6.7)References: #2090

  • [examples]

Updated the association, association proxy examplesto use declarative, added a new exampledict_of_sets_with_default.py, a “pushing the envelope”example of association proxy.

  • [examples]

The Beaker caching example allows a “query_cls” argumentto the query_callable() function.(also in 0.6.7)References: #2090

0.7.0b2

Released: Sat Feb 19 2011

orm

  • [orm]

Fixed bug whereby Session.merge() would call theload() event with one too few arguments.References: #2053

  • [orm]

Added logic which prevents the generation ofevents from a MapperExtension or SessionExtensionfrom generating do-nothing events for all the methodsnot overridden.References: #2052

sql

  • [sql]

Renamed the EngineEvents event class toConnectionEvents. As these classes are neveraccessed directly by end-user code, this strictlyis a documentation change for end users. Alsosimplified how events get linked to enginesand connections internally.References: #2059

  • [sql]

The Sequence() construct, when passed a MetaData()object via its ‘metadata’ argument, will beincluded in CREATE/DROP statements withinmetadata.create_all() and metadata.drop_all(),including “checkfirst” logic.References: #2055

  • [sql]

The Column.references() method now returns Trueif it has a foreign key referencing thegiven column exactly, not just its parenttable.References: #2064

postgresql

  • [postgresql]

Fixed regression from 0.6 where SMALLINT andBIGINT types would both generate SERIALon an integer PK column, instead ofSMALLINT and BIGSERIALReferences: #2065

misc

  • [declarative]

Fixed regression whereby composite() withColumn objects placed inline would failto initialize. The Column objects can nowbe inline with the composite() or externaland pulled in via name or object ref.References: #2058

  • [declarative]

Fix error message referencing old @classpropertyname to reference @declared_attr(also in 0.6.7)References: #2061

  • [declarative]

the dictionary at the end of the table_argstuple is now optional.References: #1468

  • [ext]

Association proxy now has correct behavior forany(), has(), and contains() when proxyinga many-to-one scalar attribute to a one-to-manycollection (i.e. the reverse of the ‘typical’association proxy use case)References: #2054

  • [examples]

Beaker example now takes into account ‘limit’and ‘offset’, bind params within embeddedFROM clauses (like when you use union() orfrom_self()) when generating a cache key.

0.7.0b1

Released: Sat Feb 12 2011

general

  • [general]

New event system, supersedes all extensions, listeners,etc.References: #1902

  • [general]

Logging enhancementsReferences: #1926

  • [general]

Setup no longer installs a Nose pluginReferences: #1949

  • [general]

The “sqlalchemy.exceptions” alias in sys.moduleshas been removed. Base SQLA exceptions areavailable via “from sqlalchemy import exc”.The “exceptions” alias for “exc” remains in“sqlalchemy” for now, it’s just not patched intosys.modules.

orm

  • [orm]

More succinct form of query.join(target, onclause)References: #1923

  • [orm]

Hybrid Attributes, implements/supersedes synonym()References: #1903

  • [orm]

Rewrite of compositesReferences: #2008

  • [orm]

Mutation Event Extension, supersedes “mutable=True”

See also

Mutation event extension, supersedes “mutable=True”

  • [orm]

PickleType and ARRAY mutability turned off by defaultReferences: #1980

  • [orm]

Simplified polymorphic_on assignmentReferences: #1895

  • [orm]

Flushing of Orphans that have no parent is allowedReferences: #1912

  • [orm]

Adjusted flush accounting step to occur beforethe commit in the case of autocommit=True. This allowsautocommit=True to work appropriately withexpire_on_commit=True, and also allows post-flush sessionhooks to operate in the same transactional contextas when autocommit=False.References: #2041

  • [orm]

Warnings generated when collection members, scalar referentsnot part of the flushReferences: #1973

  • [orm]

Non-Table-derived constructs can be mappedReferences: #1876

  • [orm]

Tuple label names in Query ImprovedReferences: #1942

  • [orm]

Mapped column attributes reference the most specificcolumn firstReferences: #1892

  • [orm]

Mapping to joins with two or more same-named columnsrequires explicit declarationReferences: #1896

  • [orm]

Mapper requires that polymorphic_on column be presentin the mapped selectableReferences: #1875

  • [orm]

compile_mappers() renamed configure_mappers(), simplifiedconfiguration internalsReferences: #1966

  • [orm]

the aliased() function, if passed a SQL FromClause element(i.e. not a mapped class), will return element.alias()instead of raising an error on AliasedClass.References: #2018

  • [orm]

Session.merge() will check the version id of the incomingstate against that of the database, assuming the mappinguses version ids and incoming state has a version_idassigned, and raise StaleDataError if they don’tmatch.References: #2027

  • [orm]

Session.connection(), Session.execute() accept ‘bind’,to allow execute/connection operations to participatein the open transaction of an engine explicitly.References: #1996

  • [orm]

Query.join(), Query.outerjoin(), eagerload(),eagerload_all(), others no longer allow listsof attributes as arguments (i.e. option([x, y, z])form, deprecated since 0.5)

  • [orm]

ScopedSession.mapper is removed (deprecated since 0.5).

  • [orm]

Horizontal shard query places ‘shard_id’ incontext.attributes where it’s accessible by the“load()” event.References: #2031

  • [orm]

A single contains_eager() call acrossmultiple entities will indicate all collectionsalong that path should load, instead of requiringdistinct contains_eager() calls for each endpoint(which was never correctly documented).References: #2032

  • [orm]

The “name” field used in orm.aliased() now rendersin the resulting SQL statement.

  • [orm]

Session weak_instance_dict=False is deprecated.References: #1473

  • [orm]

An exception is raised in the unusual case that anappend or similar event on a collection occurs afterthe parent object has been dereferenced, whichprevents the parent from being marked as “dirty”in the session. Was a warning in 0.6.6.References: #2046

  • [orm]

Query.distinct() now accepts column expressionsas *args, interpreted by the PostgreSQL dialectas DISTINCT ON ().References: #1069

  • [orm]

Additional tuning to “many-to-one” relationshiploads during a flush(). A change in version 0.6.6([ticket:2002]) required that more “unnecessary” m2oloads during a flush could occur. Extra loading modes havebeen added so that the SQL emitted in thisspecific use case is trimmed back, while stillretrieving the information the flush needs in orderto not miss anything.References: #2049

  • [orm]

the value of “passive” as passed toattributes.get_history() should be one of theconstants defined in the attributes package. SendingTrue or False is deprecated.

  • [orm]

Added a name argument to Query.subquery(), to allowa fixed name to be assigned to the alias object. (also in 0.6.7)References: #2030

  • [orm]

A warning is emitted when a joined-table inheriting mapperhas no primary keys on the locally mapped table(but has pks on the superclass table).(also in 0.6.7)References: #2019

  • [orm]

Fixed bug where “middle” class in a polymorphic hierarchywould have no ‘polymorphic_on’ column if it didn’t alsospecify a ‘polymorphic_identity’, leading to strangeerrors upon refresh, wrong class loaded when queryingfrom that target. Also emits the correct WHERE criterionwhen using single table inheritance.(also in 0.6.7)References: #2038

  • [orm]

Fixed bug where a column with a SQL or server side defaultthat was excluded from a mapping with include_propertiesor exclude_properties would result in UnmappedColumnError. (also in 0.6.7)References: #1995

  • [orm]

A warning is emitted in the unusual case that anappend or similar event on a collection occurs afterthe parent object has been dereferenced, whichprevents the parent from being marked as “dirty”in the session. This will be an exception in 0.7. (also in 0.6.7)References: #2046

sql

  • [sql]

Added over() function, method to FunctionElementclasses, produces the _Over() construct whichin turn generates “window functions”, i.e.“ OVER (PARTITION BY ,ORDER BY )”.References: #1844

  • [sql]

LIMIT/OFFSET clauses now use bind parametersReferences: #805

  • [sql]

select.distinct() now accepts column expressionsas *args, interpreted by the PostgreSQL dialectas DISTINCT ON (). Note this was alreadyavailable via passing a list to the _distinct_keyword argument to select().References: #1069

  • [sql]

select.prefix_with() accepts multiple expressions(i.e. *expr), ‘prefix’ keyword argument to select()accepts a list or tuple.

  • [sql]

Passing a string to the distinct keyword argumentof select() for the purpose of emitting specialMySQL keywords (DISTINCTROW etc.) is deprecated -use prefix_with() for this.

  • [sql]

TypeDecorator works with primary key columnsReferences: #2005, #2006

  • [sql]

DDL() constructs now escape percent signsReferences: #1897

  • [sql]

Table.c / MetaData.tables refined a bit, don’t allow directmutationReferences: #1893, #1917

  • [sql]

Callables passed to bindparam() don’t get evaluatedReferences: #1950

  • [sql]

types.type_map is now private, types._type_mapReferences: #1870

  • [sql]

Non-public Pool methods underscoredReferences: #1982

  • [sql]

Added NULLS FIRST and NULLS LAST support. It’s implementedas an extension to the asc() and desc() operators, callednullsfirst() and nullslast().References: #723

  • [sql]

The Index() construct can be created inline with a Tabledefinition, using strings as column names, as an alternativeto the creation of the index outside of the Table.

  • [sql]

execution_options() on Connection accepts“isolation_level” argument, sets transaction isolationlevel for that connection only until returned to theconnection pool, for those backends which support it(SQLite, PostgreSQL)References: #2001

  • [sql]

A TypeDecorator of Integer can be used with a primary keycolumn, and the “autoincrement” feature of various dialectsas well as the “sqlite_autoincrement” flag will honorthe underlying database type as being Integer-based.References: #2005

  • [sql]

Established consistency when server_default is presenton an Integer PK column. SQLA doesn’t pre-fetch these,nor do they come back in cursor.lastrowid (DBAPI).Ensured all backends consistently return Nonein result.inserted_primary_key for these. Regardingreflection for this case, reflection of an int PK colwith a server_default sets the “autoincrement” flag to False,except in the case of a PG SERIAL col where we detected asequence default.References: #2020, #2021

  • [sql]

Result-row processors are applied to pre-executed SQLdefaults, as well as cursor.lastrowid, when determiningthe contents of result.inserted_primary_key.References: #2006

  • [sql]

Bind parameters present in the “columns clause” of a selectare now auto-labeled like other “anonymous” clauses,which among other things allows their “type” to be meaningfulwhen the row is fetched, as in result row processors.

  • [sql]

TypeDecorator is present in the “sqlalchemy” import space.

  • [sql]

Non-DBAPI errors which occur in the scope of an _execute()_call are now wrapped in sqlalchemy.exc.StatementError,and the text of the SQL statement and repr() of paramsis included. This makes it easier to identify statementexecutions which fail before the DBAPI becomesinvolved.References: #2015

  • [sql]

The concept of associating a “.bind” directly with aClauseElement has been explicitly moved to Executable,i.e. the mixin that describes ClauseElements which representengine-executable constructs. This change is an improvementto internal organization and is unlikely to affect anyreal-world usage.References: #2048

  • [sql]

Column.copy(), as used in table.tometadata(), copies the‘doc’ attribute. (also in 0.6.7)References: #2028

  • [sql]

Added some defs to the resultproxy.c extension so thatthe extension compiles and runs on Python 2.4. (also in 0.6.7)References: #2023

  • [sql]

The compiler extension now supports overriding the defaultcompilation of expression._BindParamClause including thatthe auto-generated binds within the VALUES/SET clauseof an insert()/update() statement will also use the newcompilation rules. (also in 0.6.7)References: #2042

  • [sql]

SQLite dialect now uses NullPool for file-based databasesReferences: #1921

  • [sql]

The path given as the location of a sqlite database is nownormalized via os.path.abspath(), so that directory changeswithin the process don’t affect the ultimate locationof a relative file path.References: #2036

postgresql

  • [postgresql]

When explicit sequence execution derives the nameof the auto-generated sequence of a SERIAL column,which currently only occurs if implicit_returning=False,now accommodates if the table + column name is greaterthan 63 characters using the same logic PostgreSQL uses. (also in 0.6.7)References: #1083

  • [postgresql]

Added an additional libpq message to the list of “disconnect”exceptions, “could not receive data from server” (also in 0.6.7)References: #2044

mysql

  • [mysql]

New DBAPI support for pymysql, a pure Python portof MySQL-python.References: #1991

  • [mysql]

oursql dialect accepts the same “ssl” arguments increate_engine() as that of MySQLdb.(also in 0.6.7)References: #2047

mssql

  • [mssql]

the String/Unicode types, and their counterparts VARCHAR/NVARCHAR, emit “max” as the length when no length isspecified, so that the default length, normally ‘1’as per SQL server documentation, is instead‘unbounded’. This also occurs for the VARBINARY type..

This behavior makes these types more closely compatiblewith PostgreSQL’s VARCHAR type which is similarly unboundedwhen no length is specified.References: #1833

firebird

  • [firebird]

Some adjustments so that Interbase is supported as well.FB/Interbase version idents are parsed into a structuresuch as (8, 1, 1, ‘interbase’) or (2, 1, 588, ‘firebird’)so they can be distinguished.References: #1885

misc

Detailed descriptions of each change below aredescribed at:http://docs.sqlalchemy.org/en/latest/changelog/migration_07.html

  • [declarative]

Added an explicit check for the case that the name‘metadata’ is used for a column attribute on adeclarative class. (also in 0.6.7)References: #2050