Mike Bayer [Thu, 11 Sep 2014 15:51:44 +0000 (11:51 -0400)]
- Fixed warning that would emit when a complex self-referential
primaryjoin contained functions, while at the same time remote_side
was specified; the warning would suggest setting "remote side".
It now only emits if remote_side isn't present.
fixes #3194
Mike Bayer [Wed, 10 Sep 2014 18:14:50 +0000 (14:14 -0400)]
- Fixed bug in ordering list where the order of items would be
thrown off during a collection replace event, if the
reorder_on_append flag were set to True. The fix ensures that the
ordering list only impacts the list that is explicitly associated
with the object.
fixes #3191
Mike Bayer [Tue, 9 Sep 2014 21:29:37 +0000 (17:29 -0400)]
- add in all the method-chained methods to the parameter descriptions
on select(). improve some descriptions and add more info for limit()/
offset(), including new 1.0 functionality.
Mike Bayer [Mon, 8 Sep 2014 20:31:11 +0000 (16:31 -0400)]
- rework the previous "order by" system in terms of the new one,
unify everything.
- create a new layer of separation between the "from order bys" and "column order bys",
so that an OVER doesn't ORDER BY a label in the same columns clause
- identify another issue with polymorphic for ref #3148, match on label
keys rather than the objects
Mike Bayer [Mon, 8 Sep 2014 00:28:19 +0000 (20:28 -0400)]
- Added new event handlers :meth:`.AttributeEvents.init_collection`
and :meth:`.AttributeEvents.dispose_collection`, which track when
a collection is first associated with an instance and when it is
replaced. These handlers supersede the :meth:`.collection.linker`
annotation. The old hook remains supported through an event adapter.
Docs: use the base layout when mako_layout=='epub'
- https://readthedocs.org/projects/sqlalchemy/downloads/epub/latest/ renders with the full template which is unreadable on e-readers
- in the makefile the template-variable mako_layout is set for target: epub which makes mako use only the base layout.
- this is the more elegant solution as proposed to #133
Mike Bayer [Sun, 7 Sep 2014 18:55:44 +0000 (14:55 -0400)]
- rework ColumnAdapter and ORMAdapter to only provide the features
we're now using; rework them fully so that their behavioral contract
is consistent regarding adapter.traverse() vs. adapter.columns[],
add a full suite of tests including advanced wrapping scenarios
previously only covered by test/orm/test_froms.py and
test/orm/inheritance/test_relationships.py
- identify several cases where label._order_by_label_clause would be
corrupted, e.g. due to adaption or annotation separately
- add full tests for #3148
Mike Bayer [Sun, 7 Sep 2014 04:01:34 +0000 (00:01 -0400)]
- enhance ClauseAdapter / ColumnAdapter to have new behaviors with labels.
The "anonymize label" logic is now generalized to ClauseAdapter, and takes
place when the anonymize_labels flag is sent, taking effect for all
.columns lookups as well as within traverse() calls against the label
directly.
- traverse() will also memoize what it gets in columns, so that
calling upon traverse() / .columns against the same Label will
produce the same anonymized label. This is so that AliasedClass
produces the same anonymized label when it is accessed per-column
(e.g. SomeAlias.some_column) as well as when it is applied to a Query,
and within column loader strategies (e.g. query(SomeAlias)); the
former uses traverse() while the latter uses .columns
- AliasedClass now calls onto ColumnAdapter
- Query also makes sure to use that same ColumnAdapter from the AliasedClass
in all cases
- update the logic from 0.9 in #1068 to make use of the same
_label_resolve_dict we use for #2992, simplifying how that works
and adding support for new scenarios that were pretty broken
(see #3148, #3188)
Mike Bayer [Sat, 6 Sep 2014 20:20:01 +0000 (16:20 -0400)]
- document all the varities of _label on the base ColumnElement
- replace out _columns_clause_label with a straight boolean flag to
reduce the proliferation of labels
Mike Bayer [Fri, 5 Sep 2014 20:44:42 +0000 (16:44 -0400)]
- MySQL boolean symbols "true", "false" work again. 0.9's change
in :ticket:`2682` disallowed the MySQL dialect from making use of the
"true" and "false" symbols in the context of "IS" / "IS NOT", but
MySQL supports this syntax even though it has no boolean type.
MySQL remains "non native boolean", but the :func:`.true`
and :func:`.false` symbols again produce the
keywords "true" and "false", so that an expression like
``column.is_(true())`` again works on MySQL.
fixes #3186
Mike Bayer [Wed, 3 Sep 2014 14:30:51 +0000 (10:30 -0400)]
- The hostname-based connection format for SQL Server when using
pyodbc will no longer specify a default "driver name", and a warning
is emitted if this is missing. The optimal driver name for SQL Server
changes frequently and is per-platform, so hostname based connections
need to specify this. DSN-based connections are preferred.
fixes #3182
Mike Bayer [Tue, 2 Sep 2014 18:18:09 +0000 (14:18 -0400)]
- An adjustment to table/index reflection such that if an index
reports a column that isn't found to be present in the table,
a warning is emitted and the column is skipped. This can occur
for some special system column situations as has been observed
with Oracle. fixes #3180
Mike Bayer [Tue, 2 Sep 2014 14:49:46 +0000 (10:49 -0400)]
- add logic to compiler such that if stack is empty, we just
stringify a _label_reference() as is.
- add .key to _label_reference(), so that when _make_proxy()
is called, we don't call str() on it anyway.
- add a test to exercise Query's behavior of adding all the order_by
expressions to the columns list of the select, assert that things
work out when we have a _label_reference there, that it gets sucked
into the columns list and spit out on the other side, it's referred
to appropriately, etc. _label_reference() could theoretically
be resolved at the point we iterate _raw_columns() but
it's better to just let things work as they already do (except
nicer, since we get "tablename.colname" instead of just "somename"
in the columns list) so that we aren't adding a ton of overhead
to _columns_plus_names in the common case.
Mike Bayer [Tue, 2 Sep 2014 00:19:54 +0000 (20:19 -0400)]
- The :func:`~.expression.column` and :func:`~.expression.table`
constructs are now importable from the "from sqlalchemy" namespace,
just like every other Core construct.
- The implicit conversion of strings to :func:`.text` constructs
when passed to most builder methods of :func:`.select` as
well as :class:`.Query` now emits a warning with just the
plain string sent. The textual conversion still proceeds normally,
however. The only method that accepts a string without a warning
are the "label reference" methods like order_by(), group_by();
these functions will now at compile time attempt to resolve a single
string argument to a column or label expression present in the
selectable; if none is located, the expression still renders, but
you get the warning again. The rationale here is that the implicit
conversion from string to text is more unexpected than not these days,
and it is better that the user send more direction to the Core / ORM
when passing a raw string as to what direction should be taken.
Core/ORM tutorials have been updated to go more in depth as to how text
is handled.
fixes #2992
Mike Bayer [Mon, 1 Sep 2014 00:26:40 +0000 (20:26 -0400)]
- walk back these literal SQL lectures into something much more succinct.
the ORM one in particular was really long winded and I don't really care if people
use text() anyway, they'll figure it out ;)
Mike Bayer [Sun, 31 Aug 2014 19:22:00 +0000 (15:22 -0400)]
- A new style of warning can be emitted which will "filter" up to
N occurrences of a parameterized string. This allows parameterized
warnings that can refer to their arguments to be delivered a fixed
number of times until allowing Python warning filters to squelch them,
and prevents memory from growing unbounded within Python's
warning registries.
fixes #3178
Mike Bayer [Sat, 30 Aug 2014 05:52:36 +0000 (01:52 -0400)]
- continue moving things out that don't need to be there
- an existing state shouldn't need its load_options/load_path updated;
it should maintain those from its original Query source. there's no
tests that check this behavior
Mike Bayer [Fri, 29 Aug 2014 20:57:12 +0000 (16:57 -0400)]
- further move things vertically, at which point things are inlined enough
that I'd like to start de-inlining again in the hopes of making this readable.
Mike Bayer [Fri, 29 Aug 2014 19:07:11 +0000 (15:07 -0400)]
- reorganize how create_row_processor() communicates up to
instances(), using a named tuple it can assign to directly. this way
we never have to worry about that structure changing anymore, though
we are still having it append (key, fn) which is kind of awkward.
- inline _populators() into instance(), it's a little verbose but
saves an fn call
Mike Bayer [Fri, 29 Aug 2014 18:25:09 +0000 (14:25 -0400)]
- re-establish and test some behavior from previous versions, that
if a load() or refresh() event changes history (which...why...but anyway)
the state of the object is the same; currently it seems that history
gets reset but on a refresh, the object still goes into session.dirty
- simplify what we store in partials
Mike Bayer [Fri, 29 Aug 2014 18:01:38 +0000 (14:01 -0400)]
- The :class:`.Query` will raise an exception when :meth:`.Query.yield_per`
is used with mappings or options where eager loading, either
joined or subquery, would take place. These loading strategies are
not currently compatible with yield_per, so by raising this error,
the method is safer to use - combine with sending False to
:meth:`.Query.enable_eagerloads` to disable the eager loaders.
Mike Bayer [Fri, 29 Aug 2014 16:05:00 +0000 (12:05 -0400)]
- Changed the approach by which the "single inheritance criterion"
is applied, when using :meth:`.Query.from_self`, or its common
user :meth:`.Query.count`. The criteria to limit rows to those
with a certain type is now indicated on the inside subquery,
not the outside one, so that even if the "type" column is not
available in the columns clause, we can filter on it on the "inner"
query.
fixes #3177
Mike Bayer [Fri, 29 Aug 2014 00:06:12 +0000 (20:06 -0400)]
- major refactoring/inlining to loader.instances(), though not really
any speed improvements :(. code is in a much better place to be run into
C, however
- The ``proc()`` callable passed to the ``create_row_processor()``
method of custom :class:`.Bundle` classes now accepts only a single
"row" argument.
- Deprecated event hooks removed: ``populate_instance``,
``create_instance``, ``translate_row``, ``append_result``
- the getter() idea is somewhat restored; see ref #3175
Mike Bayer [Thu, 28 Aug 2014 21:57:48 +0000 (17:57 -0400)]
- Made a small adjustment to the mechanics of lazy loading,
such that it has less chance of interfering with a joinload() in the
very rare circumstance that an object points to itself; in this
scenario, the object refers to itself while loading its attributes
which can cause a mixup between loaders. The use case of
"object points to itself" is not fully supported, but the fix also
removes some overhead so for now is part of testing.
fixes #3145
Mike Bayer [Thu, 28 Aug 2014 16:25:21 +0000 (12:25 -0400)]
- A new implementation for :class:`.KeyedTuple` used by the
:class:`.Query` object offers dramatic speed improvements when
fetching large numbers of column-oriented rows.
fixes #3176
Mike Bayer [Tue, 26 Aug 2014 21:23:23 +0000 (17:23 -0400)]
- The behavior of :paramref:`.joinedload.innerjoin` as well as
:paramref:`.relationship.innerjoin` is now to use "nested"
inner joins, that is, right-nested, as the default behavior when an
inner join joined eager load is chained to an outer join eager load.
fixes #3008
Add note on begin_nested requiring rollback/commit
Avoid confusion about rollback/commit "must be issued" after
``session.begin_nested()`` --- this might be taken to mean call must be
*added*, but that's only true if not using the return value as a context
manager.
Mike Bayer [Thu, 21 Aug 2014 00:14:20 +0000 (20:14 -0400)]
- The INSERT...FROM SELECT construct now implies ``inline=True``
on :class:`.Insert`. This helps to fix a bug where an
INSERT...FROM SELECT construct would inadvertently be compiled
as "implicit returning" on supporting backends, which would
cause breakage in the case of an INSERT that inserts zero rows
(as implicit returning expects a row), as well as arbitrary
return data in the case of an INSERT that inserts multiple
rows (e.g. only the first row of many).
A similar change is also applied to an INSERT..VALUES
with multiple parameter sets; implicit RETURNING will no longer emit
for this statement either. As both of these constructs deal
with varible numbers of rows, the
:attr:`.ResultProxy.inserted_primary_key` accessor does not
apply. Previously, there was a documentation note that one
may prefer ``inline=True`` with INSERT..FROM SELECT as some databases
don't support returning and therefore can't do "implicit" returning,
but there's no reason an INSERT...FROM SELECT needs implicit returning
in any case. Regular explicit :meth:`.Insert.returning` should
be used to return variable numbers of result rows if inserted
data is needed.
fixes #3169
Mike Bayer [Wed, 20 Aug 2014 16:01:20 +0000 (12:01 -0400)]
- Fixed bug in connection pool logging where the "connection checked out"
debug logging message would not emit if the logging were set up using
``logging.setLevel()``, rather than using the ``echo_pool`` flag.
Tests to assert this logging have been added. This is a
regression that was introduced in 0.9.0.
fixes #3168
Mike Bayer [Mon, 18 Aug 2014 20:44:07 +0000 (16:44 -0400)]
- further reorganize collect_insert_commands to distinguish between
setting up given values vs. defaults. again trying to shoot for
making this of more general use
Mike Bayer [Mon, 18 Aug 2014 20:32:48 +0000 (16:32 -0400)]
- organize persistence methods in terms of generators,
narrow down argument lists and generator items for each function
down to just what each function needs. This will help for them
to be of more multipurpose use for bulk operations
Mike Bayer [Mon, 18 Aug 2014 16:50:29 +0000 (12:50 -0400)]
- major simplification of _collect_update_commands. in particular,
we only call upon the history API fully for primary key columns.
We also now skip the whole step of looking at PK columns and using
any history at all if no net changes are detected on the object.
Mike Bayer [Mon, 18 Aug 2014 00:06:16 +0000 (20:06 -0400)]
- Fixed bug where attribute "set" events or columns with
``@validates`` would have events triggered within the flush process,
when those columns were the targets of a "fetch and populate"
operation, such as an autoincremented primary key, a Python side
default, or a server-side default "eagerly" fetched via RETURNING.
fixes #3167