0.2 Changelog
0.2.8
Released: Tue Sep 05 2006
cleanup on connection methods + documentation. custom DBAPIarguments specified in query string, ‘connect_args’ argumentto ‘create_engine’, or custom creation function via ‘creator’function to ‘create_engine’.
added “recycle” argument to Pool, is “pool_recycle” on create_engine,defaults to 3600 seconds; connections after this age will be closed andreplaced with a new one, to handle db’s that automatically closestale connectionsReferences: #274
changed “invalidate” semantics with pooled connection; willinstruct the underlying connection record to reconnect the nexttime its called. “invalidate” will also automatically be calledif any error is thrown in the underlying call to connection.cursor().this will hopefully allow the connection pool to reconnect to adatabase that had been stopped and started without restartingthe connecting applicationReferences: #121
eesh ! the tutorial doctest was broken for quite some time.
add_property() method on mapper does a “compile all mappers”step in case the given property references a non-compiled mapper(as it did in the case of the tutorial !)
check for pg sequence already existing before createReferences: #277
if a contextual session is established via MapperExtension.get_session(as it is using the sessioncontext plugin, etc), a lazy load operationwill use that session by default if the parent object is notpersistent with a session already.
lazy loads will not fire off for an object that does not have adatabase identity (why?see http://www.sqlalchemy.org/trac/wiki/WhyDontForeignKeysLoadData)
unit-of-work does a better check for “orphaned” objects that arepart of a “delete-orphan” cascade, for certain conditions where theparent isn’t available to cascade from.
mappers can tell if one of their objects is an “orphan” basedon interactions with the attribute package. this check is basedon a status flag maintained for each relationshipwhen objects are attached and detached from each other.
it is now invalid to declare a self-referential relationship with“delete-orphan” (as the abovementioned check would make them impossibleto save)
improved the check for objects being part of a session when theunit of work seeks to flush() them as part of a relationship..
statement execution supports using the same BindParamobject more than once in an expression; simplified handling of positionalparameters. nice job by Bill Noon figuring out the basic idea.References: #280
postgres reflection moved to use pg_schema tables, can be overriddenwith use_information_schema=True argument to create_engine.References: #60, #71
added case_sensitive argument to MetaData, Table, Column, determinesitself automatically based on if a parent schemaitem has a non-Nonesetting for the flag, or if not, then whether the identifier name is all lowercase or not. when set to True, quoting is applied to identifiers with mixed oruppercase identifiers. quoting is also applied automatically in all cases toidentifiers that are known to be reserved words or contain other non-standardcharacters. various database dialects can override all of this behavior, butcurrently they are all using the default behavior. tested with postgres, mysql,sqlite, oracle. needs more testing with firebird, ms-sql. part of the ongoingwork withReferences: #155
unit tests updated to run without any pysqlite installed; pooltest uses a mock DBAPI
urls support escaped characters in passwordsReferences: #281
added limit/offset to UNION queries (though not yet in oracle)
added “timezone=True” flag to DateTime and Time types. postgresso far will convert this to “TIME[STAMP] (WITH|WITHOUT) TIME ZONE”,so that control over timezone presence is more controllable (psycopg2returns datetimes with tzinfo’s if available, which can create confusionagainst datetimes that don’t).
fix to using query.count() with distinct, **kwargs with SelectResultscount()References: #287
deregister Table from MetaData when autoload fails;References: #289
import of py2.5s sqlite3References: #293
unicode fix for startswith()/endswith()References: #296
0.2.7
Released: Sat Aug 12 2006
quoting facilities set up so that database-specific quoting can beturned on for individual table, schema, and column identifiers whenused in all queries/creates/drops. Enabled via “quote=True” inTable or Column, as well as “quote_schema=True” in Table. Thanks toAaron Spike for the excellent efforts.
assignmapper was setting is_primary=True, causing all sorts of mayhemby not raising an error when redundant mappers were set up, fixed
added allow_null_pks option to Mapper, allows rows where someprimary key columns are null (i.e. when mapping to outer joins etc)
modification to unitofwork to not maintain ordering within the“new” list or within the UOWTask “objects” list; instead, new objectsare tagged with an ordering identifier as they are registered as newwith the session, and the INSERT statements are then sorted within themapper save_obj. the INSERT ordering has basically been pushed allthe way to the end of the flush cycle. that way the various sorts andorganizations occurring within UOWTask (particularly the circular tasksort) don’t have to worry about maintaining order (which they weren’t anyway)
fixed reflection of foreign keys to autoload the referenced tableif it was not loaded already
- pass URL query string arguments to connect() functionReferences: #256
- oracle boolean typeReferences: #257
custom primary/secondary join conditions in a relation will be propagatedto backrefs by default. specifying a backref() will override this behavior.
better check for ambiguous join conditions in sql.Join; propagates to abetter error message in PropertyLoader (i.e. relation()/backref()) for whenthe join condition can’t be reasonably determined.
sqlite creates ForeignKeyConstraint objects properly upon tablereflection.
adjustments to pool stemming from changes made for.overflow counter should only be decremented if the connection actuallysucceeded. added a test script to attempt testing this.References: #224
fixed mysql reflection of default values to be PassiveDefault
added reflected ‘tinyint’, ‘mediumint’ type to MS-SQL.References: #263, #264
SingletonThreadPool has a size and does a cleanup pass, so thatonly a given number of thread-local connections stay around (neededfor sqlite applications that dispose of threads en masse)
fixed small pickle bug(s) with lazy loadersReferences: #265, #267
fixed possible error in mysql reflection where certain versionsreturn an array instead of string for SHOW CREATE TABLE call
fix to lazy loads when mapping to joinsReferences: #1770
all create()/drop() calls have a keyword argument of “connectable”.“engine” is deprecated.
fixed ms-sql connect() to work with adodbapi
added “nowait” flag to Select()
inheritance check uses issubclass() instead of direct mro checkto make sure class A inherits from B, allowing mapper inheritance to moreflexibly correspond to class inheritanceReferences: #271
SelectResults will use a subselect, when calling an aggregate (i.e.max, min, etc.) on a SelectResults that has an ORDER BY clauseReferences: #252
fixes to types so that database-specific types more easily used;fixes to mysql text types to work with this methodologyReferences: #269
some fixes to sqlite date type organization
added MSTinyInteger to MS-SQLReferences: #263
0.2.6
Released: Thu Jul 20 2006
big overhaul to schema to allow truly composite primary and foreignkey constraints, via new ForeignKeyConstraint and PrimaryKeyConstraintobjects.Existing methods of primary/foreign key creation have not been changedbut use these new objects behind the scenes. table creationand reflection is now more table oriented rather than column oriented.References: #76
overhaul to MapperExtension calling scheme, wasn’t working very wellpreviously
tweaks to ActiveMapper, supports self-referential relationships
slight rearrangement to objectstore (in activemapper/threadlocal)so that the SessionContext is referenced by ‘.context’ insteadof subclassed directly.
activemapper will use threadlocal’s objectstore if the mod isactivated when activemapper is imported
small fix to URL regexp to allow filenames with ‘@’ in them
fixes to Session expunge/update/etc…needs more cleanup.
selecttable mappers _still weren’t always compiling
added count()/count_by() to list of methods proxied by assignmapper;this also adds them to activemapper
connection exceptions wrapped in DBAPIError
ActiveMapper now supports autoloading column definitions from thedatabase if you supply a autoload = True attribute in yourmapping inner-class. Currently this does not support reflectingany relationships.
deferred column load could screw up the connection status ina flush() under some circumstances, this was fixed
expunge() was not working with cascade, fixed.
potential endless loop in cascading operations fixed.
added “synonym()” function, applied to properties to have apropname the same as another, for the purposes of overriding propsand allowing the original propname to be accessible in select_by().
fix to typing in clause construction which specifically helpstype issues with polymorphic_union (CAST/ColumnClause propagatesits type to proxy columns)
mapper compilation work ongoing, someday it’ll work….movedaround the initialization of MapperProperty objects to be afterall mappers are created to better handle circular compilations.do_init() method is called on all properties now which are moreaware of their “inherited” status if so.
eager loads explicitly disallowed on self-referential relationships, orrelationships to an inheriting mapper (which is also self-referential)
reduced bind param size in query._get to appease the picky oracleReferences: #244
added ‘checkfirst’ argument to table.create()/table.drop(), aswell as table.exists()References: #234
some other ongoing fixes to inheritanceReferences: #245
attribute/backref/orphan/history-tracking tweaks as usual…
0.2.5
Released: Sat Jul 08 2006
fixed endless loop bug in select_by(), if the traversal hittwo mappers that referenced each other
upgraded all unittests to insert ‘./lib/’ into sys.path,working around new setuptools PYTHONPATH-killing behavior
further fixes with attributes/dependencies/etc….
improved error handling for when DynamicMetaData is not connected
MS-SQL support largely working (tested with pymssql)
ordering of UPDATE and DELETE statements within groups is nowin order of primary key values, for more deterministic ordering
after_insert/delete/update mapper extensions now called per object,not per-object-per-table
further fixes/refactorings to mapper compilation
0.2.4
Released: Tue Jun 27 2006
try/except when the mapper sets init.name on a mapped class,supports python 2.3
fixed bug where threadlocal engine would still autocommitdespite a transaction in progress
lazy load and deferred load operations require the parent objectto be in a Session to do the operation; whereas before the operationwould just return a blank list or None, it now raises an exception.
Session.update() is slightly more lenient if the session to whichthe given object was formerly attached to was garbage collected;otherwise still requires you explicitly remove the instance fromthe previous Session.
fixes to mapper compilation, checking for more error conditions
small fix to eager loading combined with ordering/limit/offset
utterly remarkable: added a single space between ‘CREATE TABLE’and ‘(
more fixes to inheritance, related to many-to-many relationsproperly saving
fixed bug when specifying explicit module to mysql dialect
when QueuePool times out it raises a TimeoutError instead oferroneously making another connection
Queue.Queue usage in pool has been replaced with a locallymodified version (works in py2.3/2.4!) that uses a threading.RLockfor a mutex. this is to fix a reported case where a ConnectionFairy’sdel() method got called within the Queue’s get() method, whichthen returns its connection to the Queue via the put() method,causing a reentrant hang unless threading.RLock is used.
postgres will not place SERIAL keyword on a primary key columnif it has a foreign key constraint
cursor() method on ConnectionFairy allows db-specific extensionarguments to be propagatedReferences: #221
lazy load bind params properly propagate column typeReferences: #225
new MySQL types: MSEnum, MSTinyText, MSMediumText, MSLongText, etc.more support for MS-specific length/precision params in numeric typespatch courtesy Mike Bernson
some fixes to connection pool invalidate()References: #224
0.2.3
Released: Sat Jun 17 2006
overhaul to mapper compilation to be deferred. this allows mappersto be constructed in any order, and their relationships to eachother are compiled when the mappers are first used.
fixed a pretty big speed bottleneck in cascading behavior particularlywhen backrefs were in use
the attribute instrumentation module has been completely rewritten; itsnow a large degree simpler and clearer, slightly faster. the “history”of an attribute is no longer micromanaged with each change and isinstead part of a “CommittedState” object created when theinstance is first loaded. HistoryArraySet is gone, the behavior oflist attributes is now more open ended (i.e. they’re not sets anymore).
py2.4 “set” construct used internally, falls back to sets.Set when“set” not available/ordering is needed.
fix to transaction control, so that repeated rollback() callsdon’t fail (was failing pretty badly when flush() would raisean exception in a larger try/except transaction block)
“foreignkey” argument to relation() can also be a list. fixedauto-foreignkey detectionReferences: #151
fixed bug where tables with schema names weren’t getting indexed inthe MetaData object properly
fixed bug where Column with redefined “key” property wasn’t gettingtype conversion happening in the ResultProxyReferences: #207
fixed ‘port’ attribute of URL to be an integer if present
fixed old bug where if a many-to-many table mapped as “secondary”had extra columns, delete operations didn’t work
bugfixes for mapping against UNION queries
fixed incorrect exception class thrown when no DB driver present
added NonExistentTable exception thrown when reflecting a tablethat doesn’t existReferences: #138
small fix to ActiveMapper regarding one-to-one backrefs, otherrefactorings
overridden constructor in mapped classes gets name anddoc from the original class
fixed small bug in selectresult.py regarding mapper extensionReferences: #200
small tweak to cascade_mappers, not very strongly supportedfunction at the moment
some fixes to between(), column.between() to propagate typinginformation betterReferences: #202
if an object fails to be constructed, is not added to thesessionReferences: #203
CAST function has been made into its own clause object withits own compilation function in ansicompiler; allows MySQLto silently ignore most CAST calls since MySQLseems to only support the standard CAST syntax with Date types.MySQL-compatible CAST support for strings, ints, etc. a TODO
0.2.2
Released: Mon Jun 05 2006
big improvements to polymorphic inheritance behavior, enabling itto work with adjacency list table structuresReferences: #190
major fixes and refactorings to inheritance relationships overall,more unit tests
fixed “echo_pool” flag on create_engine()
fix to docs, removed incorrect info that close() is unsafe to usewith threadlocal strategy (its totally safe !)
create_engine() can take URLs as string or unicodeReferences: #188
firebird support partially completed;thanks to James Ralston and Brad Clements for their efforts.
Oracle url translation was broken, fixed, will feed host/port/sidinto cx_oracle makedsn() if ‘database’ field is present, else usesstraight TNS name from the ‘host’ field
fix to using unicode criterion for query.get()/query.load()
count() function on selectables now uses table primary key orfirst column instead of “1” for criterion, also uses label “rowcount”instead of “count”.
got rudimental “mapping to multiple tables” functionality cleaned up,more correctly documented
restored global_connect() function, attaches to a DynamicMetaDatainstance called “default_metadata”. leaving MetaData arg to Tableout will use the default metadata.
fixes to session cascade behavior, entity_name propagation
reorganized unittests into subdirectories
more fixes to threadlocal connection nesting patterns
0.2.1
Released: Mon May 29 2006
“pool” argument to create_engine() properly propagates
fixes to URL, raises exception if not parsed, does not pass blankfields along to the DB connect string (a string such asuser:host@/db was breaking on postgres)
small fixes to Mapper when it inserts and tries to getnew primary key values back
rewrote half of TLEngine, the ComposedSQLEngine used with‘strategy=”threadlocal”’. it now properly implements engine.begin()/engine.commit(), which nest fully with connection.begin()/trans.commit().added about six unittests.
major “duh” in pool.Pool, forgot to put back the WeakValueDictionary.unittest which was supposed to check for this was also silently missingit. fixed unittest to ensure that ConnectionFairy properly falls outof scope.
placeholder dispose() method added to SingletonThreadPool, doesn’tdo anything yet
rollback() is automatically called when an exception is raised,but only if there’s no transaction in process (i.e. works more likeautocommit).
fixed exception raise in sqlite if no sqlite module present
added extra example detail for association object doc
Connection adds checks for already being closed
0.2.0
Released: Sat May 27 2006
overhaul to Engine system so that what was formerly the SQLEngineis now a ComposedSQLEngine which consists of a variety of components,including a Dialect, ConnectionProvider, etc. This impacted all thedb modules as well as Session and Mapper.
create_engine now takes only RFC-1738-style strings:driver://user:password@host:port/database
total rewrite of connection-scoping methodology, Connection objectscan now execute clause elements directly, added explicit “close” aswell as support throughout Engine/ORM to handle closing properly,no longer relying upon del internally to return connectionsto the pool.References: #152
overhaul to Session interface and scoping. uses hibernate-stylemethods, including query(class), save(), save_or_update(), etc.no threadlocal scope is installed by default. Provides a bindinginterface to specific Engines and/or Connections so that underlyingSchema objects do not need to be bound to an Engine. Added a basicSessionTransaction object that can simplistically aggregate transactionsacross multiple engines.
overhaul to mapper’s dependency and “cascade” behavior; dependency logicfactored out of properties.py into a separate module “dependency.py”.“cascade” behavior is now explicitly controllable, proper implementationof “delete”, “delete-orphan”, etc. dependency system can now determine atflush time if a child object has a parent or not so that it makes betterdecisions on how that child should be updated in the DB with regards to deletes.
overhaul to Schema to build upon MetaData object instead of an Engine.Entire SQL/Schema system can be used with no Engines whatsoever, executedsolely by an explicit Connection object. the “bound” methodology exists via theBoundMetaData for schema objects. ProxyEngine is generally not neededanymore and is replaced by DynamicMetaData.
true polymorphic behavior implemented, fixesReferences: #167
“oid” system has been totally moved into compile-time behavior;if they are used in an order_by where they are not available, the order_bydoesn’t get compiled, fixesReferences: #147
overhaul to packaging; “mapping” is now “orm”, “objectstore” is now“session”, the old “objectstore” namespace gets loaded in via the“threadlocal” mod if used
mods now called in via “import
fix to add_property so that it propagates properties to inheritingmappersReferences: #154
backrefs create themselves against primary mapper of its originatingproperty, primary/secondary join arguments can be specified to override.helps their usage with polymorphic mappers
“table exists” function has been implementedReferences: #31
“create_all/drop_all” added to MetaData objectReferences: #98
improvements and fixes to topological sort algorithm, as well as moreunit tests
tutorial page added to docs which also can be run with a custom doctestrunner to ensure its properly working. docs generally overhauled todeal with new code patterns
many more fixes, refactorings.
migration guide is available on the Wiki athttp://www.sqlalchemy.org/trac/wiki/02Migration