Commit Graph

11998 Commits

Author SHA1 Message Date
mollardthomas cf609c19bc Add support for filtered indexes for mssql dialect 2019-05-03 14:46:50 +02:00
Bjørnar Myrheim cdd01a06f7 Include GenericTypeCompiler in docs
Fixes: #4411
Change-Id: Ic60e78555651d05ff0492650bd7647685b867671
Closes: #4651
2019-05-02 10:19:17 -06:00
Mike Bayer ae14861a31 Make the GenericFunction registry fully case insensitive
Registered function names based on :class:`.GenericFunction` are now
retrieved in a case-insensitive fashion in all cases, removing the
deprecation logic from 1.3 which temporarily allowed multiple
:class:`.GenericFunction` objects to exist with differing cases.   A
:class:`.GenericFunction` that replaces another on the same name whether or
not it's case sensitive emits a warning before replacing the object.

Fixes: #4649
Change-Id: I265ae19833132db07ed5b5ae40c4d24f659b1ab3
2019-04-30 14:01:52 -04:00
Adrien Berchet a10a4ea124 Add case insensitivity feature to GenericFunction.
The :class:`.GenericFunction` namespace is being migrated so that function
names are looked up in a case-insensitive manner, as SQL  functions do not
collide on case sensitive differences nor is this something which would
occur with user-defined functions or stored procedures.   Lookups for
functions declared with :class:`.GenericFunction` now use a case
insensitive scheme,  however a deprecation case is supported which allows
two or more :class:`.GenericFunction` objects with the same name of
different cases to exist, which will cause case sensitive lookups to occur
for that particular name, while emitting a warning at function registration
time.  Thanks to Adrien Berchet for a lot of work on this complicated
feature.

Fixes: #4569
Closes: #4570
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4570
Pull-request-sha: 37d4f3322b

Change-Id: Ief07c6eb55bf398f6aad85b60ef13ee6d1173109
2019-04-29 17:24:32 -04:00
mike bayer 6486530405 Merge "Add _cache_key implementation." 2019-04-29 18:53:43 +00:00
mike bayer 7a80f64503 Merge "Reimplement .compare() in terms of a visitor" 2019-04-29 18:52:03 +00:00
Mike Bayer 08da8115a6 Add _cache_key implementation.
This leverages the work started in #4336 to allow ClauseElement
structures to be cachable based on structure, not just identity.

Change-Id: Ia99ddeb5353496dd7d61243245685f02b98d8100
2019-04-29 12:45:45 -04:00
Mike Bayer 0995220750 Reimplement .compare() in terms of a visitor
Reworked the :meth:`.ClauseElement.compare` methods in terms of a new
visitor-based approach, and additionally added test coverage ensuring that
all :class:`.ClauseElement` subclasses can be accurately compared
against each other in terms of structure.   Structural comparison
capability is used to a small degree within the ORM currently, however
it also may form the basis for new caching features.

Fixes: #4336
Change-Id: I581b667d8e1642a6c27165cc9f4aded1c66effc6
2019-04-29 11:54:25 -04:00
mike bayer a3145cffe2 Merge "Warn on merge of already-pending object" 2019-04-28 18:43:37 +00:00
Mike Bayer 23a1c60982 Warn on merge of already-pending object
A warning is now emitted for the case where a transient object is being
merged into the session with :meth:`.Session.merge` when that object is
already transient in the :class:`.Session`.   This warns for the case where
the object would normally be double-inserted.

Fixes: #4647
Change-Id: Ie5223a59a2856664bf283017e962caf8c4230536
2019-04-28 12:44:00 -04:00
mike bayer 0ee9d61e87 Merge "Add additional parsing to extract the "MariaDB" keyword from version string" 2019-04-28 03:16:51 +00:00
Mike Bayer 2f55c84405 - continued 1.4 setup, somehow the commit didn't work
Fixes: #4631
Change-Id: I400e388a704aa6ee7722a89687a033083ce22550
2019-04-27 17:19:31 -04:00
Mike Bayer 1fbc596766 - initial 1.4 setup
Fixes: #4631
Change-Id: I7ff2ae98be6db571c9dacc75e912488b8a9bbdbb
2019-04-27 17:18:08 -04:00
Mike Bayer bbc11d621a fix RST link format
Change-Id: I52122759a92d2fa4bab93ac75c21a77f79eace5a
2019-04-25 17:26:57 -05:00
Mike Bayer 6874ee2277 remote_attr and local_attr refer to class bound attributes, not
MapperProperty

Change-Id: If5fee69474f295e8c4bef891f5360f6b54080bbf
2019-04-25 17:23:12 -05:00
Mike Bayer 049386648b - formatting typo
Change-Id: Ia34c2f9a6c3db83bbe0f0a06f82aa04c603cb521
2019-04-25 17:16:43 -05:00
Mike Bayer b954be661b Add ORM documentation for as_comparison()
In #3831 we added the ability for SQL functions to be used in
primaryjoin conditions as the source of comparison, however we
didn't add documentation from the main relationship docs so
nobody could find it unless they read the migration notes.
Since the two use cases that have come up for this are
materialized path with string functions, and geometry functions,
add the example based on the use case requested in
https://github.com/geoalchemy/geoalchemy2/issues/220#issuecomment-486709055

This example hasn't been tested yet and is subject to
revision.

Change-Id: I410d8ffade3f17cf616fc5056f27d7d32092207b
2019-04-25 10:51:30 -05:00
Mike Bayer 95dd8768d4 Add additional parsing to extract the "MariaDB" keyword from version string
Enhanced MySQL/MariaDB version string parsing to accommodate for exotic
MariaDB version strings where the "MariaDB" word is embedded among other
alphanumeric characters such as "MariaDBV1".   This detection is critical in
order to correctly accomodate for API features that have split between MySQL
and MariaDB such as the "transaction_isolation" system variable.

Fixes: #4624
Change-Id: Iba4b56535855629a974b1e24e012b07383d24199
2019-04-24 13:11:07 -05:00
mike bayer 710ff57062 Merge "negate True/False separately from other elements" 2019-04-23 22:37:19 +00:00
Mike Bayer 9fff85c8c0 Remove sqla_nose.py from MANIFEST.in
Removed errant "sqla_nose.py" symbol from MANIFEST.in which created an
undesirable warning message.

Fixes: #4625
Change-Id: I3784e82847d2ebfdd967dd9e2ab628d0ae5f415f
2019-04-23 14:48:15 -05:00
Mike Bayer a09b879a38 - black -l79 update
Change-Id: I8e6211af91a322b3c212f16e77a0c0f6e9a5e019
2019-04-20 21:23:55 -04:00
Mike Bayer e9737a9d9b negate True/False separately from other elements
Fixed issue where double negation of a boolean column wouldn't reset
the "NOT" operator.

Fixes: #4618
Change-Id: Ica280a0d6b5b0870aa2d05c4d059a1e559e6b12a
(cherry picked from commit 18f25f50353d9736e6638266585b2cb3ef7b0ea4)
2019-04-18 13:41:10 -04:00
vpsx 6758a45959 Use "parent object" instead of "primary object" 2019-04-17 18:48:40 -05:00
Mike Bayer e5fabeb9f9 cherry-pick changelog update for 1.2.20 2019-04-15 12:29:31 -04:00
Mike Bayer 30ceb5de74 - 1.2.19
(cherry picked from commit f178bac2fd)
2019-04-15 12:23:29 -04:00
Mike Bayer e5b0993197 Version 1.3.4 placeholder 2019-04-15 12:08:01 -04:00
Mike Bayer 47a2ab9e35 - 1.3.3 rel_1_3_3 2019-04-15 11:46:47 -04:00
Mike Bayer c62dff8e65 Add 1.3.x versions to still unreleased 1.2 backport fixes
Change-Id: Iee2a447c032575ff845eb4ba9d01de0be98065a2
2019-04-15 11:44:14 -04:00
Mike Bayer dfd20fbbdb Use pytest items in custom collection
We have a custom test collection hook that did not take
node of the actual list of functions in items.  By looking
in this list we now support the class/function arguments
passed to the py.test command line.

Change-Id: I1238c7c5796a296037ab9ef3bedf0f619a730481
2019-04-13 17:05:08 -04:00
Mike Bayer 17413bbf10 Black updates
Updating for a few black adjustments

Change-Id: I9c8abadd1ccd6173e6d68dd62f14cec208cc304a
2019-04-11 14:23:29 -04:00
mike bayer 53c65ed93a Merge "Don't use and_() inside of Query.filter_by" 2019-04-11 01:00:19 +00:00
Mike Bayer 36949938e8 Don't use and_() inside of Query.filter_by
Adjusted the :meth:`.Query.filter_by` method to not call :func:`.and()`
internally against multiple criteria, instead passing it off to
:meth:`.Query.filter` as a series of criteria, instead of a single criteria.
This allows :meth:`.Query.filter_by` to defer to :meth:`.Query.filter`'s
treatment of variable numbers of clauses, including the case where the list
is empty.  In this case, the :class:`.Query` object will not have a
``.whereclause``, which allows subsequent "no whereclause" methods like
:meth:`.Query.select_from` to behave consistently.

Fixes: #4606
Change-Id: Ifc8cdbf13accca2236068ef70114a7c35ab159ff
2019-04-10 11:56:49 -04:00
mike bayer deed49489b Merge "Add __reduce_ex__ to MutableList; add compat for older pickles" 2019-04-10 01:14:57 +00:00
Mike Bayer 21099479da Add __reduce_ex__ to MutableList; add compat for older pickles
Fixed bug where using ``copy.copy()`` or ``copy.deepcopy()`` on
:class:`.MutableList` would cause the items within the list to be
duplicated, due to an inconsistency in how Python pickle and copy both make
use of ``__getstate__()`` and ``__setstate__()`` regarding lists.  In order
to resolve, a ``__reduce_ex__`` method had to be added to
:class:`.MutableList`.  In order to maintain backwards compatibility with
existing pickles based on ``__getstate__()``, the ``__setstate__()`` method
remains as well; the test suite asserts that pickles made against the old
version of the class can still be deserialized by the pickle module.

Also modified sqlalchemy.testing.util.picklers to return picklers all the way through
pickle.HIGHEST_PROTOCOL.

Fixes: #4603
Change-Id: I7f78b9cfb89d59a706248536c553dc5e1d987b88
2019-04-09 21:13:56 -04:00
Mike Bayer c29b352d56 Propagate query-arg-only URL to psycopg2; don't send blank host
Fixed regression from release 1.3.2 caused by 🎫`4562` where a URL
that contained only a query string and no hostname, such as for the
purposes of specifying a service file with connection information, would no
longer be propagated to psycopg2 properly.   The change in 🎫`4562`
has been adjusted to further suit psycopg2's exact requirements, which is
that if there are any connection parameters whatsoever, the "dsn" parameter
is no longer required, so in this case the query string parameters are
passed alone.

Fixes: #4601
Change-Id: Ic29a8b77bcf50ee996968bab25aaac7ae4bfc26f
2019-04-09 17:40:14 -04:00
Mike Bayer 1ec2f7cfd6 Update link for cx_Oracle
Fixes: #4596
Change-Id: I80205d51fe500520030f2c94c06363e1fb6f9c65
2019-04-05 10:20:08 -04:00
jaskiratsingh 2b25827b84 Improve documentation for connection pool logging
Also do a general pass for logging + doc formatting,
add more cross-linking and remove obsolete information such
as "echo_uow"/

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Fixes: #4571
Closes: #4583
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4583
Pull-request-sha: e98ad34eca

Change-Id: I03f7354a4ef55fd8b6a51d03a280579f36e8a06c
2019-04-05 10:14:55 -04:00
Mike Bayer 6845be0927 Enhance documentation for string compilation use cases
- Add a web link for UnsupportedCompilationError
- Add new section to errors.rst
- add more detail and cross-linking to the FAQ
- include security caveats for parameter rendering

Fixes: #4595
Change-Id: I31ea57c18d65770cd2a51276bbe2847a9eb72bba
2019-04-04 21:44:49 -04:00
Matt Lewellyn 97d4d15fde MSSQL: only compile ORDER BY if it will be rendered
Fixed issue in SQL Server dialect where if a bound parameter were present in
an ORDER BY expression that would ultimately not be rendered in the SQL
Server version of the statement, the parameters would still be part of the
execution parameters, leading to DBAPI-level errors.  Pull request courtesy
Matt Lewellyn.

Fixes: #4587
Closes: #4588
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4588
Pull-request-sha: 2992a473e0

Change-Id: Ie709aefdb1babf810bb81526289448f8cc7a4cb1
2019-04-04 10:52:29 -04:00
mike bayer b90f9b5f36 Merge "Restore use_threadlocal equivalent behavior to SingletonThreadPool" 2019-04-03 21:15:07 +00:00
mike bayer e67b4e768b Merge "Fold entities into existing joins when resolving FROM ambiguity" 2019-04-03 14:37:09 +00:00
Mike Bayer a326869cf9 Restore use_threadlocal equivalent behavior to SingletonThreadPool
Fixed behavioral regression as a result of deprecating the "use_threadlocal"
flag for :class:`.Pool`, where the :class:`.SingletonThreadPool` no longer
makes use of this option which causes the "rollback on return" logic to take
place when the same :class:`.Engine` is used multiple times in the context
of a transaction to connect or implicitly execute, thereby cancelling the
transaction.   While this is not the recommended way to work with engines
and connections, it is nonetheless a confusing behavioral change as when
using :class:`.SingletonThreadPool`, the transaction should stay open
regardless of what else is done with the same engine in the same thread.
The ``use_threadlocal`` flag remains deprecated however the
:class:`.SingletonThreadPool` now implements its own version of the same
logic.

Fixes: #4585
Change-Id: I906293f2d0a5d14ed46cd9e64305a6481505a5a3
2019-04-03 10:12:57 -04:00
Mike Bayer 25a42e93f4 Fold entities into existing joins when resolving FROM ambiguity
Fixed 1.3 regression in new "ambiguous FROMs" query logic introduced in
:ref:`change_4365` where a :class:`.Query` that explicitly places an entity
in the FROM clause with :meth:`.Query.select_from` and also joins to it
using :meth:`.Query.join` would later cause an "ambiguous FROM" error if
that entity were used in additional joins, as the entity appears twice in
the "from" list of the :class:`.Query`.  The fix resolves this ambiguity by
folding the standalone entity into the join that it's already a part of in
the same way that ultimately happens when the SELECT statement is rendered.

Fixes: #4584
Change-Id: Ic62ca09c6d329695b21ed4f1be8621edcbb18e19
2019-04-02 23:42:36 -04:00
Mike Bayer df62c54629 Version 1.3.3 placeholder 2019-04-02 13:31:54 -04:00
Mike Bayer 8442a6e2b3 - 1.3.2 rel_1_3_2 2019-04-02 13:11:51 -04:00
Mike Bayer fd2ecb5f87 Remove "subclass existing types" use case
Thanks to :ref:`change_3981`, we no longer need to rely on recipes that
subclass dialect-specific types directly, :class:`.TypeDecorator` can now
handle all cases.   Additionally, the above change made it slightly less
likely that a direct subclass of a base SQLAlchemy type would work as
expected, which could be misleading.  Documentation has been updated to use
:class:`.TypeDecorator` for these examples including the PostgreSQL
"ArrayOfEnum" example datatype and direct support for the "subclass a type
directly" has been removed.

Fixes: #4580
Change-Id: I866f246cccc736ea618dc965ab3604762f7a52fe
2019-03-29 09:46:55 -04:00
mike bayer 9168aae5e7 Merge "Refine ambiguous access for unknown attribute types" 2019-03-27 17:38:02 +00:00
mike bayer 1f6871ef0e Merge "Test double colons without escaping in text()" 2019-03-26 19:34:23 +00:00
Mike Bayer 51f81d00dc Refine ambiguous access for unknown attribute types
Restored instance-level support for plain Python descriptors, e.g.
``@property`` objects, in conjunction with association proxies, in that if
the proxied object is not within ORM scope at all, it gets classified as
"ambiguous" but is proxed directly.  For class level access, a basic class
level``__get__()`` now returns the
:class:`.AmbiguousAssociationProxyInstance` directly, rather than raising
its exception, which is the closest approximation to the previous behavior
that returned the :class:`.AssociationProxy` itself that's possible.  Also
improved the stringification of these objects to be more descriptive of
current state.

Fixes: #4574
Change-Id: I787a22806b5530c146ae6ee66b588e5b191ae689
2019-03-26 15:17:48 -04:00
Mike Bayer c8fca639c9 Test double colons without escaping in text()
Apparently the BIND_PARAMS regex passes over double colons,
it just doesn't accommodate for a bound parameter in that case.
add this use case to current tests as people can be relying upon it.

Change-Id: I6555621b1bb05d09b17428f4b4094ff7b219b460
2019-03-26 13:29:57 -04:00