Mike Bayer [Tue, 19 Jan 2016 18:34:42 +0000 (13:34 -0500)]
- Fixed issue where two same-named relationships that refer to
a base class and a concrete-inherited subclass would raise an error
if those relationships were set up using "backref", while setting up the
identical configuration using relationship() instead with the conflicting
names would succeed, as is allowed in the case of a concrete mapping.
fixes #3630
Mike Bayer [Tue, 19 Jan 2016 17:44:42 +0000 (12:44 -0500)]
- The ``str()`` call for :class:`.Query` will now take into account
the :class:`.Engine` to which the :class:`.Session` is bound, when
generating the string form of the SQL, so that the actual SQL
that would be emitted to the database is shown, if possible. Previously,
only the engine associated with the :class:`.MetaData` to which the
mappings are associated would be used, if present. If
no bind can be located either on the :class:`.Session` or on
the :class:`.MetaData` to which the mappings are associated, then
the "default" dialect is used to render the SQL, as was the case
previously. fixes #3081
Mike Bayer [Mon, 18 Jan 2016 22:35:44 +0000 (17:35 -0500)]
- Fixed bug where some exception re-raise scenarios would attach
the exception to itself as the "cause"; while the Python 3 interpreter
is OK with this, it could cause endless loops in iPython.
fixes #3625
- add tests for reraise, raise_from_cause
- raise_from_cause is the same on py2k/3k, use just one function
Mike Bayer [Thu, 14 Jan 2016 23:06:26 +0000 (18:06 -0500)]
- A deep improvement to the recently added :meth:`.TextClause.columns`
method, and its interaction with result-row processing, now allows
the columns passed to the method to be positionally matched with the
result columns in the statement, rather than matching on name alone.
The advantage to this includes that when linking a textual SQL statement
to an ORM or Core table model, no system of labeling or de-duping of
common column names needs to occur, which also means there's no need
to worry about how label names match to ORM columns and so-forth. In
addition, the :class:`.ResultProxy` has been further enhanced to
map column and string keys to a row with greater precision in some
cases. fixes #3501
- reorganize the initialization of ResultMetaData for readability
and complexity; use the name "cursor_description", define the
task of "merging" cursor_description with compiled column information
as its own function, and also define "name extraction" as a separate task.
- fully change the name we use in the "ambiguous column" error to be the
actual name that was ambiguous, modify the C ext also
Mike Bayer [Thu, 14 Jan 2016 22:18:21 +0000 (17:18 -0500)]
- fix some old verbiage that refers to text() as an "implicit" thing
for SQL fragments; we've deprecated that in 1.0 and its a good idea
to document like this for 0.9 as well.
Mike Bayer [Sun, 10 Jan 2016 22:47:38 +0000 (17:47 -0500)]
- refactor a bit the loader options system to make it a bit more
intelligible, given the fixes for ref #3623. unfortunately the system
is still quite weird even though it was rewritten to be... less weird
Mike Bayer [Sun, 10 Jan 2016 16:48:53 +0000 (11:48 -0500)]
- fix link to types in metadata, fixes #3618
- fix "version" got whacked into "f" in core tutorial
- fix short underline in automap
- fix unmatched boldface in session events
Mike Bayer [Sat, 9 Jan 2016 15:10:20 +0000 (10:10 -0500)]
- Fixed regression since 0.9 where the 0.9 style loader options
system failed to accommodate for multiple :func:`.undefer_group`
loader options in a single query. Multiple :func:`.undefer_group`
options will now be taken into account even against the same
entity. fixes #3623
Mike Bayer [Sat, 9 Jan 2016 03:11:09 +0000 (22:11 -0500)]
- Multi-tenancy schema translation for :class:`.Table` objects is added.
This supports the use case of an application that uses the same set of
:class:`.Table` objects in many schemas, such as schema-per-user.
A new execution option
:paramref:`.Connection.execution_options.schema_translate_map` is
added. fixes #2685
- latest tox doesn't like the {posargs} in the profile rerunner
Mike Bayer [Wed, 6 Jan 2016 22:27:30 +0000 (17:27 -0500)]
- add limiting criteria to the JSON tests so that we don't
attempt integer indexed access from a key/value object nor
string access from an integer-indexed array, as earlier Postgresql
versions (prior to 9.4) don't allow this
Mike Bayer [Wed, 6 Jan 2016 22:20:57 +0000 (17:20 -0500)]
- Added a new entrypoint system to the engine to allow "plugins" to
be stated in the query string for a URL. Custom plugins can
be written which will be given the chance up front to alter and/or
consume the engine's URL and keyword arguments, and then at engine
create time will be given the engine itself to allow additional
modifications or event registration. Plugins are written as a
subclass of :class:`.CreateEnginePlugin`; see that class for
details.
fixes #3536
Mike Bayer [Wed, 6 Jan 2016 17:40:34 +0000 (12:40 -0500)]
- Added :class:`.mysql.JSON` for MySQL 5.7. The JSON type provides
persistence of JSON values in MySQL as well as basic operator support
of "getitem" and "getpath", making use of the ``JSON_EXTRACT``
function in order to refer to individual paths in a JSON structure.
fixes #3547
- Added a new type to core :class:`.types.JSON`. This is the
base of the PostgreSQL :class:`.postgresql.JSON` type as well as that
of the new :class:`.mysql.JSON` type, so that a PG/MySQL-agnostic
JSON column may be used. The type features basic index and path
searching support.
fixes #3619
- reorganization of migration docs etc. to try to refer both to
the fixes to JSON that helps Postgresql while at the same time
indicating these are new features of the new base JSON type.
- a rework of the Array/Indexable system some more, moving things
that are specific to Array out of Indexable.
- new operators for JSON indexing added to core so that these can
be compiled by the PG and MySQL dialects individually
- rename sqltypes.Array to sqltypes.ARRAY - as there is no generic
Array implementation, this is an uppercase type for now, consistent
with the new sqltypes.JSON type that is also not a generic implementation.
There may need to be some convention change to handle the case of
datatypes that aren't generic, rely upon DB-native implementations,
but aren't necessarily all named the same thing.
Mike Bayer [Tue, 5 Jan 2016 20:12:56 +0000 (15:12 -0500)]
- dont forwards-report tons of 1.0.x changes in the unreleased 1.1;
only when a 1.1.x is released would we want to capture what's still
sitting in a 1.0.x changelog
Mike Bayer [Tue, 5 Jan 2016 15:25:36 +0000 (10:25 -0500)]
- Fixed 1.0 regression where the eager fetch of cursor.rowcount was
no longer called for an UPDATE or DELETE statement emitted via plain
text or via the :func:`.text` construct, affecting those drivers
that erase cursor.rowcount once the cursor is closed such as SQL
Server ODBC and Firebird drivers.
fixes #3622
Mike Bayer [Thu, 24 Dec 2015 03:59:44 +0000 (22:59 -0500)]
- Fixed an assertion that would raise somewhat inappropriately
if a :class:`.Index` were associated with a :class:`.Column` that
is associated with a lower-case-t :class:`.TableClause`; the
association should be ignored for the purposes of associating
the index with a :class:`.Table`.
fixes #3616
Mike Bayer [Tue, 22 Dec 2015 17:04:45 +0000 (12:04 -0500)]
- An adjustment to the regular expression used to parse MySQL views,
such that we no longer assume the "ALGORITHM" keyword is present in
the reflected view source, as some users have reported this not being
present in some Amazon RDS environments.
fixes #3613
Mike Bayer [Wed, 16 Dec 2015 02:44:00 +0000 (21:44 -0500)]
- Fixed bug in baked loader system where the systemwide monkeypatch
for setting up baked lazy loaders would interfere with other
loader strategies that rely on lazy loading as a fallback, e.g.
joined and subquery eager loaders, leading to ``IndexError``
exceptions at mapper configuration time.
fixes #3612
Mike Bayer [Tue, 15 Dec 2015 19:00:50 +0000 (14:00 -0500)]
- Fixed regression caused in 1.0.10 by the fix for :ticket:`3593` where
the check added for a polymorphic joinedload from a
poly_subclass->class->poly_baseclass connection would fail for the
scenario of class->poly_subclass->class.
fixes #3611
Mike Bayer [Mon, 14 Dec 2015 23:01:32 +0000 (18:01 -0500)]
- a few tweaks to allow "server_defaults" to be a little more linkable;
remove "undoc members" that was putting some random server_default
atributes from ColumnClause
Mike Bayer [Mon, 14 Dec 2015 22:53:56 +0000 (17:53 -0500)]
- since we are mutating the statement in a loop, start with
the same cached starting statement each time. no issue has been observed
with the former but it could perhaps have issues w/ versioning
or eager_defaults
Mike Bayer [Mon, 14 Dec 2015 22:39:50 +0000 (17:39 -0500)]
- Fixed bug where :meth:`.Session.bulk_update_mappings` and related
would not bump a version id counter when in use. The experience
here is still a little rough as the original version id is required
in the given dictionaries and there's not clean error reporting
on that yet.
fixes #3610
Mike Bayer [Mon, 14 Dec 2015 22:24:47 +0000 (17:24 -0500)]
- Fixed bug in :meth:`.Update.return_defaults` which would cause all
insert-default holding columns not otherwise included in the SET
clause (such as primary key cols) to get rendered into the RETURNING
even though this is an UPDATE.
- Major fixes to the :paramref:`.Mapper.eager_defaults` flag, this
flag would not be honored correctly in the case that multiple
UPDATE statements were to be emitted, either as part of a flush
or a bulk update operation. Additionally, RETURNING
would be emitted unnecessarily within update statements.
Mike Bayer [Sun, 13 Dec 2015 02:07:25 +0000 (21:07 -0500)]
- Fixed bug where use of the :meth:`.Query.select_from` method would
cause a subsequent call to the :meth:`.Query.with_parent` method to
fail. fixes #3606
- add mark-as-fail test for #3607
Mike Bayer [Thu, 10 Dec 2015 23:27:14 +0000 (18:27 -0500)]
- convert ORM tutorial and basic_relationships to favor
back_populates while still maintaining great familiarity
w/ backref so as not to confuse people. fixes #3390
Mike Bayer [Thu, 10 Dec 2015 22:09:47 +0000 (17:09 -0500)]
- The ORM and Core tutorials, which have always been in doctest format,
are now exercised within the normal unit test suite in both Python
2 and Python 3.
- remove the old testdocs.py runner and replace with test/base/test_tutorials.py
- use pytest's unicode fixer so that we can test for unicode strings
in both py2k/3k
- use py3k format overall for prints, exceptions
- add other fixers to guarantee deterministic results
- add skips and ellipses to outputs that aren't worth matching
Mike Bayer [Thu, 10 Dec 2015 00:07:51 +0000 (19:07 -0500)]
- refactor of adapt_like_to_iterable(), fixes #3457.
Includes removal of adapt_like_to_iterable() as well
as _set_iterable(), uses __slots__ for collectionadapter,
does much less duck typing of collections.
Mike Bayer [Wed, 9 Dec 2015 23:15:25 +0000 (18:15 -0500)]
- Fixed issue within the :meth:`.Insert.from_select` construct whereby
the :class:`.Select` construct would have its ``._raw_columns``
collection mutated in-place when compiling the :class:`.Insert`
construct, when the target :class:`.Table` has Python-side defaults.
The :class:`.Select` construct would compile standalone with the
erroneous column present subsequent to compilation of the
:class:`.Insert`, and the the :class:`.Insert` statement itself would
fail on a second compile attempt due to duplicate bound parameters.
fixes #3603
Mike Bayer [Mon, 7 Dec 2015 22:24:09 +0000 (17:24 -0500)]
- Fixed bug in MySQL reflection where the "fractional sections portion"
of the :class:`.mysql.DATETIME`, :class:`.mysql.TIMESTAMP` and
:class:`.mysql.TIME` types would be incorrectly placed into the
``timestamp`` attribute, which is unused by MySQL, instead of the
``fsp`` attribute.
fixes #3602
Mike Bayer [Mon, 7 Dec 2015 17:36:36 +0000 (12:36 -0500)]
- write a real inline documentation section for from_self(),
building on the example of query.join(). Ideally all the methods
in Query would have this kind of thing. fixes #3544
Mike Bayer [Fri, 4 Dec 2015 16:52:16 +0000 (11:52 -0500)]
- The :meth:`.Session.merge` method now tracks pending objects by
primary key before emitting an INSERT, and merges distinct objects with
duplicate primary keys together as they are encountered, which is
essentially semi-deterministic at best. This behavior
matches what happens already with persistent objects.
fixes #3601
Mike Bayer [Wed, 2 Dec 2015 17:13:57 +0000 (12:13 -0500)]
- Fixed issue where post_update on a many-to-one relationship would
fail to emit an UPDATE in the case where the attribute were set to
None and not previously loaded.
fixes #3599
Mike Bayer [Wed, 2 Dec 2015 00:03:03 +0000 (19:03 -0500)]
- Fixed bug where CREATE TABLE with a no-column table, but a constraint
such as a CHECK constraint would render an erroneous comma in the
definition; this scenario can occur such as with a Postgresql
INHERITS table that has no columns of its own.
fixes #3598
Mike Bayer [Mon, 30 Nov 2015 18:15:40 +0000 (13:15 -0500)]
- Added the error "20006: Write to the server failed" to the list
of disconnect errors for the pymssql driver, as this has been observed
to render a connection unusable.
fixes #3585
Nils Philippsen [Mon, 9 Nov 2015 13:50:23 +0000 (14:50 +0100)]
py2k: accept unicode literals on :func:`backref`, too
Fixed bug where in Py2K a unicode literal would not be accepted as the
string name of a class or other argument within declarative using
:func:`.backref` on :func:`.relationship`.
Mike Bayer [Mon, 30 Nov 2015 17:19:26 +0000 (12:19 -0500)]
- A descriptive ValueError is now raised in the event that SQL server
returns an invalid date or time format from a DATE or TIME
column, rather than failing with a NoneType error. Pull request
courtesy Ed Avis.
pullreq github:206
Mike Bayer [Sun, 29 Nov 2015 16:42:55 +0000 (11:42 -0500)]
- Fixed an issue in baked queries where the .get() method, used either
directly or within lazy loads, didn't consider the mapper's "get clause"
as part of the cache key, causing bound parameter mismatches if the
clause got re-generated. This clause is cached by mappers
on the fly but in highly concurrent scenarios may be generated more
than once when first accessed.
fixes #3597
Mike Bayer [Sat, 28 Nov 2015 19:30:05 +0000 (14:30 -0500)]
- Added support for parameter-ordered SET clauses in an UPDATE
statement. This feature is available by passing the
:paramref:`~.sqlalchemy.sql.expression.update.preserve_parameter_order`
flag either to the core :class:`.Update` construct or alternatively
adding it to the :paramref:`.Query.update.update_args` dictionary at
the ORM-level, also passing the parameters themselves as a list of 2-tuples.
Thanks to Gorka Eguileor for implementation and tests.
adapted from pullreq github:200