Commit Graph

14201 Commits

Author SHA1 Message Date
Federico Caselli 85fa3473be Documentation improvements
Also remove deprecated usage:
- load_only does not accept strings
- case.whens is positional only

Ref #6712
Ref #5994
Ref #6121
Ref #6785
Ref https://groups.google.com/g/sqlalchemy/c/-cnhThEu3kk

Change-Id: I5db49a075b9d3d332518b9d189a24b13b502e2af
2021-07-20 14:04:48 -04:00
mike bayer ca52e87268 Merge "Add additional support to honor _proxy_key in Core selects" 2021-07-09 21:29:40 +00:00
Federico Caselli a457e555e0 add python 2.7 to pr workflow to help catch py3 only issues
Change-Id: If26b3c2ca84636859adc7623ec912f9e44cbbc3c
2021-07-08 23:28:49 +02:00
Chris 990069b2e8 Docs: fixed typo in "Cascades" 2021-07-07 03:12:00 +02:00
Mike Bayer 4e1b2ee4cb Add additional support to honor _proxy_key in Core selects
Fixed ORM regression where ad-hoc label names generated for hybrid
properties and potentially other similar types of ORM-enabled expressions
would usually be propagated outwards through subqueries, allowing the name
to be retained in the final keys of the result set even when selecting from
subqueries. Additional state is now tracked in this case that isn't lost
when a hybrid is selected out of a Core select / subquery.

as we have removed things like column.label() from
ORM, since we now have to export the cols with the same names
as what we will render, experiment with giving a greater role
to the _proxy_key annotation so that a desired name can be
carried through more transarently.

Fixes: #6718
Change-Id: Icb313244c13ea1a8f58d3e05d07aa3e1039e15bf
2021-07-05 15:57:55 -04:00
Federico Caselli fb81f9c8d9 Replace all http:// links to https://
Also replace http://pypi.python.org/pypi with https://pypi.org/project

Change-Id: I84b5005c39969a82140706472989f2a30b0c7685
2021-07-04 20:54:33 +02:00
Gord Thompson b920869ef5 Modernize tests
Eliminate engine.execute() and engine.scalar()

Change-Id: I99f76d0e615ddebab2da4fd07a40a0a2796995c7
2021-07-03 18:50:03 -04:00
mike bayer cb9f6f83b2 Merge "Update docs re: deprecated internal dialects" 2021-07-03 21:56:09 +00:00
mike bayer e9a3b15665 Merge "Update link for mysql case sensitivity" 2021-07-03 21:55:27 +00:00
Gord Thompson 20f485f91b Update link for mysql case sensitivity
Change-Id: Ia4ff3e86d944bd5cfaa0ae2086b1d20fa027ba14
2021-07-03 17:54:31 -04:00
mike bayer 7ec1cf2086 Merge "Modernize tests - Connection.connect" 2021-07-03 21:53:18 +00:00
Federico Caselli a05b526a8d Add Result to the link description in the docs index
Change-Id: Ic6d9e1c92e1f7a4bbfe4446ac063d033e8b0089c
2021-07-01 23:16:24 +02:00
Mike Bayer 7ed6aee275 clear new Query._memoized_select_entities in _from_selectable
Fixed regression caused in 1.4.19 due to #6503 and related involving
:meth:`_orm.Query.with_entities` where the new structure used would be
inappropriately transferred to an enclosing :class:`_orm.Query` when making
use of set operations such as :meth:`_orm.Query.union`, causing the JOIN
instructions within to be applied to the outside query as well.

Fixes: #6698
Change-Id: Ia9f294215ebc01330d142a0a3e5be9d02be9380f
2021-06-30 16:05:34 -04:00
Mike Bayer b01a415a6d Ensure compiler uses quote_schema hook for translates renders
Fixed regression where the special dotted-schema name handling for the SQL
Server dialect would not function correctly if the dotted schema name were
used within the ``schema_translate_map`` feature.

Fixes: #6697
Change-Id: Idb610755cbf8122e71223d5dd0a17fcb61b1b98d
2021-06-30 10:52:09 -04:00
Mike Bayer dee5747788 apply quoting to "ON CONSTRAINT" symbol
Fixed issue in :meth:`_postgresql.Insert.on_conflict_do_nothing` and
:meth:`_postgresql.Insert.on_conflict_do_update` where the name of a unique
constraint passed as the ``constraint`` parameter would not be properly
quoted if it contained characters which required quoting.

Fixes: #6696
Change-Id: I4ffca9b8c72cef4ed39e2de96831ccc11a620422
2021-06-30 09:23:02 -04:00
Mike Bayer 67edf8e376 rewrite "one-to-one", again
Use the term "collection" instead of "many" as the
"side" where "uselist=False" goes.  Clarify that
one-to-one is in many ways a convention.

Fixes: #6692
Change-Id: I2bc7b24c9f57747306fdcf4b6376ac7eb3bff78b
2021-06-29 19:48:45 -04:00
Gord Thompson c92b59e45a Update docs re: deprecated internal dialects
Change-Id: I3d9432a03e133af312595cf0883ce81b05043665
2021-06-29 14:22:42 -06:00
Mike Bayer 69604f5c31 Version 1.4.21 placeholder 2021-06-28 16:36:16 -04:00
Mike Bayer e3ce7ee2ee - 1.4.20 rel_1_4_20 2021-06-28 16:29:28 -04:00
Mike Bayer f7f1d565cc changelog typo fixes
Change-Id: I66e16cf1a2321f9706a602e7683f767d37163010
2021-06-28 16:28:37 -04:00
Miłosz Stypiński 5933a5dc2e Be less fiscal regarding validators functions
Adjusted the check in the mapper for a callable object that is used as a
``@validates`` validator function or a ``@reconstructor`` reconstruction
function, to check for "callable" more liberally such as to accommodate
objects based on fundamental attributes like ``__func__`` and
``__call___``, rather than testing for ``MethodType`` / ``FunctionType``,
allowing things like cython functions to work properly. Pull request
courtesy Miłosz Stypiński.

Fixes: #6538
Closes: #6539
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6539
Pull-request-sha: ed1d7fe5c9

Change-Id: I8350558bc9a9ba58f43e48e12ce25a0b30e4d767
2021-06-28 11:34:00 -04:00
mike bayer b02087666e Merge "Fix missing None handling of Table.prefixes" 2021-06-28 15:06:57 +00:00
Kai Mueller 7e5e40ff84 Fix missing None handling of Table.prefixes
Fixed issue where passing ``None`` for the value of
:paramref:`_schema.Table.prefixes` would not store an empty list, but
rather the constant ``None``, which may be unexpected by third party
dialects. The issue is revealed by a usage in recent versions of Alembic
that are passing ``None`` for this value. Pull request courtesy Kai
Mueller.

Fixes: #6685
Closes: #6672
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6672
Pull-request-sha: b79aca0ee4

Change-Id: I758641c6fbde6f2607d074fecea7efa6728aeea0
2021-06-28 10:26:01 -04:00
Daniël van Eeden 919763b43c Don't require space after MySQL pk comment
Made a small adjustment in the table reflection feature of the MySQL
dialect to accommodate for alternate MySQL-oriented databases such as TiDB
which include their own "comment" directives at the end of a constraint
directive within "CREATE TABLE" where the format doesn't have the
additional space character after the comment, in this case the TiDB
"clustered index" feature. Pull request courtesy Daniël van Eeden.

Fixes: #6659
Closes: #6660
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6660
Pull-request-sha: 98791a441b

Change-Id: I20d206e0cdb809e4c6997b87159edf41249f7cd9
2021-06-28 09:39:59 -04:00
mike bayer 2f909a6b12 Merge "ensure with poly entities are also reconstituted for GC'ed AC" 2021-06-26 23:03:00 +00:00
Gord Thompson 0e91400f1b Modernize tests - Connection.connect
Change-Id: I61639dc2d7e7bcae6c53e2a15680b11fce3efa5d
2021-06-26 16:10:57 -06:00
Mike Bayer 4e7438e0ac ensure with poly entities are also reconstituted for GC'ed AC
Fixed regression in ORM regarding an internal reconstitution step for the
func:`_orm.with_polymorphic` construct, when the user-facing object is
garbage collected as the query is processed. The reconstitution was not
ensuring the sub-entities for the "polymorphic" case were handled, leading
to an ``AttributeError``.

Fixes: #6680
Change-Id: Id35b16d0f2aadb50b5a7385a21fa81b9d8a8325f
2021-06-26 16:41:31 -04:00
Mike Bayer 77e58046dc set _render_for_subquery for legacy set ops
Adjusted :meth:`_orm.Query.union` and similar set operations to be
correctly compatible with the new capabilities just added in
🎫`6661`, with SQLAlchemy 1.4.19, such that the SELECT statements
rendered as elements of the UNION or other set operation will include
directly mapped columns that are mapped as deferred; this both fixes a
regression involving unions with multiple levels of nesting that would
produce a column mismatch, and also allows the :func:`_orm.undefer` option
to be used at the top level of such a :class:`_orm.Query` without having to
apply the option to each of the elements within the UNION.

Fixes: #6678
Change-Id: Iba97ce7fd8a965499853256fd2eb7f61512db60f
2021-06-26 19:08:04 +00:00
mike bayer 84a68ac882 Merge "turn pg provision error into a warning" 2021-06-26 19:07:42 +00:00
Mike Bayer 3d6130d8e9 turn pg provision error into a warning
We haven't had any real cases of the PG "cant drop tables"
condition since this error was first introduced; instead we
seem to get it for a non-critical query during pool reconnect
tests, and I have not been able to isolate what is causing it.
Therefore turn the error into a new class of warning that can
emit within the test suite without failing the test, so that
if we do get a real PG drop timeout, the warning will be there
to show us what the query was in which it was stuck.

Change-Id: I1a9b3c4f7a25b7b9c1af722a721fc44ad5575b0f
2021-06-26 09:55:00 -04:00
Mike Bayer 65e16e9b3e have automap suppress overlaps warning for mapped secondary
Fixed regression in :mod:`sqlalchemy.ext.automap` extension such that the
use case of creating an explicit mapped class to a table that is also the
:paramref:`_orm.relationship.secondary` element of a
:func:`_orm.relationship` that automap will be generating would emit the
"overlaps" warnings introduced in 1.4 and discussed at :ref:`error_qzyx`.
While generating this case from automap is still subject to the same
caveats that the "overlaps" warning refers towards, as automap is intended
for more ad-hoc use cases, the condition which produces the warning is
disabled when a many-to-many relationship with this particular pattern is
generated.

Fixes: #6679
Change-Id: Ib3a53982b076ed4999b0d3235f84008b9e2f1cce
2021-06-25 16:53:01 -04:00
jason3gb 791f1d9407 Add "impl" parameter to PickleType
Add a impl parameter to :class:`_types.PickleType` constructor, allowing
any arbitary type to be used in place of the default implementation of
:class:`_types.LargeBinary`. Pull request courtesy jason3gb.

Fixes: #6646
Closes: #6657
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6657
Pull-request-sha: e49bcd368d

Change-Id: Ib79f3b0ebbc94393f673f5a5ba6558260083d0cf
2021-06-24 12:22:20 -04:00
mike bayer fb141d9d5e Merge "Fix typo in _warn_for_legacy_exec_format" 2021-06-24 16:08:33 +00:00
mike bayer b0b2aa6ab3 Merge "Use Py_TPFLAGS_HAVE_GC for Row" 2021-06-24 15:11:26 +00:00
gordthompson 34163dfd1c Fix typo in _warn_for_legacy_exec_format
Change-Id: Idc24b5ab4b5a25fcfb7115c5d7be4c2ece520674
2021-06-24 07:44:21 -06:00
mike bayer 1b05f0d208 Merge "Add Executable to DefaultGenerator" 2021-06-24 13:17:15 +00:00
Mike Bayer 421d5ec0be Use Py_TPFLAGS_HAVE_GC for Row
Fixed an issue in the C extension for the :class:`_result.Row` class which
could lead to a memory leak in the unlikely case of a :class:`_result.Row`
object which referred to an ORM object that then was mutated to refer back
to the ``Row`` itself, creating a cycle. The Python C APIs for tracking GC
cycles has been added to the native :class:`_result.Row` implementation to
accommodate for this case.

Fixes: #5348
Change-Id: I3ac32012f29fbb59f8921cf2a124fa3a7ac5f0d1
2021-06-24 09:12:31 -04:00
Mike Bayer 80b90cbcfe Add Executable to DefaultGenerator
Fixed the class hierarchy for the :class:`_schema.Sequence` and the more
general :class:`_schema.DefaultGenerator` base, as these are "executable"
as statements they need to include :class:`_sql.Executable` in their
hierarchy, not just :class:`_roles.StatementRole` as was applied
arbitrarily to :class:`_schema.Sequence` previously. The fix allows
:class:`_schema.Sequence` to work in all ``.execute()`` methods including
with :meth:`_orm.Session.execute` which was not working in the case that a
``do_orm_execute()`` handler was also established.

Fixes: #6668
Change-Id: I0d192258c7cbd1bce2552f9e748e8fdd680dc45f
2021-06-23 16:42:33 -04:00
mike bayer b2b23b00b7 Merge "consider "*" col as textual ordered" 2021-06-23 18:08:56 +00:00
Mike Bayer cdd041ea60 consider "*" col as textual ordered
Fixed old issue where a :func:`_sql.select()` made against the token "*",
which then yielded exactly one column, would fail to correctly organize the
``cursor.description`` column name into the keys of the result object.

Fixes: #6665
Change-Id: Ie8c00f62998972ad4a19a750d2642d00fde006f6
2021-06-23 09:49:11 -04:00
Mike Bayer 268eda3e6e Version 1.4.20 placeholder 2021-06-22 21:30:40 -04:00
Mike Bayer acbc5e8241 - 1.4.19 rel_1_4_19 2021-06-22 21:22:33 -04:00
Mike Bayer 2f875a4b79 refer to undefer here
this is the option one might want to use to undefer
a deferred column into a subquery; the message here explains
that is not applicable in 1.4.

Change-Id: Iea6c48f69c540e11ff5c3f6c8c56cc5cf2bf257b
2021-06-22 21:21:16 -04:00
mike bayer fecb36d1e8 Merge "apply render_schema_translates to identity insert directives" 2021-06-23 01:02:48 +00:00
mike bayer 2af9d08f6b Merge "Add impl property to PostgreSQL / Oracle INTERVAL class" 2021-06-22 22:49:52 +00:00
mike bayer 7110a5fa86 Merge "Export deferred columns but not col props; fix CTE labeling" 2021-06-22 22:05:35 +00:00
MajorDallas ac20c3d34b Add impl property to PostgreSQL / Oracle INTERVAL class
Fixed issue where the ``INTERVAL`` datatype on PostgreSQL and Oracle would
produce an ``AttributeError`` when used in the context of a comparison
operation against a ``timedelta()`` object. Pull request courtesy
MajorDallas.

Fixes: #6649
Closes: #6650
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6650
Pull-request-sha: dd217a975e

Change-Id: I773caf2673294fdb3c92b42895ad714e944d1bf8
2021-06-22 18:01:33 -04:00
Mike Bayer 2cf8c5868c Export deferred columns but not col props; fix CTE labeling
Refined the behavior of ORM subquery rendering with regards to deferred
columns and column properties to be more compatible with that of 1.3 while
also providing for 1.4's newer features. As a subquery in 1.4 does not make
use of loader options, including :func:`_orm.deferred`, a subquery that is
against an ORM entity with deferred attributes will now render those
deferred attributes that refer directly to mapped table columns, as these
are needed in the outer SELECT if that outer SELECT makes use of these
columns; however a deferred attribute that refers to a composed SQL
expression as we normally do with :func:`_orm.column_property` will not be
part of the subquery, as these can be selected explicitly if needed in the
subquery. If the entity is being SELECTed from this subquery, the column
expression can still render on "the outside" in terms of the derived
subquery columns. This produces essentially the same behavior as when
working with 1.3. However in this case the fix has to also make sure that
the ``.selected_columns`` collection of an ORM-enabled :func:`_sql.select`
also follows these rules, which in particular allows recursive CTEs to
render correctly in this scenario, which were previously failing to render
correctly due to this issue.

As part of this change the _exported_columns_iterator() method has been
removed and logic simplified to use ._all_selected_columns from any
SelectBase object where _exported_columns_iterator() was used before.
Additionally sets up UpdateBase to include ReturnsRows in its hierarchy;
the literal point of ReturnsRows was to be a common base for UpdateBase
and SelectBase so it was kind of weird it wasn't there.

Fixes: #6661

Fixed issue in CTE constructs mostly relevant to ORM use cases where a
recursive CTE against "anonymous" labels such as those seen in ORM
``column_property()`` mappings would render in the
``WITH RECURSIVE xyz(...)`` section as their raw internal label and not a
cleanly anonymized name.

Fixes: #6663
Change-Id: I26219d4d8e6c0915b641426e9885540f74fae4d2
2021-06-22 17:25:37 -04:00
Federico Caselli a84881e1b7 Improve regexp used by pymssql to parse db version
Made improvements to the server version regexp used by the pymssql
dialect to prevent a regexp overflow in case of an invalid version
string.

Fixes: #5557
Change-Id: Ia3e95a9f11f5a121d84474c97f6b122cf8d9c9cf
2021-06-21 22:31:01 +00:00
mike bayer 2f100a7d4b Merge "Implement MySQL-specific MATCH" 2021-06-21 22:30:31 +00:00