Mike Bayer [Sat, 24 Sep 2016 04:49:22 +0000 (00:49 -0400)]
- improve documentation for SessionTransaction re: parent
and nested attributes and what these mean
- improve linking for after_transaction_create() / after_transaction_end()
events
- add public .parent attribute to detect top-level transaction within
these events
Mike Bayer [Thu, 22 Sep 2016 15:08:09 +0000 (11:08 -0400)]
- clarify documentation on timezone flag, since Oracle has both
DATE / TIMESTAMP separately the timezone flag will not bump the
type to TIMESTAMP WITH TIMEZONE on that backend.
Mike Bayer [Wed, 21 Sep 2016 19:37:20 +0000 (15:37 -0400)]
Handle BaseException in all _handle_dbapi_error
Tests illustrate that exceptions like GreenletExit and
even KeyboardInterrupt can corrupt the state of a DBAPI
connection like that of pymysql and mysqlclient. Intercept
BaseException errors within the handle_error scheme and
invalidate just the connection alone in this case, but not
the whole pool.
The change is backwards-incompatible with a program that
currently intercepts ctrl-C within a database transaction
and wants to continue working on that transaction. Ensure
the event hook can be used to reverse this behavior.
Mike Bayer [Wed, 21 Sep 2016 21:55:39 +0000 (17:55 -0400)]
Ensure mapper.polymorphic_on is polymorphic_prop.columns[0]
Fixed bug where joined eager loading would fail for a polymorphically-
loaded mapper, where the polymorphic_on was set to an un-mapped
expression such as a CASE expression.
John Perkins [Fri, 5 Aug 2016 17:45:49 +0000 (13:45 -0400)]
Add the "triggering mapper" to the configure_mappers error message.
There are cases where the originating mapper name is not
present in the exception message, such as relationship initialization
against an unmapped class. Ensure the originating mapper is named
in the string output.
Mike Bayer [Tue, 20 Sep 2016 15:33:16 +0000 (11:33 -0400)]
Allow SQL expressions to be set on PK columns
Removes an unnecessary transfer of modified PK column
value to the params dictionary, so that if the modified PK column
is already present in value_params, this remains in effect. Also
propagate a new flag through to _emit_update_statements() that will
trip "return_defaults()" across the board if a PK col w/ SQL expression
change is present, and pull this PK value in _postfetch as well assuming
we're an UPDATE.
John Passaro [Mon, 19 Sep 2016 19:43:46 +0000 (15:43 -0400)]
Exclude eq and ne from associative operators
The "eq" and "ne" operators are no longer part of the list of
"associative" operators, while they remain considered to be
"commutative". This allows an expression like ``(x == y) == z``
to be maintained at the SQL level with parenthesis. Pull request
courtesy John Passaro.
Mike Bayer [Mon, 19 Sep 2016 20:22:08 +0000 (16:22 -0400)]
Support bindparam() with callable for primaryjoin
Fixes the comparison of bindparam() objects based on
the "callable" parameter being present which helps to correctly
detect use_get, and also checks for "callable" when detecting
parameters for value substitution and will not impact the
object if present.
Mike Bayer [Fri, 2 Sep 2016 19:10:32 +0000 (15:10 -0400)]
Additions to support HAAlchemy plugin
- add a connect=True key to connection record to support
pre-loading of _ConnectionRecord objects
- ensure _ConnectionRecord.close() leaves the record in a good
state for reopening
- add _ConnectionRecord.record_info for persistent storage
- add "in_use" accessor based on fairy_ref being present or not
- allow for the exclusions system and SuiteRequirements to be
usable without the full plugin_base setup.
- move some Python-env requirements to the importable
requirements.py module.
- allow starttime to be queried
- add additional events for engine plugins
- have "dialect" be a first-class parameter to the pool,
ensure the engine strategy supplies it up front
Mike Bayer [Thu, 15 Sep 2016 04:50:17 +0000 (00:50 -0400)]
Repair foreign_keys population for Join._refresh_for_new_column
Fixed bug where setting up a single-table inh subclass of a joined-table
subclass which included an extra column would corrupt the foreign keys
collection of the mapped table, thereby interfering with the
initialization of relationships.
Mike Bayer [Fri, 2 Sep 2016 15:27:58 +0000 (11:27 -0400)]
Repair clauselist comparison to account for clause ordering
Fixed bug where the "simple many-to-one" condition that allows lazy
loading to use get() from identity map would fail to be invoked if the
primaryjoin of the relationship had multiple clauses separated by AND
which were not in the same order as that of the primary key columns
being compared in each clause. This ordering
difference occurs for a composite foreign key where the table-bound
columns on the referencing side were not in the same order in the .c
collection as the primary key columns on the referenced side....which
in turn occurs a lot if one is using declarative mixins and/or
declared_attr to set up columns.
Mike Bayer [Fri, 2 Sep 2016 15:48:15 +0000 (11:48 -0400)]
Allow stringify compiler to render unnamed column
Stringify of expression with unnamed :class:`.Column` objects, as
occurs in lots of situations including ORM error reporting,
will now render the name in string context as "<name unknown>"
rather than raising a compile error.
Mike Bayer [Wed, 31 Aug 2016 18:34:54 +0000 (14:34 -0400)]
Check for supports_execution at ClauseElement base
Raise a more descriptive exception / message when ClauseElement
or non-SQLAlchemy objects that are not "executable" are erroneously
passed to ``.execute()``; a new exception ObjectNotExecutableError
is raised consistently in all cases.
Edouard Berthe [Wed, 31 Aug 2016 06:52:48 +0000 (16:52 +1000)]
Corrects typo
This example doesn't work with 'back_populates' because 'parent_associations' and 'child_associations' are not defined in Parent and Child classes respectively.
Alternatively, we could create 'parent_associations' and 'child_associations' into the classes.
Mike Bayer [Mon, 15 Aug 2016 20:39:12 +0000 (16:39 -0400)]
Rework _apply_joins(), _prep_for_joins() totally
The approach here is still error prone
and hard to follow. Reorganize the whole
thing to take a pretty blunt approach to
the structure of to_join(). Also fix some never-called
code (!) in _prep_for_joins() and ensure we re-use
an aliased object.
Mike Bayer [Sat, 13 Aug 2016 03:35:40 +0000 (23:35 -0400)]
Ensure final link in subqueryload join is correct
Fixed bug in subquery eager loading where a subqueryload
of an "of_type()" object linked to a second subqueryload of a plain
mapped class would fail to link the joins correctly.
Mike Bayer [Thu, 4 Aug 2016 15:56:31 +0000 (11:56 -0400)]
Build string/int processors for JSONIndexType, JSONPathType
Fixed regression in JSON datatypes where the "literal processor" for
a JSON index value, that needs to take effect for example within DDL,
would not be invoked for the value. The native String and Integer
datatypes are now called upon from within the JSONIndexType
and JSONPathType. This is applied to the generic, Postgresql, and
MySQL JSON types.
brln [Tue, 2 Aug 2016 22:37:35 +0000 (18:37 -0400)]
Warn that bulk save groups inserts/updates by type
Users who pass many different object types to bulk_save_objects
may be surprised that the INSERT/UPDATE batches must necessarily
be broken up by type. Add this to the list of caveats.
Co-authored-by: Mike Bayer
Change-Id: I8390c1c971ced50c41268b479a9dcd09c695b135
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/294
Mike Bayer [Sun, 31 Jul 2016 04:10:04 +0000 (00:10 -0400)]
Ensure post-__clause_element__() expression are used in Index
The change in Index for 1.1 combined with the fix for
ref #3763 still fails to deliver the correct object
resolved by __clause_element__() to the list of expressions
for compilation. Make sure we use the expression that's
been unwrapped from __clause_element__().
Mike Bayer [Fri, 29 Jul 2016 22:17:43 +0000 (18:17 -0400)]
Index should extract __clause_element__() early
Fixed bug where :class:`.Index` would fail to extract columns from
compound SQL expressions if those SQL expressions were wrapped inside
of an ORM-style ``__clause_element__()`` construct. This bug
exists in 1.0.x as well, however in 1.1 is more noticeable as
hybrid_property @expression now returns a wrapped element.
Mike Bayer [Fri, 29 Jul 2016 22:50:18 +0000 (18:50 -0400)]
Clarify order_by(False)
It wasn't clear how this differs from order_by(None);
add more tests and document that this has to do with whether or
not mapper.order_by will be re-enabled as well.
Mike Bayer [Sun, 24 Jul 2016 21:37:25 +0000 (17:37 -0400)]
Allow Table._reset_exported to silently pass
Fixed bug in :class:`.Table` where the internal method
``_reset_exported()`` would corrupt the state of the object. This
method is intended for selectable objects and is called by the ORM
in some cases; an erroneous mapper configuration would could lead the
ORM to call this on on a :class:`.Table` object.
Mike Bayer [Mon, 25 Jul 2016 03:14:47 +0000 (23:14 -0400)]
- MySQL's JSON shared implementation completely w/ sqltypes.JSON;
this must have been an oversight. Leave mysql.JSON in place still
as we might need to add things to it.
- CAST(json, String) still confusing MySQL drivers even mysqlclient.
Since here we're checking for the raw form of the JSON and not a typical
round trip, add a force for unicode
Mike Bayer [Tue, 19 Jul 2016 16:36:21 +0000 (12:36 -0400)]
Remove same-named relationship warning
Removed a warning that dates back to 0.4 which emits when a same-named
relationship is placed on two mappers that inherits via joined or
single table inheritance. The warning does not apply to the
current unit of work implementation.
Mike Bayer [Tue, 12 Jul 2016 20:53:37 +0000 (16:53 -0400)]
Ensure DML provides named_with_column for CTE(Alias)
Fixed bug in new CTE feature for update/insert/delete whereby
an anoymous (e.g. no name passed) :class:`.CTE` construct around
the statement would fail. The Alias base class of CTE checks
for the "named_with_column" attribute in order to detect if
the underlying selectable has a name; UpdateBase now provides
this as False.
Mike Bayer [Tue, 12 Jul 2016 20:38:22 +0000 (16:38 -0400)]
Work w/ prefetch even for selects, if present
Fixed bug in new CTE feature for update/insert/delete stated
as a CTE inside of an enclosing statement (typically SELECT) whereby
oninsert and onupdate values weren't called upon for the embedded
statement.
This is accomplished by consulting prefetch
for all statements. The collection is also broken into
separate insert/update collections so that we don't need to
consult toplevel self.isinsert to determine if the prefetch
is for an insert or an update. What we don't yet test for
are CTE combinations that have both insert/update in one
statement, though these should now work in theory provided
the underlying database supports such a statement.
Mark Hahnenberg [Tue, 12 Jul 2016 18:07:52 +0000 (14:07 -0400)]
Fix issue with unbaking subqueries
Fix improper capture of a loop variable inside a lambda during unbaking
of subquery eager loaders, which would cause the incorrect query
to be invoked.
Mike Bayer [Tue, 5 Jul 2016 16:48:41 +0000 (12:48 -0400)]
Adapt "FOR UPDATE OF" with Oracle limit/offset
This modifies the Oracle ROWNUM limit/offset approach
to accommodate for the "OF" clause in a "FOR UPDATE"
phrase. The column expressions must be added to the selected
subquery if necessary and adapted on the outside.
Mike Bayer [Mon, 4 Jul 2016 20:37:26 +0000 (16:37 -0400)]
Repair PG BIGSERIAL w/ TypeDecorator, Variant
Some of the dialect impl memoization for TypeDecorator
necessarily keeps the top-level TypeDecorator type
around, since a user-defined type will have bind and result
set processing behavior. For both TypeDecorator and Variant,
PG dialect needs to ensure it's looking at the SQLAlchemy
type to check for SmallInteger / BigInteger.