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.
Mike Bayer [Mon, 13 Jun 2016 19:18:13 +0000 (15:18 -0400)]
Deprecate FromClause.count()
count() here is misleading in that it not only
counts from an arbitrary column in the table, it also
does not make accommodations for DISTINCT, JOIN, etc.
as the ORM-level function does. Core should not be
attempting to provide a function like this.
Mike Bayer [Fri, 10 Jun 2016 21:24:36 +0000 (17:24 -0400)]
Ensure CTE internals are handled during clone
The CTE construct was missing a _copy_internals() method
which would handle CTE-specific structures including _cte_alias,
_restates during a clone operation.
Support `postgresql_concurrently` on index dropping.
Also adds version detection so that DROP INDEX CONCURRENTLY
only renders if the Postgresql version is 9.2 or higher;
for CREATE INDEX CONCURRENTLY, version detection is added
to allow the phrase to omit if the Postgresql version is
less than 8.2.
Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Change-Id: I597287e0ebbbe256c957a3579b58ace6848ab4f4
Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/84
Mike Bayer [Sun, 8 May 2016 06:21:57 +0000 (02:21 -0400)]
Use the "committed" values when extracting many-to-one lazyload value
The scalar object set() method calls upon the lazy loader
to get at the "old" value of the attriute, however doesn't
ensure that the "committed" value of the foreign key attributes
is used. If the user has manipulated these attributes and they
themselves have pending, non committed changes, we get the
"new" value which these attributes would have set up if they
were flushed. "old" vs "new" value is always about how the
value has changed since the load, so we always have to use the
DB-persisted values for everything when looking for "old".