Commit Graph

3552 Commits

Author SHA1 Message Date
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 7a80f64503 Merge "Reimplement .compare() in terms of a visitor" 2019-04-29 18:52:03 +00: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 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 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
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 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 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
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 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 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 47ee0e2e0f Merge "Fix boolean check in new path comparison logic" 2019-03-25 19:09:58 +00:00
Mike Bayer da04aa577b Fix boolean check in new path comparison logic
Fixed regression where a new error message that was supposed to raise when
attempting to link a relationship option to an AliasedClass without using
:meth:`.PropComparator.of_type` would instead raise an ``AttributeError``.
Note that in 1.3, it is no longer valid to create an option path from a
plain mapper relationship to an :class:`.AliasedClass` without using
:meth:`.PropComparator.of_type`.

Fixes: #4566
Change-Id: Ic547a1c8408e41aec66ef9644aac7f76f50dd064
2019-03-24 12:35:53 -04:00
Julian Mehnle a31da95e00 Support DNS-less connections for psycopg2
Added support for parameter-less connection URLs for the psycopg2 dialect,
meaning, the URL can be passed to :func:`.create_engine` as
``"postgresql+psycopg2://"`` with no additional arguments to indicate an
empty DSN passed to libpq, which indicates to connect to "localhost" with
no username, password, or database given. Pull request courtesy Julian
Mehnle.

Fixes: #4562
Closes: #4563
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4563
Pull-request-sha: 8a05c96944

Change-Id: Ib6fca3c3c9eebeaf590d7f7fb0bc8cd4b6e4a55a
2019-03-24 12:03:28 -04:00
raylu 8acbc2624f Expand joins when calculating PostgreSQL "WITH FOR UPDATE OF"
Modified the :paramref:`.Select.with_for_update.of` parameter so that if a
join or other composed selectable is passed, the individual :class:`.Table`
objects will be filtered from it, allowing one to pass a join() object to
the parameter, as occurs normally when using joined table inheritance with
the ORM.  Pull request courtesy Raymond Lu.

Fixes: #4550
Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Closes: #4551
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4551
Pull-request-sha: 452da77d15

Change-Id: If4b7c231f7b71190d7245543959fb5c3351125a1
2019-03-21 10:25:29 -04:00
mike bayer 4aadcca993 Merge "Clone internals for Select._correlate_except collection as well as _correlate" 2019-03-11 14:49:23 +00:00
Mike Bayer 25fc9562f0 Clone internals for Select._correlate_except collection as well as _correlate
Fixed bug where use of :func:`.with_polymorphic` or other aliased construct
would not properly adapt when the aliased target were used as the
:meth:`.Select.correlate_except` target of a subquery used inside of a
:func:`.column_property`.  This required a fix to the clause adaption
mechanics to properly handle a selectable that shows up in the "correlate
except" list, in a similar manner as which occurs for selectables that show
up in the "correlate" list.  This is ultimately a fairly fundamental bug
that has lasted for a long time but it is hard to come across it.

Fixes: #4537
Change-Id: Ibb97d4eea18b3c452aad519dd14919bfb84d422f
2019-03-10 23:44:08 -04:00
Mike Bayer 16411cd8d6 Version 1.3.2 placeholder 2019-03-09 14:38:14 -05:00
Mike Bayer f7d2556cd3 - 1.3.1 2019-03-09 14:32:32 -05:00
Mike Bayer cbc31716c2 Commit transaction after SNAPSHOT isolation change
A commit() is emitted after an isolation level change to SNAPSHOT, as both
pyodbc and pymssql open an implicit transaction which blocks subsequent SQL
from being emitted in the current transaction.

Fixes: #4536
Change-Id: If3ba70f495bce2a35a873a3a72d1b30406e678c8
2019-03-08 23:45:25 -05:00
Mike Bayer e6d0963040 Add documentation section for cascade_scalar_deletes
Change-Id: I56825652e0608862472bc594fc6c2b12ed5cc16f
References: #4534
2019-03-07 09:54:45 -05:00
mike bayer 2160b7e652 Merge "Ensure association proxy works over synonym" 2019-03-06 16:38:49 +00:00
mike bayer db212bcf49 Merge "Fix large_resultsets performance example field name" 2019-03-06 16:11:36 +00:00