Mike Bayer [Tue, 11 Feb 2020 17:51:46 +0000 (12:51 -0500)]
Begin to disallow back_populates with viewonly=True
A viewonly=True relationship should not be mutated and ideally
mutation itself would raise an error, but we're not there yet.
Warn when a viewonly is to be the target of a back_populates
as this only means that it should be locally mutated, which
by definition will not work as expected because post-flush
it will deliver doubled results, due to its state not being
reset.
Setting a relationship to viewonly=True which is also the target of a
back_populates or backref configuration will now emit a warning and
eventually be disallowed. back_populates refers specifically to mutation
of an attribute or collection, which is disallowed when the attribute is
subject to viewonly=True. The viewonly attribute is not subject to
persistence behaviors which means it will not reflect correct results
when it is locally mutated.
Gord Thompson [Mon, 3 Feb 2020 23:42:45 +0000 (16:42 -0700)]
Fix handling of None as parameter for a datetimeoffset column
Fixed issue where the :class:`.mssql.DATETIMEOFFSET` type would not
accommodate for the ``None`` value, introduced as part of the series of
fixes for this type first introduced in :ticket:`4983`, :ticket:`5045`.
Additionally, added support for passing a backend-specific date formatted
string through this type, as is typically allowed for date/time types on
most other DBAPIs.
Mike Bayer [Mon, 10 Feb 2020 20:38:39 +0000 (15:38 -0500)]
Rework combination exclusions
The technique arrived at for doing exclusions inside of combinations
relies upon comparing all the arguments in a particular combination
to some set of combinations that were gathered as having
"exclusions". This logic is actually broken for the
case where the @testing.combinations has an "id", but if we fix
that, we still have the issue of all the arguments being
compared, which is complicated and also doesn't work for the
case of a py2/py3 incompatibility like a timezone that has
fractional minutes or seconds in it. It's also not clear
if a @testing.combinations that uses lambdas will work either
(maybe it does though because lambdax == lambdax compares...).
anyway, this patch reworks it so that we hit this on the decorator
side instead, where we add our own decorator and go through
the extra effort to create a decorator that accepts an extra
argument of "exclusions" which we can then check in a way that
is local to the whole pytest @combinations thing in the first place.
The only difficulty is that pytest is very sneaky about looking
at the test function so we need to make sure __wrapped__ isn't
set when doing this.
Mike Bayer [Sat, 8 Feb 2020 19:53:21 +0000 (14:53 -0500)]
Fixes for public_factory and mysql/pg dml functions
* ensure that the location indicated by public_factory is
importable
* adjust all of sqlalchemy.sql.expression locations to be correct
* support the case where a public_factory is against a function
that has another public_factory already, and already replaced the
__init__ on the target class
* Use mysql.insert(), postgresql.insert(), don't include .dml in the
class path.
Mike Bayer [Fri, 7 Feb 2020 22:55:07 +0000 (17:55 -0500)]
Vendor inspect.formatannotation
Vendored the ``inspect.formatannotation`` function inside of
``sqlalchemy.util.compat``, which is needed for the vendored version of
``inspect.formatargspec``. The function is not documented in cPython and
is not guaranteed to be available in future Python versions.
Mike Bayer [Thu, 6 Feb 2020 15:26:50 +0000 (10:26 -0500)]
Document SQLite "mixed binary" behavior
The Pysqlite driver can store a string value with
or without an indicator that the value is to be retrieved
as bytes or as a unicode string object. To suit the
use case where a SQLite database has mixed values on a row
by row basis, provide a recipe for a MixedBinary datatype.
Mike Bayer [Tue, 4 Feb 2020 21:46:49 +0000 (16:46 -0500)]
Add second section detailing cascade_backrefs to backref section
We only have docs for "cascade_backrefs" in the session->cascades
documentation, when this really should be mentioned in the chapter
that's all about backrefs. Add a similar section and link to the
original for further detail.
Mike Bayer [Fri, 31 Jan 2020 16:10:08 +0000 (11:10 -0500)]
Warn for runid changing in load events; add restore_load_context flag
Added a new flag :paramref:`.InstanceEvents.restore_load_context` and
:paramref:`.SessionEvents.restore_load_context` which apply to the
:meth:`.InstanceEvents.load`, :meth:`.InstanceEvents.refresh`, and
:meth:`.SessionEvents.loaded_as_persistent` events, which when set will
restore the "load context" of the object after the event hook has been
called. This ensures that the object remains within the "loader context"
of the load operation that is already ongoing, rather than the object being
transferred to a new load context due to refresh operations which may have
occurred in the event. A warning is now emitted when this condition occurs,
which recommends use of the flag to resolve this case. The flag is
"opt-in" so that there is no risk introduced to existing applications.
The change additionally adds support for the ``raw=True`` flag to
session lifecycle events.
Mike Bayer [Tue, 28 Jan 2020 17:34:06 +0000 (12:34 -0500)]
Accommodate for base class when adjusting path for with_polymorphic
Fixed an additional regression in the same area as that of :ticket:`5080`
introduced in 1.3.0b3 via :ticket:`4468` where the ability to create a
joined option across a :func:`.with_polymorphic` into a relationship
against the base class of that with_polymorphic, and then further into
regular mapped relationships would fail as the base class component would
not add itself to the load path in a way that could be located by the
loader strategy. The changes applied in :ticket:`5080` have been further
refined to also accommodate this scenario.
Gord Thompson [Mon, 27 Jan 2020 21:49:28 +0000 (16:49 -0500)]
Add py3.8, py3.9 token to setup.py
Fixes: #5113
<!-- Provide a general summary of your proposed changes in the Title field above -->
### Description
Add py3.8 and py3.9 tokens to setup.py
### Checklist
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)
-->
This pull request is:
- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [x] A short code fix
- please include the issue number, and create an issue if none exists, which
must include a complete example of the issue. one line code fixes without an
issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests. one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.
Gord Thompson [Mon, 13 Jan 2020 01:08:22 +0000 (20:08 -0500)]
Refactor test provisioning to dialect-level files
Fixes: #5085
<!-- Provide a general summary of your proposed changes in the Title field above -->
Move dialect-specific provisioning code to dialect-level copies of provision.py.
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)
-->
This pull request is:
- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [x] A short code fix
- please include the issue number, and create an issue if none exists, which
must include a complete example of the issue. one line code fixes without an
issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests. one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.
Gord Thompson [Mon, 20 Jan 2020 20:21:17 +0000 (15:21 -0500)]
Add test requirement: indexes_with_ascdesc
There are some tests for indexes that include DESC in the
columns. Firebird and maybe others don't support this concept,
so put it under a requirement rule.
Mike Bayer [Wed, 22 Jan 2020 21:27:26 +0000 (16:27 -0500)]
InstanceState default path is RootRegistry, not tuple
Fixed regression caused in 1.3.13 by :ticket:`5056` where a refactor of the
ORM path registry system made it such that a path could no longer be
compared to an empty tuple, which can occur in a particular kind of joined
eager loading path. The "empty tuple" use case has been resolved so that
the path registry is compared to a path registry in all cases; the
:class:`.PathRegistry` object itself now implements ``__eq__()`` and
``__ne__()`` methods which will take place for all equality comparisons and
continue to succeed in the not anticipated case that a non-
:class:`.PathRegistry` object is compared, while emitting a warning that
this object should not be the subject of the comparison.
Mike Bayer [Wed, 22 Jan 2020 16:01:59 +0000 (11:01 -0500)]
Clarify documentation for lazy_loaded_from
This attribute was never available in conjunction with
mapper options, and additionally the use of baked queries
in the lazy loader strategy prevent this attribute from
being reliably available within the before_compile hook
unless baked queries are turned off entirely.
Mike Bayer [Mon, 20 Jan 2020 17:41:22 +0000 (12:41 -0500)]
Adjust natural path to relationship's base mapper for aliased class also
Fixed regression in loader options introduced in 1.3.0b3 via :ticket:`4468`
where the ability to create a loader option using
:meth:`.PropComparator.of_type` targeting an aliased entity that is an
inheriting subclass of the entity which the preceding relationship refers
to would fail to produce a matching path. See also :ticket:`5082` fixed
in this same release which involves a similar kind of issue.
Mike Bayer [Mon, 13 Jan 2020 18:50:38 +0000 (13:50 -0500)]
Adjust use_mapper_path rule for poly subclasses
We must change the approach from 2734439 as the information
loss is breaking subquery eager loading.
Move the adjustment into a deeper set of logic inside
of path_regsitry. We can distinguish between a path
that will "naturally" build from an aliased entity
at the base, vs. one that will "naturally" build
on all raw mappers, based on if when we observe that
we are being given a with_polymorphic(), if the existing
parent path is already in progress or not.
In general, we prefer paths to have as much of the original
information as possible, and the "natural path" is supposed
to be where the loader lookup stuff happens.
Gord Thompson [Thu, 19 Dec 2019 17:20:39 +0000 (12:20 -0500)]
Improve regex parsing of CHECK constraints for PostgreSQL.
Fixed issue where the PostgreSQL dialect would fail to parse a reflected
CHECK constraint that was a boolean-valued function (as opposed to a
boolean-valued expression).
Mike Bayer [Tue, 14 Jan 2020 22:32:12 +0000 (17:32 -0500)]
Establish that contains_eager()->alias can be replaced by of_type
One test in test_of_type was creating a cartesian product
because contains_eager() was used with "alias" to refer
to a with_polymorphic(), but the wp was not used with of_type(),
so the pathing did not know that additional entities were present.
while the docs indicate that of_type() should be used, there is no
reason to use "alias" when you are using of_type(). Attempts
to make this automatic don't work as the current usage contract
with "alias" is that the contains_eager() chain can continue
along in terms of the base entities, which is another example
of the implicit swapping of entities for an aliased version of
themselves that really should be entirely marked as deprecated
throughout 1.4 and removed in 2.0.
So instead, add test coverage for the of_type() versions of
things and begin to make the case that we can remove "alias"
entirely, where previously we thought we would only deprecate
the string form.
For the 1.3 backport we are also picking a little bit of the
lambda combinations improvements that landed in 217948f5c7 and for
some reason were not backported.
Mike Bayer [Fri, 10 Jan 2020 18:16:43 +0000 (13:16 -0500)]
Integrate mapper-level version_id_col with versioned_history
as the versioned_history example supplies an integer version
counter for the purposes of generating an audit trail, this
counter is also suited to be used for optimistic concurrency
detection using the version_id_col feature. Build upon
the test that was first added in ac54ba0f2d8df5a76b6852841b6b3321c0e6c0e2
to provide a flag and some basic documentation.
Mike Bayer [Fri, 10 Jan 2020 15:30:13 +0000 (10:30 -0500)]
Alter unique bound parameter key on deserialize
Fixed bug in sqlalchemy.ext.serializer where a unique
:class:`.BindParameter` object could conflict with itself if it were
present in the mapping itself, as well as the filter condition of the
query, as one side would be used against the non-deserialized version and
the other side would use the deserialized version. Logic is added to
:class:`.BindParameter` similar to its "clone" method which will uniquify
the parameter name upon deserialize so that it doesn't conflict with its
original.
Mike Bayer [Tue, 7 Jan 2020 02:06:10 +0000 (21:06 -0500)]
Set use_mapper_path=True for with_poly subentities
Fixed regression in joined eager loading introduced in 1.3.0b3 via
:ticket:`4468` where the ability to create a joined option across a
:func:`.with_polymorphic` into a polymorphic subclass using
:meth:`.RelationshipProperty.of_type` and then further along regular mapped
relationships would fail as the polymorphic subclass would not add itself
to the load path in a way that could be located by the loader strategy. A
tweak has been made to resolve this scenario.
Mike Bayer [Mon, 6 Jan 2020 19:09:01 +0000 (14:09 -0500)]
Support GenericFunction.name passed as a quoted_name
A function created using :class:`.GenericFunction` can now specify that the
name of the function should be rendered with or without quotes by assigning
the :class:`.quoted_name` construct to the .name element of the object.
Prior to 1.3.4, quoting was never applied to function names, and some
quoting was introduced in :ticket:`4467` but no means to force quoting for
a mixed case name was available. Additionally, the :class:`.quoted_name`
construct when used as the name will properly register its lowercase name
in the function registry so that the name continues to be available via the
``func.`` registry.
Gord Thompson [Tue, 31 Dec 2019 17:42:09 +0000 (12:42 -0500)]
Fix DATETIMEOFFSET formatting to preserve fractional seconds.
Fixed issue where a timezone-aware ``datetime`` value being converted to
string for use as a parameter value of a :class:`.mssql.DATETIMEOFFSET`
column was omitting the fractional seconds.
Mike Bayer [Tue, 31 Dec 2019 16:53:07 +0000 (11:53 -0500)]
Repair uncovered warning in persistnce.py; update versioning tests
Repaired a warning in the ORM flush process that was not covered by test
coverage when deleting objects that use the "version_id" feature. This
warning is generally unreachable unless using a dialect that sets the
"supports_sane_rowcount" flag to False, which is not typically the case
however is possible for some MySQL configurations as well as older Firebird
drivers, and likely some third party dialects.
As part of this change, we would like to establish that versionining-
related warnings are not expected to emit for the core set of
test-covered dialects, and if they are we would like the check for
warning emitted to be explicit, rather than an ignore.
Mike Bayer [Tue, 31 Dec 2019 18:01:59 +0000 (13:01 -0500)]
Bump test_build_query numbers
Due to the decreased caching introduced in
Ifd93856eba550483f95f9ae63d49f36ab068b85a, callcounts have risen
here however they did not pass the threshold in the review.
Bump them now instead.
Federico Caselli [Tue, 31 Dec 2019 01:29:33 +0000 (20:29 -0500)]
Fix test failures under Windows
Fixed a few test failures which would occur on Windows due to SQLite file
locking issues, as well as some timing issues in connection pool related
tests; pull request courtesy Federico Caselli.
Note the pool related issues were fixed by Mike in
I1a7162e67912d22c135fa517b687a073f8fd9151 but are being ticketed
here.
Mike Bayer [Fri, 27 Dec 2019 19:10:36 +0000 (14:10 -0500)]
Note time passage requirement for pool.invalidate()
For Windows, time.time() may only have 16 millisecond
accuracy, so invalidation routines which compare
the time.time() of invalidate() to the time.time() when
the ConnectionRecord last connected may fail in a unit test
environment that does not pause at least this much time
since the ConnectionRecord startup. Using >= for comparison
instead of > was considered but this only leads to more confusing
results as the ConnecitonRecord goes into a re-connect loop
as time continues to not pass.
Overall, while using routines such as Python 3.7's time_ns()
might be helpful, for now make sure tests which rely on this
are marked under timing intensive and add small sleeps.
Mike Bayer [Tue, 31 Dec 2019 01:01:23 +0000 (20:01 -0500)]
Fix newly found rst issue
Likely due to new versions flake8-rst-docstrings or similar,
repair an incorrectly formatted code example in a doc string
causing all the gerrits to fail.
Mike Bayer [Fri, 27 Dec 2019 20:02:31 +0000 (15:02 -0500)]
Test for short term reference cycles and resolve as many as possible
Added test support and repaired a wide variety of unnecessary reference
cycles created for short-lived objects, mostly in the area of ORM queries.
For the 1.3 backport, includes the prefix_anon_map() optimization
from 1.4 / master which inlines the anonymous symbol generation
into a single object. This removes a cycle from the compiler
that otherwise results in a signficantly higher number of
unreachable cycles.
Mike Bayer [Mon, 30 Dec 2019 18:08:17 +0000 (13:08 -0500)]
Include GROUP BY in _should_nest_selectable criteria
Fixed bug where usage of joined eager loading would not properly wrap the
query inside of a subquery when :meth:`.Query.group_by` were used against
the query. When any kind of result-limiting approach is used, such as
DISTINCT, LIMIT, OFFSET, joined eager loading embeds the row-limited query
inside of a subquery so that the collection results are not impacted. For
some reason, the presence of GROUP BY was never included in this criterion,
even though it has a similar effect as using DISTINCT. Additionally, the
bug would prevent using GROUP BY at all for a joined eager load query for
most database platforms which forbid non-aggregated, non-grouped columns
from being in the query, as the additional columns for the joined eager
load would not be accepted by the database.
Federico Caselli [Sun, 29 Dec 2019 02:23:23 +0000 (21:23 -0500)]
Improve two phase transaction requirement detection for PG
Improved detection of two phase transactions requirement for the PostgreSQL
database by testing that max_prepared_transactions is set to a value
greater than 0. Pull request courtesy Federico Caselli.
Carson Ip [Fri, 27 Dec 2019 17:05:30 +0000 (12:05 -0500)]
Fix WeakSequence circular reference
Fixed a reference cycle which could impact the GC behavior of the
:class:`.WeakSequence` object, currently used within one place in certain
mapper configurations. The issue only affects configuration-time
structures. Pull request courtesy Carson Ip.
Mike Bayer [Fri, 20 Dec 2019 16:40:10 +0000 (11:40 -0500)]
Copy bind_processors when altering for expanding IN
Fixed issue where the collection of value processors on a
:class:`.Compiled` object would be mutated when "expanding IN" parameters
were used with a datatype that has bind value processors; in particular,
this would mean that when using statement caching and/or baked queries, the
same compiled._bind_processors collection would be mutated concurrently.
Since these processors are the same function for a given bind parameter
namespace every time, there was no actual negative effect of this issue,
however, the execution of a :class:`.Compiled` object should never be
causing any changes in its state, especially given that they are intended
to be thread-safe and reusable once fully constructed.
Mike Bayer [Thu, 19 Dec 2019 02:50:24 +0000 (21:50 -0500)]
Don't apply aliasing + adaption for simple relationship joins
Identified a performance issue in the system by which a join is constructed
based on a mapped relationship. The clause adaption system would be used
for the majority of join expressions including in the common case where no
adaptation is needed. The conditions under which this adaptation occur
have been refined so that average non-aliased joins along a simple
relationship without a "secondary" table use about 70% less function calls.
Mike Bayer [Thu, 19 Dec 2019 14:19:53 +0000 (09:19 -0500)]
Improve documentation for refresh_flush event
This event does not include INSERTed primary key columns
and additionally will always be limited to default/onupdate
columns. Note better choices for interception of INSERT
events.
Added support for prefixes to the :class:`.CTE` construct, to allow
support for Postgresql 12 "MATERIALIZED" and "NOT MATERIALIZED" phrases.
Pull request courtesy Marat Sharafutdinov.
Mike Bayer [Fri, 13 Dec 2019 17:44:23 +0000 (12:44 -0500)]
Close connection if begin fails
Fixed issue where by if the "begin" of a transaction failed at the Core
engine/connection level, such as due to network error or database is locked
for some transactional recipes, within the context of the :class:`.Session`
procuring that connection from the connection pool and then immediately
returning it, the ORM :class:`.Session` would not close the connection
despite this connection not being stored within the state of that
:class:`.Session`. This would lead to the connection being cleaned out by
the connection pool weakref handler within garbage collection which is an
unpreferred codepath that in some special configurations can emit errors in
standard error.
Mike Bayer [Fri, 6 Dec 2019 16:38:55 +0000 (11:38 -0500)]
Use label reference coercion for select() distinct keyword argument
Fixed bug where "distinct" keyword passed to :func:`.select` would not
treat a string value as a "label reference" in the same way that the
:meth:`.select.distinct` does; it would instead raise unconditionally. This
keyword argument and the others passed to :func:`.select` will ultimately
be deprecated for SQLAlchemy 2.0.
Mike Bayer [Fri, 6 Dec 2019 15:24:25 +0000 (10:24 -0500)]
Include DISTINCT in error message for label reference
Needed to add tests to ensure this label reference is handled
correctly, so also modified the exception message to
be more clear if someone has this error within distinct().
Mike Bayer [Thu, 5 Dec 2019 00:18:57 +0000 (19:18 -0500)]
Introduce lambda combinations
As the ORM's combinatoric tests mostly use entities and
table metadata that's defined in fixtures, we can't use
@testing.combinations directly as it takes place at the
module level. Instead we use lambdas, but to reduce
verbosity we use a code replacement so that the namespace
of the lambda can be provided at runtime rather than
module import time.
Mike Bayer [Mon, 2 Dec 2019 16:47:08 +0000 (11:47 -0500)]
Skip sub-minute timezone tests for Python 3 < 3.7
The datetime.timezone class as of Python 3.7, or SQLAlchemy's port for Python
2, supports seconds and microseconds. For Python 3.6 and earlier, it is not
supported.
Gord Thompson [Tue, 26 Nov 2019 14:57:48 +0000 (09:57 -0500)]
Add DATETIMEOFFSET support for mssql+pyodbc
Repaired support for the :class:`.mssql.DATETIMEOFFSET` datatype on PyODBC,
by adding PyODBC-level result handlers as it does not include native
support for this datatype. This includes usage of the Python 3 "timezone"
tzinfo subclass in order to set up a timezone, which on Python 2 makes
use of a minimal backport of "timezone" in sqlalchemy.util.
Mike Bayer [Fri, 29 Nov 2019 15:50:44 +0000 (10:50 -0500)]
Gracefully degrade for SQLite JSON receiving direct numeric value
Fixed issue to workaround SQLite's behavior of assigning "numeric" affinity
to JSON datatypes, first described at :ref:`change_3850`, which returns
scalar numeric JSON values as a number and not as a string that can be JSON
deserialized. The SQLite-specific JSON deserializer now gracefully
degrades for this case as an exception and bypasses deserialization for
single numeric values, as from a JSON perspective they are already
deserialized.
Also adds a combinatoric fixture for JSON single values within
the dialect-general test suite.
Mike Bayer [Tue, 26 Nov 2019 16:09:00 +0000 (11:09 -0500)]
Don't clear metadata in TablesTest setup
Some upcoming commits will make use of @metadata_fixture
within a TablesTest class. As the fixture takes place before
setup, remove anything in setup that would interfere with it.
Change-Id: I4f16889c4c02cb2835dcf4886eb09ece848d8109
References: I507bc405eee6cae2c5991345d0eac53a37fe7512
(cherry picked from commit d9e43c518f90c0a79c05d7e6ea2559aef5157f52)
Mike Bayer [Sat, 23 Nov 2019 17:25:20 +0000 (12:25 -0500)]
Generalize DescriptorProps.uses_objects
Previously, uses_objects was specific to the SynonymAttribute;
generalize it so that it defaults to False for other DescriptorProps.
Immediate fix is against CompositeProperty.
Fixed regression introduced in 1.3.0 related to the association proxy
refactor in :ticket:`4351` that prevented :func:`.composite` attributes
from working in terms of an association proxy that references them.
Add test coverage for association proxies that refer to Composite
attributes as endpoints.
Mike Bayer [Wed, 20 Nov 2019 17:15:57 +0000 (12:15 -0500)]
Warn for settings that don't work with viewonly=True
Setting persistence-related flags on :func:`.relationship` while also
setting viewonly=True will now emit a regular warning, as these flags do
not make sense for a viewonly=True relationship. In particular, the
"cascade" settings have their own warning that is generated based on the
individual values, such as "delete, delete-orphan", that should not apply
to a viewonly relationship. Note however that in the case of "cascade",
these settings are still erroneously taking effect even though the
relationship is set up as "viewonly". In 1.4, all persistence-related
cascade settings will be disallowed on a viewonly=True relationship in
order to resolve this issue.
Mike Bayer [Fri, 22 Nov 2019 15:27:02 +0000 (10:27 -0500)]
Don't raise w/ raiseload strategy for many-to-one history in flush
Fixed issue involving ``lazy="raise"`` strategy where an ORM delete of an
object would raise for a simple "use-get" style many-to-one relationship
that had lazy="raise" configured. This is inconsistent vs. the change
introduced in 1.3 as part of :ticket:`4353`, where it was established that
a history operation that does not expect emit SQL should bypass the
``lazy="raise"`` check, and instead effectively treat it as
``lazy="raise_on_sql"`` for this case. The fix adjusts the lazy loader
strategy to not raise for the case where the lazy load was instructed that
it should not emit SQL if the object were not present.
Mike Bayer [Tue, 19 Nov 2019 14:30:31 +0000 (09:30 -0500)]
Skip on slice assignment to self
Fixed issue where when assigning a collection to itself as a slice, the
mutation operation would fail as it would first erase the assigned
collection inadvertently. As an assignment that does not change the
contents should not generate events, the operation is now a no-op. Note
that the fix only applies to Python 3; in Python 2, the ``__setitem__``
hook isn't called in this case; ``__setslice__`` is used instead which
recreates the list item-by-item in all cases.
Mike Bayer [Mon, 11 Nov 2019 21:17:50 +0000 (16:17 -0500)]
Detect PyMySQL connection was killed
Added "Connection was killed" message interpreted from the base
pymysql.Error class in order to detect closed connection, based on reports
that this message is arriving via a pymysql.InternalError() object which
indicates pymysql is not handling it correctly.
Mike Bayer [Thu, 7 Nov 2019 20:31:48 +0000 (15:31 -0500)]
Add type accessors for JSON indexed/pathed element access
Added new accessors to expressions of type :class:`.JSON` to allow for
specific datatype access and comparison, covering strings, integers,
numeric, boolean elements. This revises the documented approach of
CASTing to string when comparing values, instead adding specific
functionality into the PostgreSQL, SQlite, MySQL dialects to reliably
deliver these basic types in all cases.
The change also delivers a new feature to the test exclusions
system so that combinations and exclusions can be used together.
Mike Bayer [Sun, 10 Nov 2019 20:42:40 +0000 (15:42 -0500)]
Exclude local columns when adapting secondary in a join condition
Fixed ORM bug where a "secondary" table that referred to a selectable which
in some way would refer to the local primary table would apply aliasing to
both sides of the join condition when a relationship-related join, either
via :meth:`.Query.join` or by :func:`.joinedload`, were generated. The
"local" side is now excluded.
Mike Bayer [Sat, 9 Nov 2019 17:33:16 +0000 (12:33 -0500)]
Support exclusion rules in combinations
Like py.test we need to be able to mark certain combination
elements with exclusion rules. Add additional logic
to pytestlplugin and exclusions so that the exclusion decorators
can be added to the combination tuples, where they will be applied
to the decorated function along with a qualifier that the test
arguments need to match what's given.
Mike Bayer [Sat, 9 Nov 2019 21:12:30 +0000 (16:12 -0500)]
Interpret empty LIMIT, expression LIMIT correctly
Fixed issue in MSSQL dialect where an expression-based OFFSET value in a
SELECT would be rejected, even though the dialect can render this
expression inside of a ROW NUMBER-oriented LIMIT/OFFSET construct.
CaselIT [Mon, 4 Nov 2019 22:11:21 +0000 (17:11 -0500)]
Support for generated columns
Added DDL support for "computed columns"; these are DDL column
specifications for columns that have a server-computed value, either upon
SELECT (known as "virtual") or at the point of which they are INSERTed or
UPDATEd (known as "stored"). Support is established for Postgresql, MySQL,
Oracle SQL Server and Firebird. Thanks to Federico Caselli for lots of work
on this one.
ORM round trip tests included. The ORM makes use of existing
FetchedValue support and no additional ORM logic is present for
the basic feature.
It has been observed that Oracle RETURNING does not return the
new value of a computed column upon UPDATE; it returns the
prior value. As this is very dangerous, a warning is emitted
if a computed column is rendered into the RETURNING clause
of an UPDATE statement.
Mike Bayer [Fri, 8 Nov 2019 14:48:27 +0000 (09:48 -0500)]
Work around setuptools issue #1902
Added a workaround for a setuptools-related failure that has been observed
as occurring on Windows installations, where setuptools is not correctly
reporting a build error when the MSVC build dependencies are not installed
and therefore not allowing graceful degradation into non C extensions
builds.