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".
Add "render_nulls" flag to bulk_insert as optional performance optimization
Currently, ``Session.bulk_insert_mappings`` omits NULL values which
causes it to break up batches of inserts based on which batches
contain NULL and which do not.
By adding this flag, the same columns are rendered in the INSERT
for all rows allowing them to be batched. The downside is that
server-side defaults are omitted.
Doctext-author: Mike Bayer <mike_mp@zzzcomputing.com>
Change-Id: Iec5969304d4bdbf57290b200331bde02254aa3a5
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/243
Sebastian Bank [Tue, 12 Apr 2016 03:16:39 +0000 (23:16 -0400)]
Refine PG inspection methods
This refines get_schema_names(), get_table_names(),
get_view_defintion(), _get_foreign_table_names(),
and get_view_names() to use better queries and
remove unnecessary explicit encoding logic.
Mike Bayer [Fri, 3 Jun 2016 19:07:14 +0000 (15:07 -0400)]
Ensure 'options' is always present in foreign key info
Regarding 0e88bcc30ed49193b91f248123f526fa30007f22, "options"
needs to be present as a key in the dictionary because Alembic
uses this as a guide to know if the backend is even capable of
reporting on foreign key options.
Mike Bayer [Thu, 2 Jun 2016 17:52:27 +0000 (13:52 -0400)]
Skip UniqueConstraint marked by unique=True in tometadata
Fixes an issue where a Column would be copied with unique=True
and at the same time the UniqueConstraint would also be copied,
leading to duplicate UniqueConstraints in the target table,
when tometadata() is used. Imitates the same logic used
by index=True/Index to avoid duplicates. For some reason
a fix was implemented for Index long ago but never for
UniqueConstraint.
Sheila Allen [Mon, 11 Apr 2016 19:29:03 +0000 (15:29 -0400)]
Use new mxODBC 3.3.4 varbinary null symbol
Use new mxODBC 3.3.4 varbinary null symbol with VARBINARY
data types when value is None(based on similar change to pyodbc).
Fix a test to pass on mxODBC starting w 3.3.3 version