summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
Commit message (Collapse)AuthorAgeFilesLines
...
| * | implement active_history for compositesMike Bayer2023-03-091-2/+18
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed bug where the "active history" feature was not fully implemented for composite attributes, making it impossible to receive events that included the "old" value. This seems to have been the case with older SQLAlchemy versions as well, where "active_history" would be propagated to the underlying column-based attributes, but an event handler listening to the composite attribute itself would not be given the "old" value being replaced, even if the composite() were set up with active_history=True. Additionally, fixed a regression that's local to 2.0 which disallowed active_history on composite from being assigned to the impl with ``attr.impl.active_history=True``. Fixes: #9460 Change-Id: I6d7752a01c8d3fd78de7a90de10e8c52f9b3cd4e
* | denormalize "public" schema to "PUBLIC"Mike Bayer2023-03-091-17/+45
|/ | | | | | | | | | | | | Fixed reflection bug where Oracle "name normalize" would not work correctly for reflection of symbols that are in the "PUBLIC" schema, such as synonyms, meaning the PUBLIC name could not be indicated as lower case on the Python side for the :paramref:`_schema.Table.schema` argument. Using uppercase "PUBLIC" would work, but would then lead to awkward SQL queries including a quoted ``"PUBLIC"`` name as well as indexing the table under uppercase "PUBLIC", which was inconsistent. Fixes: #9459 Change-Id: I989bd1e794a5b5ac9aae4f4a8702f14c56cd74c2
* Use independent TypeVar for ColumnElement.castMike Bayer2023-03-081-1/+1
| | | | | | | | | | Fixed typing issue where :meth:`.ColumnElement.cast` did not allow a :class:`.TypeEngine` argument independent of the type of the :class:`.ColumnElement` itself, which is the purpose of :meth:`.ColumnElement.cast`. Fixes: #9451 Change-Id: I68119c6a9e8bf896715eea79be2b4f36b1c141de
* update for mypy 1.1.1Mike Bayer2023-03-084-17/+32
| | | | | | | looks like mypy 1.1.1 slipped in after the last jenkins pep484 build for SQLAlchemy. update for its new issues. Change-Id: Ifca967a75d5e592c04b0138aeda9b646067fe59b
* resolve select to NULLTYPE if no columnsMike Bayer2023-03-072-0/+13
| | | | | | | | | | | | | | | | | Fixed regression where the :func:`_sql.select` construct would not be able to render if it were given no columns and then used in the context of an EXISTS, raising an internal exception instead. While an empty "SELECT" is not typically valid SQL, in the context of EXISTS databases such as PostgreSQL allow it, and in any case the condition now no longer raises an internal exception. For this case, also add an extra whitespace trim step for the unusual case that there are no columns to render. This is done in such a way as to not interfere with other test cases that are involving custom compilation schemes. Fixes: #9440 Change-Id: If65ba9ce15d371f09b4342ad0669143b7b082a78
* update sql server use_setinputsizes docs a bitMike Bayer2023-03-061-7/+10
| | | | | | the verbiage here was ambiguous previously. Change-Id: I452ae85bd8b5469d4103970e99cfac752b508274
* Version 2.0.6 placeholderMike Bayer2023-03-051-1/+1
|
* comment out pickle/ process test and attempt 2.0.5.post1Mike Bayer2023-03-051-1/+1
| | | | | | | | | | | | | | if .post1 fails to work out, we'll just do 2.0.6 The test_pickle_rows_other_process test is failing during wheel builds as it seems that the "subprocess" run is not using the cython extensions, leading to a pickle mismatch between the cythonized and the pure python version of a row. comment out this test and attempt to release as 2.0.5.post1 so that wheels can build. Fixes: #9429 Change-Id: I6e1e9f2b9c4ef8fa67a88ff86ebdacbeb02b90df
* Version 2.0.6 placeholderMike Bayer2023-03-051-1/+1
|
* (lots of) changelog updates for 2.0.5Mike Bayer2023-03-051-0/+19
| | | | Change-Id: Iea2ca2cd1eb44b4e9139f2bb6c3d6239f67aeb56
* Merge "KeyFuncDict regression fixes and dataclass fixes" into mainmike bayer2023-03-062-35/+100
|\
| * KeyFuncDict regression fixes and dataclass fixesMike Bayer2023-03-052-35/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | adapt None-key warning for non-mapped attributes Fixed multiple regressions due to :ticket:`8372`, involving :func:`_orm.attribute_mapped_collection` (now called :func:`_orm.attribute_keyed_dict`). First, the collection was no longer usable with "key" attributes that were not themselves ordinary mapped attributes; attributes linked to descriptors and/or association proxy attributes have been fixed. Second, if an event or other operation needed access to the "key" in order to populate the dictionary from an mapped attribute that was not loaded, this also would raise an error inappropriately, rather than trying to load the attribute as was the behavior in 1.4. This is also fixed. For both cases, the behavior of :ticket:`8372` has been expanded. :ticket:`8372` introduced an error that raises when the derived key that would be used as a mapped dictionary key is effectively unassigned. In this change, a warning only is emitted if the effective value of the ".key" attribute is ``None``, where it cannot be unambiguously determined if this ``None`` was intentional or not. ``None`` will be not supported as mapped collection dictionary keys going forward (as it typically refers to NULL which means "unknown"). Setting :paramref:`_orm.attribute_keyed_dict.ignore_unpopulated_attribute` will now cause such ``None`` keys to be ignored as well. Add value constructors to dictionary collections Added constructor arguments to the built-in mapping collection types including :class:`.KeyFuncDict`, :func:`_orm.attribute_keyed_dict`, :func:`_orm.column_keyed_dict` so that these dictionary types may be constructed in place given the data up front; this provides further compatibility with tools such as Python dataclasses ``.asdict()`` which relies upon invoking these classes directly as ordinary dictionary classes. Fixes: #9418 Fixes: #9424 Change-Id: Ib16c4e690b7ac3fcc34df2f139cad61c6c4b2b19
* | Merge "Fixed bug where :meth:`_engine.Row`s could not be unpickled by other ↵mike bayer2023-03-051-6/+17
|\ \ | | | | | | | | | processes." into main
| * | Fixed bug where :meth:`_engine.Row`s could not beFederico Caselli2023-03-041-6/+17
| | | | | | | | | | | | | | | | | | | | | unpickled by other processes. Fixes: #9423 Change-Id: Ie496e31158caff5f72e0a9069dddd55f3116e0b8
* | | Merge "audition pymssql once more; retire sane_rowcount_returning" into mainmike bayer2023-03-059-59/+165
|\ \ \
| * | | audition pymssql once more; retire sane_rowcount_returningMike Bayer2023-03-049-59/+165
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pymssql seems to be maintained again and seems to be working completely, so let's try re-enabling it. Fixed issue in the new :class:`.Uuid` datatype which prevented it from working with the pymssql driver. As pymssql seems to be maintained again, restored testing support for pymssql. Tweaked the pymssql dialect to take better advantage of RETURNING for INSERT statements in order to retrieve last inserted primary key values, in the same way as occurs for the mssql+pyodbc dialect right now. Identified that the ``sqlite`` and ``mssql+pyodbc`` dialects are now compatible with the SQLAlchemy ORM's "versioned rows" feature, since SQLAlchemy now computes rowcount for a RETURNING statement in this specific case by counting the rows returned, rather than relying upon ``cursor.rowcount``. In particular, the ORM versioned rows use case (documented at :ref:`mapper_version_counter`) should now be fully supported with the SQL Server pyodbc dialect. Change-Id: I38a0666587212327aecf8f98e86031ab25d1f14d References: #5321 Fixes: #9414
* | | | Merge "ensure event handlers called for all do_ping" into mainmike bayer2023-03-059-60/+58
|\ \ \ \ | |_|/ / |/| | |
| * | | ensure event handlers called for all do_pingMike Bayer2023-03-049-60/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The support for pool ping listeners to receive exception events via the :meth:`.ConnectionEvents.handle_error` event added in 2.0.0b1 for :ticket:`5648` failed to take into account dialect-specific ping routines such as that of MySQL and PostgreSQL. The dialect feature has been reworked so that all dialects participate within event handling. Additionally, a new boolean element :attr:`.ExceptionContext.is_pre_ping` is added which identifies if this operation is occurring within the pre-ping operation. For this release, third party dialects which implement a custom :meth:`_engine.Dialect.do_ping` method can opt in to the newly improved behavior by having their method no longer catch exceptions or check exceptions for "is_disconnect", instead just propagating all exceptions outwards. Checking the exception for "is_disconnect" is now done by an enclosing method on the default dialect, which ensures that the event hook is invoked for all exception scenarios before testing the exception as a "disconnect" exception. If an existing ``do_ping()`` method continues to catch exceptions and check "is_disconnect", it will continue to work as it did previously, but ``handle_error`` hooks will not have access to the exception if it isn't propagated outwards. Fixes: #5648 Change-Id: I6535d5cb389e1a761aad8c37cfeb332c548b876d
* | | | Merge "restore old *args approach for MutableDict.pop()" into mainmike bayer2023-03-041-30/+35
|\ \ \ \
| * | | | restore old *args approach for MutableDict.pop()Nils Philippsen2023-03-041-30/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The typing change in ba0e508141206efc55cdab91df21c1 changed the semantics of pop() and possibly setdefault() in order to try working at runtime with a two-argument signature. however the implementation for this in cpython likely uses a strict `*args` approach where the lack of the second parameter is explicit, rather than matching to a constant. Restore the old implementation inside of a "not TYPE_CHECKING" block while keeping the type annotated forms intact for typing only. Fixed regression caused by typing added to ``sqlalchemy.ext.mutable`` for :ticket:`8667`, where the semantics of the ``.pop()`` method changed such that the method was non-working. Pull request courtesy Nils Philippsen. Fixes: #9380 Closes: #9381 Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9381 Pull-request-sha: fd903ce1b949d2af26ceb6c2159ad84aab007f3d Change-Id: I213e52f51a795801aacf05307e38cc8c89b54e12
* | | | | Merge "Restore connectivity with ancient sqlite" into mainmike bayer2023-03-041-1/+8
|\ \ \ \ \ | |_|_|_|/ |/| | | |
| * | | | Restore connectivity with ancient sqliteFederico Caselli2023-03-041-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed bug that prevented SQLAlchemy to connect when using a very old sqlite version (before 3.9) on python 3.8+. Fixes: #9379 Change-Id: I10ca347398221c952e1a572dc6ef80e491d1f5cf
* | | | | Merge "TextualSelect is ReturnsRowsRole" into mainmike bayer2023-03-043-14/+41
|\ \ \ \ \
| * | | | | TextualSelect is ReturnsRowsRoleMike Bayer2023-03-023-14/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed typing bug where :meth:`_sql.Select.from_statement` would not accept :func:`_sql.text` or :class:`.TextualSelect` objects as a valid type. Additionally repaired the :class:`.TextClause.columns` method to have a return type, which was missing. Fixes: #9398 Change-Id: I627fc33bf83365e1c7f7c6ed29ea387dfd4a57d8
* | | | | | Merge "Add missing overload to Numeric" into mainmike bayer2023-03-042-7/+27
|\ \ \ \ \ \
| * | | | | | Add missing overload to NumericFederico Caselli2023-03-032-7/+27
| | |_|/ / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added missing init overload to :class:`_sql.Numeric` to allow type checkers to properly resolve the type var given the ``asdecimal`` parameter. this fortunately fixes a glitch in the generate_sql_functions script also Fixes: #9391 Change-Id: I9cecc40c52711489e9dbe663f110c3b81c7285e4
* | | | | | Merge "allow multiparams with scalars" into mainmike bayer2023-03-042-6/+6
|\ \ \ \ \ \
| * | | | | | allow multiparams with scalarsMike Bayer2023-03-012-6/+6
| | |/ / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed bug where the :meth:`_engine.Connection.scalars` method was not typed as allowing a multiple-parameters list, which is now supported using insertmanyvalues operations. Change-Id: I65e22c3bee80fc226d484ff1424421dd78520fa5
* | | | | | Merge "Validate metadata schema arg" into mainmike bayer2023-03-041-0/+5
|\ \ \ \ \ \ | |_|_|_|_|/ |/| | | | |
| * | | | | Validate metadata schema argFederico Caselli2023-03-011-0/+5
| | |/ / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | Validate that when provided the :paramref:`_sql.MetaData.schema` argument of :class:`_sql.MetaData` is a string. Change-Id: I4237232d2ee0f5a4d0b9dbd9af5f5b57abf395b4
* | | | | Fixed issue when copying ExcludeConstraintFederico Caselli2023-03-011-7/+4
| |/ / / |/| | | | | | | | | | | | | | | Fixes: #9401 Change-Id: Ie10192348749567110f53ae618fc724f37d1a6a1
* | | | Merge "Restore export for nullslast/nullfirst" into mainmike bayer2023-03-012-0/+6
|\ \ \ \
| * | | | Restore export for nullslast/nullfirstFederico Caselli2023-02-282-0/+6
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | Previously only the snake case versions nulls_last/nulls_first were exported in the toplevel namespace. Fixes: #9390 Change-Id: I9088e858ae108a5c9106b9d8d82655ad605417cc
* | | | Merge "Improve orm event docs" into mainmike bayer2023-02-282-9/+17
|\ \ \ \ | |_|/ / |/| | |
| * | | Improve orm event docsFederico Caselli2023-02-272-9/+17
| | |/ | |/| | | | | | | Change-Id: Ia4f8ce497565c9d5e8df4ef7cc3c3e645f995ff3
* | | ensure single import per lineMike Bayer2023-02-283-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds the very small plugin flake8-import-single which will prevent us from having an import with more than one symbol on a line. Flake8 by itself prevents this pattern with E401: import collections, os, sys However does not do anything with this: from sqlalchemy import Column, text Both statements have the same issues generating merge artifacts as well as presenting a manual decision to be made. While zimports generally cleans up such imports at the top level, we don't enforce zimports / pre-commit use. the plugin finds the same issue for imports that are inside of test methods. We shouldn't usually have imports in test methods so most of them here are moved to be top level. The version is pinned at 0.1.5; the project seems to have no activity since 2019, however there are three 0.1.6dev releases on pypi which stopped in September 2019, they seem to be experiments with packaging. The source for 0.1.5 is extremely simple and only reveals one method to flake8 (the run() method). Change-Id: Icea894e43bad9c0b5d4feb5f49c6c666d6ea6aa1
* | | Improve exclude constraint docs and tests.Federico Caselli2023-02-271-5/+9
| |/ |/| | | | | | | | | Follow up of 71693c94d52612a5e88128575ff308ee4a923c00 Change-Id: Icc9d9942bda92171581dec82cf0cacbd3e3e4162
* | Merge "Add separate version notes for scalars" into mainmike bayer2023-02-274-4/+14
|\ \
| * | Add separate version notes for scalarsGrey Li2023-02-264-4/+14
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add separate 1.4.24 and 1.4.26 version notes for the .scalars method; this covers Session, scoped_session, AsyncSession, async_scoped_session as the "scoped" versions did not have the method added until 1.4.26 as part of :ticket:`7103`. Also indicate scoped_session as ``sqlalchemy.orm.scoped_session`` in docs rather than ``sqlalchemy.orm.scoping.scoped_session``. This is also happening in I77da54891860095edcb1f0625ead99fee89bd76f separately, as both changesets refer to scoped_session without using ".scoping". References: #7103 Closes: #9371 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9371 Pull-request-sha: 61132230cc6e897ab61beff25d98b19a4c0aefd0 Change-Id: I84c8b1aad752db124cfee6bc8516f6eed7ba2faf
* | Merge "include columns from superclasses that indicate "selectin"" into mainmike bayer2023-02-272-15/+115
|\ \
| * | include columns from superclasses that indicate "selectin"Mike Bayer2023-02-272-15/+115
| |/ | | | | | | | | | | | | | | | | | | | | | | | | Added support for the :paramref:`_orm.Mapper.polymorphic_load` parameter to be applied to each mapper in an inheritance hierarchy more than one level deep, allowing columns to load for all classes in the hierarchy that indicate ``"selectin"`` using a single statement, rather than ignoring elements on those intermediary classes that nonetheless indicate they also would participate in ``"selectin"`` loading and were not part of the base-most SELECT statement. Fixes: #9373 Change-Id: If8dcba0f0191f6c2818ecd15870bccfdf5ce1112
* | Merge "fix with_polymorphic" into mainmike bayer2023-02-272-2/+2
|\ \
| * | fix with_polymorphicMike Bayer2023-02-262-2/+2
| |/ | | | | | | | | | | | | | | Fixed typing issue where :func:`_orm.with_polymorphic` would not record the class type correctly. Fixes: #9340 Change-Id: I535ad9aede9b60475231028adb8dc270e55738a4
* | Merge "Create public QueryPropertyDescriptor type for query_property" into mainmike bayer2023-02-272-6/+22
|\ \
| * | Create public QueryPropertyDescriptor type for query_propertyFederico Caselli2023-02-262-6/+22
| |/ | | | | | | | | | | | | | | | | | | | | Exported the type returned by :meth:`_orm.scoped_session.query_property` using a new public type :class:`.orm.QueryPropertyDescriptor`. Also stated ``scoped_session()`` from ``sqlalchemy.orm`` in the documentation rather than from ``sqlalchemy.orm.scoping``. Fixes: #9338 Change-Id: I77da54891860095edcb1f0625ead99fee89bd76f
* | Merge "Declare KEY_OBJECTS_ONLY as cdef variable" into mainmike bayer2023-02-271-2/+3
|\ \
| * | Declare KEY_OBJECTS_ONLY as cdef variableMatus Valo2023-02-261-2/+3
| |/ | | | | | | | | | | | | | | | | | | | | | | | | A small optimization to the Cython implementation of :class:`.ResultProxy` using a cdef for a particular int value to avoid Python overhead. Pull request courtesy Matus Valo. Fixes: #9343 Closes: #9344 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9344 Pull-request-sha: fc6a97debe45497ef502f3861611b021a5885b63 Change-Id: I231d4fb292decfe9bccdf54f2851ce6f69d5d6c7
* | Merge "apply a fixed locals w/ Mapped to all de-stringify" into mainmike bayer2023-02-275-13/+95
|\ \
| * | apply a fixed locals w/ Mapped to all de-stringifyMike Bayer2023-02-265-13/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Continued the fix for :ticket:`8853`, allowing the :class:`_orm.Mapped` name to be fully qualified regardless of whether or not ``from __annotations__ import future`` were present. This issue first fixed in 2.0.0b3 confirmed that this case worked via the test suite, however the test suite apparently was not testing the behavior for the name ``Mapped`` not being locally present at all; string resolution has been updated to ensure the ``Mapped`` symbol is locatable as applies to how the ORM uses these functions. Fixes: #8853 Fixes: #9335 Change-Id: Id82d09aee906165a4d77c7da6a0b4177dd675c10
* | | Merge "use read-only Mapping for values dictionary type" into mainmike bayer2023-02-272-1/+6
|\ \ \