* tweaked PickleType result_processor and bind_processor so that they are more
correct and more easily maintainable.
* implemented specific result_processor and bind_processor for Interval type
to avoid TypeDecorator call overhead (closes #1598)
rewrote PickleType bind_processor and result_processors to bypass TypeDecorator
call overhead and avoid pickler function lookup for each row (see #1598).
Provides a speedup of ~7 % on total query time for a 1000 record query on a
table with 1 PickeType field and 25% None values.
Mike Bayer [Sun, 1 Nov 2009 22:47:14 +0000 (22:47 +0000)]
- INTERVAL supports an optional "precision" argument
corresponding to the argument that PG accepts.
- Added support for reflecting the INTERVAL YEAR TO MONTH
and INTERVAL DAY TO SECOND syntaxes of the INTERVAL
type. [ticket:460]
Mike Bayer [Sun, 1 Nov 2009 20:39:43 +0000 (20:39 +0000)]
- the `__contains__()` method of `MetaData` now accepts
strings or `Table` objects as arguments. If given
a `Table`, the argument is converted to `table.key` first,
i.e. "[schemaname.]<tablename>" [ticket:1541]
Mike Bayer [Mon, 26 Oct 2009 00:32:39 +0000 (00:32 +0000)]
- The psycopg2 dialect now uses psycopg2's "unicode extension"
on all new connections, which allows all String/Text/etc.
types to skip the need to post-process bytestrings into
unicode (an expensive step due to its volume). Other
dialects which return unicode natively (pg8000, zxjdbc)
also skip unicode post-processing.
- String/Text/Unicode types now skip the unicode() check
on each result column value if the dialect has
detected the DBAPI as returning Python unicode objects
natively. This check is issued on first connect
using "SELECT CAST 'some text' AS VARCHAR(10)" or
equivalent, then checking if the returned object
is a Python unicode. This allows vast performance
increases for native-unicode DBAPIs, including
pysqlite/sqlite3, psycopg2, and pg8000.
Mike Bayer [Sun, 25 Oct 2009 16:31:54 +0000 (16:31 +0000)]
- Using a "dynamic" loader with a "secondary" table now produces
a query where the "secondary" table is *not* aliased. This
allows the secondary Table object to be used in the "order_by"
attribute of the relation(), and also allows it to be used
in filter criterion against the dynamic relation.
[ticket:1531]
- a "dynamic" loader sets up its query criterion at construction
time so that the actual query is returned from non-cloning
accessors like "statement".
Mike Bayer [Sun, 25 Oct 2009 01:40:23 +0000 (01:40 +0000)]
- Fixed a slight inaccuracy in the sharding example.
Comparing equivalence of columns in the ORM is best
accomplished using col1.shares_lineage(col2).
[ticket:1491]
Mike Bayer [Sun, 25 Oct 2009 00:40:34 +0000 (00:40 +0000)]
- Added new ENUM type to the Postgresql dialect, which exists as a schema-level
construct and extends the generic Enum type. Automatically
associates itself with tables and their parent metadata
to issue the appropriate CREATE TYPE/DROP TYPE
commands as needed, supports unicode labels, supports
reflection. [ticket:1511]
- MySQL ENUM now subclasses the new generic Enum type, and also handles
unicode values implicitly, if the given labelnames are unicode
objects.
- Added a new Enum generic type, currently supported on
Postgresql and MySQL. Enum is a schema-aware object
to support databases which require specific DDL in
order to use enum or equivalent; in the case of PG
it handles the details of `CREATE TYPE`, and on
other databases without native enum support can
support generation of CHECK constraints.
[ticket:1109] [ticket:1511]
Mike Bayer [Sat, 24 Oct 2009 16:38:07 +0000 (16:38 +0000)]
- ResultProxy internals have been overhauled to greatly reduce
method call counts when fetching columns that have no
type-level processing applied. Provides a 100% speed
improvement when fetching large result sets with no unicode
conversion. Many thanks to Elixir's Gaëtan de Menten
for this dramatic improvement ! [ticket:1586]
Mike Bayer [Fri, 23 Oct 2009 19:46:58 +0000 (19:46 +0000)]
- Mutable collection passed to the "extension" attribute
of relation(), column_property() etc. will not be mutated
or shared among multiple instrumentation calls, preventing
duplicate extensions, such as backref populators,
from being inserted into the list.
[ticket:1585]
Mike Bayer [Fri, 23 Oct 2009 01:08:02 +0000 (01:08 +0000)]
- insert() and update() constructs can now embed bindparam()
objects using names that match the keys of columns. These
bind parameters will circumvent the usual route to those
keys showing up in the VALUES or SET clause of the generated
SQL. [ticket:1579]
Michael Trier [Thu, 22 Oct 2009 03:29:52 +0000 (03:29 +0000)]
Removed references to sequence in MSSQL
Implicit identities in mssql work the same as implicit sequences on any
other dialects. Explicit sequences are enabled through the use of
"default=Sequence()". See the MSSQL dialect documentation for more
information.
Mike Bayer [Sun, 18 Oct 2009 21:59:54 +0000 (21:59 +0000)]
- the behavior of eagerloading such that the main query is
wrapped in a subquery when LIMIT/OFFSET are present now
makes an exception for the case when all eager loads are
many-to-one joins. In those cases, the eager joins are
against the parent table directly along with the
limit/offset without the extra overhead of a subquery,
since a many-to-one join does not add rows to the result.
Mike Bayer [Sun, 18 Oct 2009 20:28:19 +0000 (20:28 +0000)]
- added a flag to relation(), eagerload(), and eagerload_all()
called 'innerjoin'. Specify `True` or `False` to control
whether an eager join is constructed as an INNER or OUTER
join. Default is `False` as always. The mapper options
will override whichever setting is specified on relation().
Should generally be set for many-to-one, not nullable
foreign key relations to allow improved join performance.
[ticket:1544]
Mike Bayer [Thu, 15 Oct 2009 23:00:06 +0000 (23:00 +0000)]
deprecations per [ticket:1498]:
- deprecated PassiveDefault - use DefaultClause.
- the BINARY and MSBinary types now generate "BINARY" in all
cases. Omitting the "length" parameter will generate
"BINARY" with no length. Use BLOB to generate an unlengthed
binary column.
- the "quoting='quoted'" argument to MSEnum/ENUM is deprecated.
It's best to rely upon the automatic quoting.
- "shortname" attribute on bindparam() is removed.
- fold_equivalents flag on join is deprecated (will remain
until [ticket:1131] is implemented)
- "scalar" flag on select() is removed, use
select.as_scalar().
- 'transactional' flag on sessionmaker() and others is
removed. Use 'autocommit=True' to indicate 'transactional=False'.
- 'polymorphic_fetch' argument on mapper() is removed.
Loading can be controlled using the 'with_polymorphic'
option.
- 'select_table' argument on mapper() is removed. Use
'with_polymorphic=("*", <some selectable>)' for this
functionality.
- 'proxy' argument on synonym() is removed. This flag
did nothing throughout 0.5, as the "proxy generation"
behavior is now automatic.
- Passing a single list of elements to eagerload(),
eagerload_all(), contains_eager(), lazyload(),
defer(), and undefer() instead of multiple positional
-args is deprecated.
- Passing a single list of elements to query.order_by(),
query.group_by(), query.join(), or query.outerjoin()
instead of multiple positional *args is deprecated.
- query.iterate_instances() is removed. Use query.instances().
- Query.query_from_parent() is removed. Use the
sqlalchemy.orm.with_parent() function to produce a
"parent" clause, or alternatively query.with_parent().
- query._from_self() is removed, use query.from_self()
instead.
- the "comparator" argument to composite() is removed.
Use "comparator_factory".
- RelationProperty._get_join() is removed.
- the 'echo_uow' flag on Session is removed. Use
logging on the "sqlalchemy.orm.unitofwork" name.
- session.clear() is removed. use session.expunge_all().
- session.save(), session.update(), session.save_or_update()
are removed. Use session.add() and session.add_all().
- the "objects" flag on session.flush() remains deprecated.
- the "dont_load=True" flag on session.merge() is deprecated
in favor of "load=False".
- passing an InstanceState (internal SQLAlchemy state object) to
attributes.init_collection() or attributes.get_history() is
deprecated. These functions are public API and normally
expect a regular mapped object instance.
- the 'engine' parameter to declarative_base() is removed.
Use the 'bind' keyword argument.
Mike Bayer [Thu, 15 Oct 2009 21:06:35 +0000 (21:06 +0000)]
- setting echo=False on create_engine() now sets the loglevel
to WARN instead of NOTSET. This so that logging can be
disabled for a particular engine even if logging
for "sqlalchemy.engine" is enabled overall. Note that the
default setting of "echo" is `None`. [ticket:1554]
Mike Bayer [Thu, 15 Oct 2009 20:52:06 +0000 (20:52 +0000)]
- A column can be added to a joined-table declarative
superclass after the class has been constructed
(i.e. via class-level attribute assignment), and
the column will be propagated down to
subclasses. [ticket:1570] This is the reverse
situation as that of [ticket:1523], fixed in 0.5.6.
Mike Bayer [Thu, 15 Oct 2009 20:15:19 +0000 (20:15 +0000)]
- query.from_self(), query.union(), others which do a
"SELECT * from (SELECT...)" type of nesting will do
a better job translating column expressions within the subquery
to the columns clause of the outer query. This is
potentially backwards incompatible with 0.5, in that this
may break queries with literal expressions that do not have labels
applied (i.e. literal('foo'), etc.)
[ticket:1568]
Mike Bayer [Thu, 15 Oct 2009 19:08:35 +0000 (19:08 +0000)]
- mapping to a select() construct now requires that you
make an alias() out of it distinctly. This to eliminate
confusion over such issues as [ticket:1542]
Mike Bayer [Thu, 15 Oct 2009 18:41:02 +0000 (18:41 +0000)]
- an executemany() now requires that all bound parameter
sets require that all keys are present which are
present in the first bound parameter set. The structure
and behavior of an insert/update statement is very much
determined by the first parameter set, including which
defaults are going to fire off, and a minimum of
guesswork is performed with all the rest so that performance
is not impacted. For this reason defaults would otherwise
silently "fail" for missing parameters, so this is now guarded
against. [ticket:1566]
Mike Bayer [Thu, 15 Oct 2009 16:09:59 +0000 (16:09 +0000)]
- DefaultRunner and subclasses have been removed. The job
of this object has been simplified and moved into
ExecutionContext. Dialects which support sequences should
add a `fire_sequence()` method to their execution context
implementation. [ticket:1566]
Mike Bayer [Mon, 12 Oct 2009 22:29:08 +0000 (22:29 +0000)]
- `expression.null()` is fully understood the same way
None is when comparing an object/collection-referencing
attribute within query.filter(), filter_by(), etc.
[ticket:1415]
Mike Bayer [Mon, 12 Oct 2009 00:11:00 +0000 (00:11 +0000)]
- added "ddl" argument to the "on" callable of DDLElement [ticket:1538]
- fixed the imports in the "postgres" cleanup dialect
- renamed "schema_item" attribute/argument of DDLElement
to "target".
Mike Bayer [Sun, 11 Oct 2009 17:16:53 +0000 (17:16 +0000)]
- RowProxy objects are now pickleable, i.e. the object returned
by result.fetchone(), result.fetchall() etc.
- the "named tuple" objects returned when iterating a
Query() are now pickleable.
Mike Bayer [Sat, 10 Oct 2009 16:51:05 +0000 (16:51 +0000)]
- the setuptools entrypoint for external dialects is now
called "sqlalchemy.dialects". external dialects need to be changed to work with 0.6 in any case.
Mike Bayer [Mon, 5 Oct 2009 22:11:06 +0000 (22:11 +0000)]
- the mechanics of "backref" have been fully merged into the
finer grained "back_populates" system, and take place entirely
within the _generate_backref() method of RelationProperty. This
makes the initialization procedure of RelationProperty
simpler and allows easier propagation of settings (such as from
subclasses of RelationProperty) into the reverse reference.
The internal BackRef() is gone and backref() returns a plain
tuple that is understood by RelationProperty.
Mike Bayer [Fri, 2 Oct 2009 22:23:30 +0000 (22:23 +0000)]
- query.options() now only propagate to loaded objects
for potential further sub-loads only for options where
such behavior is relevant, keeping
various unserializable options like those generated
by contains_eager() out of individual instance states.
[ticket:1553]
Mike Bayer [Thu, 1 Oct 2009 23:00:02 +0000 (23:00 +0000)]
- boolean, int, and float arguments count as "cache key" values for inspector info_cache()
- added awareness of sqlite implicit auto indexes [ticket:1551]
Philip Jenvey [Thu, 24 Sep 2009 02:11:56 +0000 (02:11 +0000)]
merge from branches/clauseelement-nonzero
adds a __nonzero__ to _BinaryExpression to avoid faulty comparisons during hash
collisions (which only occur on Jython)
fixes #1547
Mike Bayer [Fri, 18 Sep 2009 20:04:45 +0000 (20:04 +0000)]
- query.join() has been reworked to provide more consistent
behavior and more flexibility (includes [ticket:1537])
- query.select_from() accepts multiple clauses to produce
multiple comma separated entries within the FROM clause.
Useful when selecting from multiple-homed join() clauses.
Mike Bayer [Wed, 16 Sep 2009 19:48:22 +0000 (19:48 +0000)]
- contains_eager() now works with the automatically
generated subquery that results when you say
"query(Parent).join(Parent.somejoinedsubclass)", i.e.
when Parent joins to a joined-table-inheritance subclass.
Previously contains_eager() would erroneously add the
subclass table to the query separately producing a
cartesian product. An example is in the ticket
description. [ticket:1543]
Revisited Firebird's keywords set
Several keywords were missing, and various words were wrongly included
in the set. I took the current list of keywords out of "keywords.cpp", filtering
out effective reserverd words with a simple script that created a dummy table
with a field named after each word.
While this fixes a few tests (for example, those creating a table with a "start"
field, a Firebird reserverd words not previously registered as such), it may
introduce a backward incompatibility with previous SA releases: should this be
not wanted, I will add previous non-reserved-words to the set.
Mike Bayer [Sat, 12 Sep 2009 20:28:10 +0000 (20:28 +0000)]
- Table objects declared in the MetaData can now be used
in string expressions sent to primaryjoin/secondaryjoin/
secondary - the name is pulled from the MetaData of the
declarative base. [ticket:1527]
Mike Bayer [Sat, 12 Sep 2009 19:59:39 +0000 (19:59 +0000)]
- Added an assertion that prevents a @validates function
or other AttributeExtension from loading an unloaded
collection such that internal state may be corrupted.
[ticket:1526]