summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* | [asyncpg] Extract rowcount for SELECT statementsMichael Gorven2023-01-041-1/+1
|/ | | | | | | | | | | | | | Added support to the asyncpg dialect to return the ``cursor.rowcount`` value for SELECT statements when available. While this is not a typical use for ``cursor.rowcount``, the other PostgreSQL dialects generally provide this value. Pull request courtesy Michael Gorven. Fixes: #9048 Closes: #9049 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9049 Pull-request-sha: df16160530c6001d99de059995ad5047a75fb7b0 Change-Id: I095b866779ccea7e4d50bc841fef7605e61c667f
* tutorial updates re: Core /ORM commonalityMike Bayer2023-01-031-3/+2
| | | | | | | | | | | updates for Insert / bulk insert, executemanyvalues, as well as beginning to describe Table / declared class more closely together, mentioning typing support. Fixed a long-standing issue where sphinx would complain about the Insert symbol being ambiguous. Change-Id: Id4cc09b9581e8fa39c9c00bc8f229636e626e9bc
* happy new year 2023Mike Bayer2023-01-03205-205/+205
| | | | Change-Id: I625af65b3fb1815b1af17dc2ef47dd697fdc3fb1
* link to with_variant() narrative from API docMike Bayer2023-01-031-0/+5
| | | | Change-Id: I5d8e4d7cb7871bedebe0fe89758be441e64b94c6
* Version 2.0.0rc2 placeholderMike Bayer2022-12-281-1/+1
|
* Merge "ensure whereclause, returning copied as tuples" into mainmike bayer2022-12-281-7/+7
|\
| * ensure whereclause, returning copied as tuplesMike Bayer2022-12-281-7/+7
| | | | | | | | | | | | | | | | | | | | Fixed issue in the internal SQL traversal for DML statements like :class:`_dml.Update` and :class:`_dml.Delete` which would cause among other potential issues, a specific issue using lambda statements with the ORM update/delete feature. Fixes: #9033 Change-Id: I76428049cb767ba302fbea89555114bf63ab8687
* | Type annotations for sqlalchemy.orm.eventsGleb Kisenkov2022-12-281-144/+352
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | <!-- Provide a general summary of your proposed changes in the Title field above --> ### Description An attempt to annotate `lib/sqlalchemy/orm/events.py` with type hints (issue #6810). ### 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 - [ ] 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. - [x] 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. **Have a nice day!** Closes: #9025 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9025 Pull-request-sha: a3fd2c0c3790164c433305ccc7ac6b73e813e037 Change-Id: I0808b6485504615fa20691dc8f4631d38bc89ab3
* Merge "rename 2.0.0b5 to 2.0.0rc1" into mainmike bayer2022-12-287-16/+16
|\
| * rename 2.0.0b5 to 2.0.0rc1Mike Bayer2022-12-277-16/+16
| | | | | | | | | | | | it's hoped for 2.0.0 final to be next, in early January Change-Id: If4285f0929f4a2895f2bc93d9e8336599b973bcf
* | Merge "remove errant NO_KEY symbol" into mainmike bayer2022-12-282-8/+10
|\ \ | |/ |/|
| * remove errant NO_KEY symbolMike Bayer2022-12-272-8/+10
| | | | | | | | | | | | | | | | | | | | the symbol from base is used in the event API and is passed along from attributes here. for the additional use where it's an exception case for attribute name as passed by hybrid, use a different symbol name. Change-Id: I8c5c0e71d19185ebec64f2fcbfe1e9be74e54287
* | establish explicit join transaction modesMike Bayer2022-12-271-16/+133
|/ | | | | | | | | | | | | | | | | | | | | | | | The behavior of "joining an external transaction into a Session" has been revised and improved, allowing explicit control over how the :class:`_orm.Session` will accommodate an incoming :class:`_engine.Connection` that already has a transaction and possibly a savepoint already established. The new parameter :paramref:`_orm.Session.join_transaction_mode` includes a series of option values which can accommodate the existing transaction in several ways, most importantly allowing a :class:`_orm.Session` to operate in a fully transactional style using savepoints exclusively, while leaving the externally initiated transaction non-committed and active under all circumstances, allowing test suites to rollback all changes that take place within tests. Additionally, revised the :meth:`_orm.Session.close` method to fully close out savepoints that may still be present, which also allows the "external transaction" recipe to proceed without warnings if the :class:`_orm.Session` did not explicitly end its own SAVEPOINT transactions. Fixes: #9015 Change-Id: I31c22ee0fd9372fa0eddfe057e76544aee627107
* Merge "pass more contextual information to PyWrapper param create" into mainmike bayer2022-12-272-7/+17
|\
| * pass more contextual information to PyWrapper param createMike Bayer2022-12-272-7/+17
| | | | | | | | | | | | | | | | | | | | Fixed issue in lambda SQL feature where the calculated type of a literal value would not take into account the type coercion rules of the "compared to type", leading to a lack of typing information for SQL expressions, such as comparisons to :class:`.JSON` elements and similar. Fixes: #9029 Change-Id: I381c8d7458d98ba762313dee9ec47a9c1881f74a
* | dont prefix ssl args with "ssl" in the ssl dictMike Bayer2022-12-271-3/+3
|/ | | | | Fixes: #9031 Change-Id: I9ef077e7da5b2328a345f6526a6210ce82d807f6
* Merge "reorganize pre_session_exec around do_orm_execute" into mainmike bayer2022-12-266-157/+216
|\
| * reorganize pre_session_exec around do_orm_executeMike Bayer2022-12-266-157/+216
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow do_orm_execute() events to both receive the complete state of bind_argments, load_options, update_delete_options as they do already, but also allow them to *change* all those things via new execution options. Options like autoflush, populate_existing etc. can now be updated within a do_orm_execute() hook and those changes will take effect all the way through. Took a few tries to get something that covers every case here, in particular horizontal sharding which is consuming those options as well as using context.invoke(), without excess complexity. The good news seems to be that a simple reorg and replacing the "reentrant" boolean with "is this before do_orm_execute is invoked" was all that was needed. As part of this we add a new "identity_token" option allowing this option to be controlled from do_orm_execute() as well as from the outside. WIP Fixes: #7837 Change-Id: I087728215edec8d1b1712322ab389e3f52ff76ba
* | Merge "expand out Index if passed to "constraint"" into mainmike bayer2022-12-231-1/+1
|\ \
| * | expand out Index if passed to "constraint"Mike Bayer2022-12-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed bug where the PostgreSQL :paramref:`_postgresql.OnConflictClause.constraint` parameter would accept an :class:`.Index` object, however would not expand this index out into its individual index expressions, instead rendering its name in an ON CONFLICT ON CONSTRAINT clause, which is not accepted by PostgreSQL; the "constraint name" form only accepts unique or exclude constraint names. The parameter continues to accept the index but now expands it out into its component expressions for the render. Fixes: #9023 Change-Id: I6baf243e26bfe578bf3f193c162dd7a623b6ede9
* | | improve async_sessionmaker docsMike Bayer2022-12-231-7/+20
|/ / | | | | | | | | | | | | | | | | * illustrate patterns where the async_sessionmaker is being reused. if you are not reusing it, there is no point to making it * fix reference to async_sessionmaker * add typing Change-Id: I22a260132b6e06574b5fe37af554829e38163de6
* | check for adapt to same class in AbstractRangeMike Bayer2022-12-211-1/+1
| | | | | | | | | | | | | | | | | | Fixed regression where newly revised PostgreSQL range types such as :class:`_postgresql.INT4RANGE` could not be set up as the impl of a :class:`.TypeDecorator` custom type, instead raising a ``TypeError``. Fixes: #9020 Change-Id: Ib881c3c7f63d000f49a09185a8663659a9970aa9
* | Merge "add joins_implicitly to column_valued()" into mainmike bayer2022-12-201-2/+12
|\ \
| * | add joins_implicitly to column_valued()Mike Bayer2022-12-201-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added parameter :paramref:`.FunctionElement.column_valued.joins_implicitly`, which is useful in preventing the "cartesian product" warning when making use of table-valued or column-valued functions. This parameter was already introduced for :meth:`.FunctionElement.table_valued` in :ticket:`7845`, however it failed to be added for :meth:`.FunctionElement.column_valued` as well. Fixes: #9009 Change-Id: Ifb72fbcb4f4d2998e730d6f85ec7280df3bf3d47
* | | Merge "Add MACCADDR8 for PGCompiler" into mainmike bayer2022-12-203-0/+16
|\ \ \
| * | | Add MACCADDR8 for PGCompilerasimfarooq52022-12-193-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add MACCADDR8 for PGCompiler Closes: #8393 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8393 Pull-request-sha: 837a68eba3e31e0acbb7c47ee87bca4e9def7648 Change-Id: I87e4999eb8d82662ff8ab409c98dc57edd7fd271
* | | | Merge "remove __allow_unmapped__ requirement from dataclasses" into mainmike bayer2022-12-191-1/+1
|\ \ \ \ | |_|/ / |/| | |
| * | | remove __allow_unmapped__ requirement from dataclassesMike Bayer2022-12-191-1/+1
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Removed the requirement that the ``__allow_unmapped__`` attribute be used on Declarative Dataclass Mapped class when non-``Mapped[]`` annotations are detected; previously, an error message that was intended to support legacy ORM typed mappings would be raised, which additionally did not mention correct patterns to use with Dataclasses specifically. This error message is now no longer raised if :meth:`_orm.registry.mapped_as_dataclass` or :class:`_orm.MappedAsDataclass` is used. Fixes: #8973 Change-Id: I887afcc2da83dd904444bcb97f31e695b9f8b443
* | | add exclusion for unusual chars in column namesMike Bayer2022-12-192-0/+12
|/ / | | | | | | | | | | | | | | | | | | | | | | Added new exclusion rule for third party dialects called ``unusual_column_name_characters``, which can be "closed" for third party dialects that don't support column names with unusual characters such as dots, slashes, or percent signs in them, even if the name is properly quoted. Fixes: #9002 Change-Id: I44b765df4c73ce5ec1907d031fd9c89761fd99d1 References: #8993
* | Merge "include pk cols in refresh() if relationships are requested" into mainmike bayer2022-12-184-55/+134
|\ \
| * | include pk cols in refresh() if relationships are requestedMike Bayer2022-12-184-55/+134
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A series of changes and improvements regarding :meth:`_orm.Session.refresh`. The overall change is that primary key attributes for an object are now included in a refresh operation unconditionally when relationship-bound attributes are to be refreshed, even if not expired and even if not specified in the refresh. * Improved :meth:`_orm.Session.refresh` so that if autoflush is enabled (as is the default for :class:`_orm.Session`), the autoflush takes place at an earlier part of the refresh process so that pending primary key changes are applied without errors being raised. Previously, this autoflush took place too late in the process and the SELECT statement would not use the correct key to locate the row and an :class:`.InvalidRequestError` would be raised. * When the above condition is present, that is, unflushed primary key changes are present on the object, but autoflush is not enabled, the refresh() method now explicitly disallows the operation to proceed, and an informative :class:`.InvalidRequestError` is raised asking that the pending primary key changes be flushed first. Previously, this use case was simply broken and :class:`.InvalidRequestError` would be raised anyway. This restriction is so that it's safe for the primary key attributes to be refreshed, as is necessary for the case of being able to refresh the object with relationship-bound secondary eagerloaders also being emitted. This rule applies in all cases to keep API behavior consistent regardless of whether or not the PK cols are actually needed in the refresh, as it is unusual to be refreshing some attributes on an object while keeping other attributes "pending" in any case. * The :meth:`_orm.Session.refresh` method has been enhanced such that attributes which are :func:`_orm.relationship`-bound and linked to an eager loader, either at mapping time or via last-used loader options, will be refreshed in all cases even when a list of attributes is passed that does not include any columns on the parent row. This builds upon the feature first implemented for non-column attributes as part of :ticket:`1763` fixed in 1.4 allowing eagerly-loaded relationship-bound attributes to participate in the :meth:`_orm.Session.refresh` operation. If the refresh operation does not indicate any columns on the parent row to be refreshed, the primary key columns will nonetheless be included in the refresh operation, which allows the load to proceed into the secondary relationship loaders indicated as it does normally. Previously an :class:`.InvalidRequestError` error would be raised for this condition (:ticket:`8703`) * Fixed issue where an unnecessary additional SELECT would be emitted in the case where :meth:`_orm.Session.refresh` were called with a combination of expired attributes, as well as an eager loader such as :func:`_orm.selectinload` that emits a "secondary" query, if the primary key attributes were also in an expired state. As the primary key attributes are now included in the refresh automatically, there is no additional load for these attributes when a relationship loader goes to select for them (:ticket:`8997`) * Fixed regression caused by :ticket:`8126` released in 2.0.0b1 where the :meth:`_orm.Session.refresh` method would fail with an ``AttributeError``, if passed both an expired column name as well as the name of a relationship-bound attribute that was linked to a "secondary" eagerloader such as the :func:`_orm.selectinload` eager loader (:ticket:`8996`) Fixes: #8703 Fixes: #8996 Fixes: #8997 Fixes: #8126 Change-Id: I88dcbc0a9a8337f6af0bc4bcc5b0261819acd1c4
* | | Merge "dont call platform.architecture()" into mainmike bayer2022-12-181-1/+1
|\ \ \
| * | | dont call platform.architecture()Mike Bayer2022-12-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed regression where the base compat module was calling upon ``platform.architecture()`` in order to detect some system properties, which results in an over-broad system call against the system-level ``file`` call that is unavailable under some circumstances, including within some secure environment configurations. Fixes: #8995 Change-Id: Ib6171e75aff5a60a79dab81a0be21bee2456318b
* | | | Merge "ensure all visit methods accept **kw" into mainmike bayer2022-12-177-48/+99
|\ \ \ \ | |_|/ / |/| | |
| * | | ensure all visit methods accept **kwMike Bayer2022-12-167-48/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added test support to ensure that all compiler ``visit_xyz()`` methods across all :class:`.Compiler` implementations in SQLAlchemy accept a ``**kw`` parameter, so that all compilers accept additional keyword arguments under all circumstances. Fixes: #8988 Change-Id: I1cefc313e4e64a10ee7dd14400137fbe02ce9523
* | | | Merge "make bind escape lookup extensible" into mainmike bayer2022-12-162-18/+92
|\ \ \ \ | |_|/ / |/| | |
| * | | make bind escape lookup extensibleMike Bayer2022-12-162-18/+92
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To accommodate for third party dialects with different character escaping needs regarding bound parameters, the system by which SQLAlchemy "escapes" (i.e., replaces with another character in its place) special characters in bound parameter names has been made extensible for third party dialects, using the :attr:`.SQLCompiler.bindname_escape_chars` dictionary which can be overridden at the class declaration level on any :class:`.SQLCompiler` subclass. As part of this change, also added the dot ``"."`` as a default "escaped" character. Fixes: #8994 Change-Id: I52fbbfa8c64497b123f57327113df3f022bd1419
* | | Merge "add eager_defaults="auto" for inserts" into mainmike bayer2022-12-165-34/+110
|\ \ \ | |/ / |/| |
| * | add eager_defaults="auto" for insertsMike Bayer2022-12-155-34/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added a new default value for the :paramref:`.Mapper.eager_defaults` parameter "auto", which will automatically fetch table default values during a unit of work flush, if the dialect supports RETURNING for the INSERT being run, as well as :ref:`insertmanyvalues <engine_insertmanyvalues>` available. Eager fetches for server-side UPDATE defaults, which are very uncommon, continue to only take place if :paramref:`.Mapper.eager_defaults` is set to ``True``, as there is no batch-RETURNING form for UPDATE statements. Fixes: #8889 Change-Id: I84b91092a37c4cd216e060513acde3eb0298abe9
* | | Merge "implement literal_binds with expanding + bind_expression" into mainmike bayer2022-12-161-8/+56
|\ \ \
| * | | implement literal_binds with expanding + bind_expressionMike Bayer2022-12-151-8/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed bug where SQL compilation would fail to make use of :meth:`_types.TypeEngine.bind_expression` on a given type when used in the context of an "expanding" (i.e. "IN") parameter with the ``literal_binds`` compiler parameter in use. Fixes: #8989 Change-Id: Ic9fd27b46381b488117295ea5a492d8fc158e39f
* | | | Merge "add explicit REGCONFIG, pg full text functions" into mainmike bayer2022-12-166-2/+317
|\ \ \ \
| * | | | add explicit REGCONFIG, pg full text functionsMike Bayer2022-12-156-2/+317
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added support for explicit use of PG full text functions with asyncpg and psycopg (SQLAlchemy 2.0 only), with regards to the ``REGCONFIG`` type cast for the first argument, which previously would be incorrectly cast to a VARCHAR, causing failures on these dialects that rely upon explicit type casts. This includes support for :class:`_postgresql.to_tsvector`, :class:`_postgresql.to_tsquery`, :class:`_postgresql.plainto_tsquery`, :class:`_postgresql.phraseto_tsquery`, :class:`_postgresql.websearch_to_tsquery`, :class:`_postgresql.ts_headline`, each of which will determine based on number of arguments passed if the first string argument should be interpreted as a PostgreSQL "REGCONFIG" value; if so, the argument is typed using a newly added type object :class:`_postgresql.REGCONFIG` which is then explicitly cast in the SQL expression. Fixes: #8977 Change-Id: Ib36698a984fd4194bd6e0eb663105f790f3db7d3
* | | | Merge "Improved error message in orm annotated declarative" into mainmike bayer2022-12-161-5/+20
|\ \ \ \
| * | | | Improved error message in orm annotated declarativeFederico Caselli2022-12-141-5/+20
| | |_|/ | |/| | | | | | | | | | | | | | Fixes: #8980 Change-Id: I32c4cf8715ee43fa8415f0102394ddd43b1fee0a
* | | | Merge "Improve v2 documentation" into mainmike bayer2022-12-151-5/+152
|\ \ \ \
| * | | | Improve v2 documentationFederico Caselli2022-12-141-5/+152
| |/ / / | | | | | | | | | | | | | | | | Fixes: #7659 Change-Id: Ic9b758c7eed568f33dd0a745031f96de7666baf1
* | | | Fix equality comparison between a PG Range and a different class instanceLele Gaifax2022-12-151-4/+7
| |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | This fixes issue #8984, making the method `Range.__eq__` return `NotImplemented` when the argument is an instance of a different class. Closes: #8985 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8985 Pull-request-sha: b8f601f038a2203af02a99ab190ebbc1c489549a Change-Id: Iaf0b651a22a9f346c8f18b3a53e3339bf61bb33f
* | | Merge "warn when backref will replace existing userland descriptor" into mainmike bayer2022-12-142-3/+21
|\ \ \
| * | | warn when backref will replace existing userland descriptorMike Bayer2022-12-142-3/+21
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | A warning is emitted if a backref name used in :func:`_orm.relationship` names an attribute on the target class which already has a method or attribute assigned to that name, as the backref declaration will replace that attribute. Fixes: #4629 Change-Id: I0059b35ce60f43b0f3d8be008f12411154484ea1