summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
Commit message (Collapse)AuthorAgeFilesLines
...
* | | Merge "Improved usage of ``asyncio.shield()``" into mainFederico Caselli2022-09-152-4/+8
|\ \ \
| * | | Improved usage of ``asyncio.shield()``Federico Caselli2022-09-152-4/+8
| |/ / | | | | | | | | | | | | Fixes: #8516 Change-Id: Ifd8f5e5f42d9fbcd5b8d00bddc81ff6be690a75e
* | | Merge "Use ``;`` instead of ``select 1`` to ping PostgreSQL" into mainFederico Caselli2022-09-154-0/+36
|\ \ \
| * | | Use ``;`` instead of ``select 1`` to ping PostgreSQLFederico Caselli2022-09-154-0/+36
| |/ / | | | | | | | | | | | | Fixes: #8491 Change-Id: I941d2a3cf92e5609e2045a53cec94522340951db
* | | Add type awareness to evaluatorMike Bayer2022-09-131-19/+49
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed regression where using ORM update() with synchronize_session='fetch' would fail due to the use of evaluators that are now used to determine the in-Python value for expressions in the the SET clause when refreshing objects; if the evaluators make use of math operators against non-numeric values such as PostgreSQL JSONB, the non-evaluable condition would fail to be detected correctly. The evaluator now limits the use of math mutation operators to numeric types only, with the exception of "+" that continues to work for strings as well. SQLAlchemy 2.0 may alter this further by fetching the SET values completely rather than using evaluation. Fixes: #8507 Change-Id: Icf7120ccbf4266499df6bb3e05159c9f50971d69
* | Merge "additional de-stringify pass for unions" into mainmike bayer2022-09-082-2/+21
|\ \
| * | additional de-stringify pass for unionsMike Bayer2022-09-082-2/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the change in c3cfee5b00a40790c18d took out a pass for de-stringify that broke some un-tested cases for Optional with future annotations mode. Adding tests for this revealed that this was a subset of a more general case where Union is presented with ForwardRefs inside of it matching up within the type map, which wasn't working before either, fixed that as well with an additional de-stringify for elements within the Union. Fixes: #8478 Change-Id: I8804cf6c67f14d10804584e1cddd2cfaa2376654
* | | Merge "implement icontains, istartswith, iendswith operators" into mainmike bayer2022-09-086-21/+415
|\ \ \ | |/ / |/| |
| * | implement icontains, istartswith, iendswith operatorsMatias Martinez Rebori2022-09-086-21/+415
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added long-requested case-insensitive string operators :meth:`_sql.ColumnOperators.icontains`, :meth:`_sql.ColumnOperators.istartswith`, :meth:`_sql.ColumnOperators.iendswith`, which produce case-insensitive LIKE compositions (using ILIKE on PostgreSQL, and the LOWER() function on all other backends) to complement the existing LIKE composition operators :meth:`_sql.ColumnOperators.contains`, :meth:`_sql.ColumnOperators.startswith`, etc. Huge thanks to Matias Martinez Rebori for their meticulous and complete efforts in implementing these new methods. Fixes: #3482 Closes: #8496 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8496 Pull-request-sha: 7287e2c436959fac4fef022f359fcc73d1528211 Change-Id: I9fcdd603716218067547cc92a2b07bd02a2c366b
* | | enable UPDATE..FROM for SQLiteMike Bayer2022-09-071-0/+10
|/ / | | | | | | | | | | | | | | | | | | | | The SQLite dialect now supports UPDATE..FROM syntax, for UPDATE statements that may refer to additional tables within the WHERE criteria of the statement without the need to use subqueries. This syntax is invoked automatically when using the :class:`_dml.Update` construct when more than one table or other entity or selectable is used. Fixes: #7185 Change-Id: I27e94ace9ff761cc45e652fa1abff8cd1f42fec5
* | Improve compiled extension detectionFederico Caselli2022-09-051-2/+20
| | | | | | | | | | | | | | | | | | Ensure that all cython extension are imported by the compied detection logic. This is required since cython extensions moduels are marked as optional in the install, so it's possible that only some of them are compiled. The extensions are enabled only if all of them are correctly compiled Change-Id: I355cbac06f5c7a47d35661f42ebab3b0156c1965
* | Merge "Fix Azure Synapse connection error" into mainmike bayer2022-09-021-18/+25
|\ \
| * | Fix Azure Synapse connection errorGord Thompson2022-09-021-18/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed regression caused by the fix for :ticket:`8231` released in 1.4.40 where connection would fail if the user does not have permission to query the dm_exec_sessions or dm_pdw_nodes_exec_sessions system view when trying to determine the current transaction isolation level. Fixes: #8475 Change-Id: Ie2bcda92f2ef2d12360ddda47eb6e896313c71f2
* | | Detection of PEP 604 union syntax.Peter Schutt2022-09-012-8/+11
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Description Fixes #8478 Handle `UnionType` as arguments to `Mapped`, e.g., `Mapped[str | None]`: - adds `utils.typing.is_optional_union()` used to detect if a column should be nullable. - adds `"UnionType"` to `utils.typing.is_optional()` names. - uses `get_origin()` in `utils.typing.is_origin_of()` as `UnionType` has no `__origin__` attribute. - tests with runtime type and postponed annotations and guard the tests running with `compat.py310`. ### 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 - [x] 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. - [ ] 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: #8479 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8479 Pull-request-sha: 12417654822272c5847e684c53677f665553ef0e Change-Id: Ib3248043dd4a97324ac592c048385006536b2d49
* | run update_subclass anytime we add new clslevel dispatchMike Bayer2022-08-313-33/+25
| | | | | | | | | | | | | | | | | | | | | | Fixed event listening issue where event listeners added to a superclass would be lost if a subclass were created which then had its own listeners associated. The practical example is that of the :class:`.sessionmaker` class created after events have been associated with the :class:`_orm.Session` class. Fixes: #8467 Change-Id: I9bdba8769147e30110a09900d4a577e833ac3af9
* | Merge "include TableClause.schema in cache key" into mainmike bayer2022-08-301-0/+1
|\ \
| * | include TableClause.schema in cache keyMike Bayer2022-08-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue where use of the :func:`_sql.table` construct, passing a string for the :paramref:`_sql.table.schema` parameter, would fail to take the "schema" string into account when producing a cache key, thus leading to caching collisions if multiple, same-named :func:`_sql.table` constructs with different schemas were used. Fixes: #8441 Change-Id: Ic4b55b3e8ec53b4c88ba112691bdf60ea1d4c448
* | | implement event for merge/load=False for mutable state setupMike Bayer2022-08-303-0/+28
|/ / | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue in :mod:`sqlalchemy.ext.mutable` extension where collection links to the parent object would be lost if the object were merged with :meth:`.Session.merge` while also passing :paramref:`.Session.merge.load` as False. The event added here is currently private for expediency, but is acceptable to become a public event at some point. Fixes: #8446 Change-Id: I9e5b9f1f5a0c5a9781f51635d5e57b1134c9e866
* | apply consistent ORM mutable notes for all mutable SQL typesMike Bayer2022-08-303-22/+80
| | | | | | | | | | | | | | | | | | | | | | | | in https://github.com/sqlalchemy/sqlalchemy/discussions/8447 I was surprised that we didnt have any notes about using Mutable for ARRAY classes, since we have them for HSTORE and JSON. Add a consistent topic box for these so we have something to point towards. Change-Id: Idfa1b2cbee67024545f4fa299e4c875075ec7d3f
* | Merge "Use cibuildwheel to create wheels" into mainFederico Caselli2022-08-302-4/+13
|\ \
| * | Use cibuildwheel to create wheelsTrevor Gross2022-08-292-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using cibuildwheel the following wheels are created: - windows x64 and x84 - macos x64 and arm - linux x64 and arm on manylinux and mosulinux (for alpine) - create a pure python wheel (for pypy and other archs) Fixes: #6702 Fixes: #7607 Closes: #7992 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7992 Pull-request-sha: 61d5e24e5b76c97db73aa2507af7f5c2d3a948fa Change-Id: If0c0b353766e0b61d421789d619eb2b940c08ad0
* | | refine ruleset to determine when poly adaption should be usedMike Bayer2022-08-293-13/+42
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed regression appearing in the 1.4 series where a joined-inheritance query placed as a subquery within an enclosing query for that same entity would fail to render the JOIN correctly for the inner query. The issue manifested in two different ways prior and subsequent to version 1.4.18 (related issue #6595), in one case rendering JOIN twice, in the other losing the JOIN entirely. To resolve, the conditions under which "polymorphic loading" are applied have been scaled back to not be invoked for simple joined inheritance queries. Fixes: #8456 Change-Id: Ie4332fadb1dfc670cd31d098a6586a9f6976bcf7
* | Merge "integrate connection.terminate() for supporting dialects" into mainmike bayer2022-08-244-10/+61
|\ \
| * | integrate connection.terminate() for supporting dialectsMike Bayer2022-08-244-10/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Integrated support for asyncpg's ``terminate()`` method call for cases where the connection pool is recycling a possibly timed-out connection, where a connection is being garbage collected that wasn't gracefully closed, as well as when the connection has been invalidated. This allows asyncpg to abandon the connection without waiting for a response that may incur long timeouts. Fixes: #8419 Change-Id: Ia575af779d5733b483a72dff3690b8bbbad2bb05
* | | Merge "include mssql_clustered dialect_options when reflecting - issue ↵mike bayer2022-08-242-6/+30
|\ \ \ | |/ / |/| | | | | #8288" into main
| * | include mssql_clustered dialect_options when reflecting - issue #8288John Lennox2022-08-232-6/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implemented reflection of the "clustered index" flag ``mssql_clustered`` for the SQL Server dialect. Pull request courtesy John Lennox. Fixes: #8288 Closes: #8289 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8289 Pull-request-sha: 1bb57352e3e31d8fb7de69ab5e60e5464949f640 Change-Id: Ife367066328f9e47ad823e4098647964a18e21e8
* | | more function adjustmentsMike Bayer2022-08-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | the inherited-members feature works very poorly and inconsistently in sphinx. just dont use it here as it refuses to exclude ColumnOperators methods Change-Id: Ic50865c9901e7225a99ff7f33454da15ff91b12f
* | | Merge "support create/drop events for all CREATE/DROP" into mainmike bayer2022-08-224-156/+280
|\ \ \
| * | | support create/drop events for all CREATE/DROPMike Bayer2022-08-204-156/+280
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implemented the DDL event hooks :meth:`.DDLEvents.before_create`, :meth:`.DDLEvents.after_create`, :meth:`.DDLEvents.before_drop`, :meth:`.DDLEvents.after_drop` for all :class:`.SchemaItem` objects that include a distinct CREATE or DROP step, when that step is invoked as a distinct SQL statement, including for :class:`.ForeignKeyConstraint`, :class:`.Sequence`, :class:`.Index`, and PostgreSQL's :class:`_postgresql.ENUM`. Fixes: #8394 Change-Id: Iee6274984e794f50103451a04d089641d6ac443a
* | | | Column._copy() duplicates "user defined" nullable state exactlyMike Bayer2022-08-211-3/+7
| |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To accommodate how mapped_column() works, after many attempts to get this working it became clear that _copy() should just transfer "nullable" state exactly as it was, including the state where .nullable was set but user_defined_nullable remains at not user set. additionally, added a similar step to _merge() that was needed to preserve the nullability behavior when Identity is present. server / client default objects are not copied within column._copy() and this should be fixed. Fixes: #8410 Change-Id: Ib09df52b71f3e58e67e9f19b893d40a6cc4eec5c
* | | remove narrative "reconstructor" documentMike Bayer2022-08-191-2/+6
| | | | | | | | | | | | | | | | | | | | | this event hook is not commonly used and this page does not fit into the current narrative very well. We should possibly write a new paragraph regarding how instances load at some point though the best place to put it is not clear.
* | | remove notes re: current pymssql DBAPI featuresMike Bayer2022-08-191-18/+0
| | | | | | | | | | | | | | | Fixes: #8337 Change-Id: Ib0c107bb386489dcb6d1683f29d0a9574dd96f1e
* | | improve abstractconcretebaseMike Bayer2022-08-181-13/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | try to limit the attributes on the base and set up wpoly etc so that things still work the way we want. It seems like I've tried this in the past before so not sure if this is actually working or if there are problems. it needs a little more strictness on how you set up your base since attributes are no longer implicit. So, it seems like perhaps the new behavior should be on a flag or something like "strict_attributes=True", something like that, so that nothing breaks for existing users and we can slowly deal with the new way being a little bit less worse than the old way. Fixes: #8403 Change-Id: Ic9652d9a0b024d649807aaf3505e67173e7dc3b9
* | | more abstractconcretebase clarityMike Bayer2022-08-181-22/+23
| | | | | | | | | | | | Change-Id: I9ddb6b1a2e0c0be1fe355a7ea714d0e16aa93b47
* | | Merge "validate mapped collection key is loaded" into mainmike bayer2022-08-174-32/+185
|\ \ \
| * | | validate mapped collection key is loadedMike Bayer2022-08-174-32/+185
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changed the attribute access method used by :func:`_orm.attribute_mapped_collection` and :func:`_orm.column_mapped_collection`, used when populating the dictionary, to assert that the data value on the object to be used as the dictionary key is actually present, and is not instead using "None" due to the attribute never being actually assigned. This is used to prevent a mis-population of None for a key when assigning via a backref where the "key" attribute on the object is not yet assigned. As the failure mode here is a transitory condition that is not typically persisted to the database, and is easy to produce via the constructor of the class based on the order in which parameters are assigned, it is very possible that many applications include this behavior already which is silently passed over. To accommodate for applications where this error is now raised, a new parameter :paramref:`_orm.attribute_mapped_collection.ignore_unpopulated_attribute` is also added to both :func:`_orm.attribute_mapped_collection` and :func:`_orm.column_mapped_collection` that instead causes the erroneous backref assignment to be skipped. Fixes: #8372 Change-Id: I85bf4af405adfefe6386f0f2f8cef22537d95912
* | | | Merge "fill out all distinguising fields for AliasedInsp" into mainmike bayer2022-08-171-6/+13
|\ \ \ \
| * | | | fill out all distinguising fields for AliasedInspMike Bayer2022-08-171-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hardened the cache key strategy for the :func:`_orm.aliased` and :func:`_orm.with_polymorphic` constructs. While no issue involving actual statements being cached can easily be demonstrated (if at all), these two constructs were not including enough of what makes them unique in their cache keys for caching on the aliased construct alone to be accurate. Fixes: #8401 Change-Id: I13d14985b6965f398edd9494601d8ae89ac641f2
* | | | | Merge "refine transfer of cached ORM options for selectin, lazy" into mainmike bayer2022-08-174-66/+103
|\ \ \ \ \ | |_|/ / / |/| | | |
| * | | | refine transfer of cached ORM options for selectin, lazyMike Bayer2022-08-174-66/+103
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue involving :func:`_orm.with_loader_criteria` where a closure variable used as bound parameter value within the lambda would not carry forward correctly into additional relationship loaders such as :func:`_orm.selectinload` and :func:`_orm.lazyload` after the statement were cached, using the stale originally-cached value instead. This change brings forth a good refinement where we finally realize we shouldn't be testing every ORM option with lots of switches, we just let the option itself be given "here is your uncached version, you are cached, tell us what to do!". the current decision is that strategy loader options used the cached in all cases as they always have, with_loader_criteria uses the uncached, because the uncached will have been invoked with new closure state that we definitely need. The only edge that might not work is if with_loader_criteria referenced an entity that is local to the query, namely a specific AliasedInsp, however that's not a documented case for this. if we had to do that, then we perhaps would introduce a more complex reconcilation logic, and this would also give us the hook to do that. Fixes: #8399 Change-Id: Ided8e2123915131e3f11cf6b06d773039e73797a
* | | | Merge "restore Connectable and other changes for oslo.db" into mainmike bayer2022-08-171-0/+2
|\ \ \ \
| * | | | restore Connectable and other changes for oslo.dbMike Bayer2022-08-121-0/+2
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | at this point oslo.db should be passing tests however they seem to be importing "Connectable", which we had temporarily removed, it's now a different kind of object but restore it to the engine import space which seems to be where they're pulling it from to see if oslo.db can run some tests now. Change-Id: I52cb5ad82b00eec12004eeeb571c4eb8efa5ced2
* | | | Merge "Propagate key for collection events" into mainmike bayer2022-08-177-59/+162
|\ \ \ \
| * | | | Propagate key for collection eventsMike Bayer2022-08-167-59/+162
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added new parameter :paramref:`_orm.AttributeEvents.include_key`, which will include the dictionary or list key for operations such as ``__setitem__()`` (e.g. ``obj[key] = value``) and ``__delitem__()`` (e.g. ``del obj[key]``), using a new keyword parameter "key" or "keys", depending on event, e.g. :paramref:`_orm.AttributeEvents.append.key`, :paramref:`_orm.AttributeEvents.bulk_replace.keys`. This allows event handlers to take into account the key that was passed to the operation and is of particular importance for dictionary operations working with :class:`_orm.MappedCollection`. Fixes: #8375 Change-Id: Icc472f7c28848f94e15c94a399cc13a88782e1e4
* | | | Merge "JSONPATH type can be used in casts in PostgreSQL" into mainmike bayer2022-08-175-21/+51
|\ \ \ \
| * | | | JSONPATH type can be used in casts in PostgreSQLFederico Caselli2022-08-175-21/+51
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduced the type :class:`_postgresql.JSONPATH` that can be used in cast expressions. This is required by some PostgreSQL dialects when using functions such as ``jsonb_path_exists`` or ``jsonb_path_match`` that accept a ``jsonpath`` as input. Fixes: #8216 Change-Id: I3e7337eab91680cab1604e1f3058854a0a19c5be
* | | | Merge "Support comments on MSSQL" into mainmike bayer2022-08-172-25/+155
|\ \ \ \ | |_|/ / |/| | |
| * | | Support comments on MSSQLDaniel Hall2022-08-102-25/+155
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added support table and column comments on MSSQL when creating a table. Added support for reflecting table comments. Thanks to Daniel Hall for the help in this pull request. Fixes: #7844 Closes: #8225 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8225 Pull-request-sha: 540f4eb6395f9feed4b4240e3d22f539021948e9 Change-Id: I69f48c6dda4e00ec3d82fdeff13f3df9d735b7b0
* | | | remove erroneous note about future metadataMike Bayer2022-08-171-3/+0
| |/ / |/| | | | | | | | | | | | | | this change was already applied Change-Id: I24cfdc1912b77f98ae6d0f3865cabd223553fc79
* | | Add support for Partitioning and Sample pages on mysqlRamonWill2022-08-111-0/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for Partitioning and Sample pages on MySQL and MariaDB reflected options. The options are stored in the table dialect options dictionary, so the following keyword need to be prefixed with ``mysql_`` or ``mariadb_`` depending on the backend. Supported options are: * ``stats_sample_pages`` * ``partition_by`` * ``partitions`` * ``subpartition_by`` These options are also reflected when loading a table from database, and will populate the table :attr:`_schema.Table.dialect_options`. Pull request courtesy of Ramon Will. Fixes: #4038 Closes: #5536 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5536 Pull-request-sha: f8852cabe15c9a91de85d27980988051f7a1306d Change-Id: I69b60576532af04c725c998e9e8fec6e2040b149