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.
Mike Bayer [Fri, 1 Jul 2016 16:44:47 +0000 (12:44 -0400)]
Preserve type for math negation
Fixed issue in SQL math negation operator where the type of the
expression would no longer be the numeric type of the original.
This would cause issues where the type determined result set
behaviors.
Pieter Mulder [Wed, 29 Jun 2016 15:15:44 +0000 (11:15 -0400)]
Repair pickling for Properties object
Fixed bug whereby the ``__getstate__`` / ``__setstate__``
methods for sqlalchemy.util.Properties were
non-working due to the transition in the 1.0 series to ``__slots__``.
The issue potentially impacted some third-party applications.
Pull request courtesy Pieter Mulder.
Mike Bayer [Wed, 29 Jun 2016 15:11:17 +0000 (11:11 -0400)]
Ensure @compiles calls down to the original compilation scheme
Made a slight behavioral change in the ``sqlalchemy.ext.compiler``
extension, whereby the existing compilation schemes for an established
construct would be removed if that construct was itself didn't already
have its own dedicated ``__visit_name__``. This was a
rare occurrence in 1.0, however in 1.1 :class:`.postgresql.ARRAY`
subclasses :class:`.sqltypes.ARRAY` and has this behavior.
As a result, setting up a compilation handler for another dialect
such as SQLite would render the main :class:`.postgresql.ARRAY`
object no longer compilable.
Mike Bayer [Thu, 23 Jun 2016 23:26:28 +0000 (19:26 -0400)]
Make boolean processors consistent between Py/C; coerce to 1/0
The processing performed by the :class:`.Boolean` datatype for backends
that only feature integer types has been made consistent between the
pure Python and C-extension versions, in that the C-extension version
will accept any integer value from the database as a boolean, not just
zero and one; additionally, non-boolean integer values being sent to
the database are coerced to exactly zero or one, instead of being
passed as the original integer value.
Mike Bayer [Mon, 20 Jun 2016 15:39:01 +0000 (11:39 -0400)]
Don't reorder PrimaryKeyConstraint columns if explicit
Dialed back the "order the primary key columns per auto-increment"
described in :ref:`change_mysql_3216` a bit, so that if the
:class:`.PrimaryKeyConstraint` is explicitly defined, the order
of columns is maintained exactly, allowing control of this behavior
when necessary.
Mike Bayer [Mon, 20 Jun 2016 14:08:36 +0000 (10:08 -0400)]
Disable Enum string validation by default
Rolled back the validation rules a bit in :class:`.Enum` to allow
unknown string values to pass through, unless the flag
``validate_string=True`` is passed to the Enum; any other kind of object is
still of course rejected. While the immediate use
is to allow comparisons to enums with LIKE, the fact that this
use exists indicates there may be more unknown-string-comparsion use
cases than we expected, which hints that perhaps there are some
unknown string-INSERT cases too.
saarni [Thu, 26 May 2016 14:15:24 +0000 (10:15 -0400)]
Add TABLESAMPLE clause support.
The TABLESAMPLE clause allows randomly selecting an approximate percentage
of rows from a table. At least DB2, Microsoft SQL Server and recent
Postgresql support this standard clause.