summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
...
| * | use simple decimal query to detect decimal charMike Bayer2022-11-011-4/+27
| |/ | | | | | | | | | | | | | | | | | | | | | | Fixed issue where the ``nls_session_parameters`` view queried on first connect in order to get the default decimal point character may not be available depending on Oracle connection modes, and would therefore raise an error. The approach to detecting decimal char has been simplified to test a decimal value directly, instead of reading system views, which works on any backend / driver. Fixes: #8744 Change-Id: I39825131c13513798863197d0c180dd5a18b32dc
* | fix event nameMike Bayer2022-11-021-1/+1
|/ | | | | Change-Id: I26af2326034be07f0ebc91dfbf31d00c40acf585 References: #8717
* evaluate types in terms of the class in which they appearMike Bayer2022-10-317-25/+88
| | | | | | | | | | | Fixed issues within the declarative typing resolver (i.e. which resolves ``ForwardRef`` objects) where types that were declared for columns in one particular source file would raise ``NameError`` when the ultimate mapped class were in another source file. The types are now resolved in terms of the module for each class in which the types are used. Fixes: #8742 Change-Id: I236f94484ea79d47392a6201e671eeb89c305fd8
* Merge "ensure pool.reset event always called for reset" into mainmike bayer2022-10-3010-59/+306
|\
| * ensure pool.reset event always called for resetMike Bayer2022-10-3010-59/+306
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added new parameter :paramref:`.PoolEvents.reset.reset_state` parameter to the :meth:`.PoolEvents.reset` event, with deprecation logic in place that will continue to accept event hooks using the previous set of arguments. This indicates various state information about how the reset is taking place and is used to allow custom reset schemes to take place with full context given. Within this change a fix that's also backported to 1.4 is included which re-enables the :meth:`.PoolEvents.reset` event to continue to take place under all circumstances, including when :class:`.Connection` has already "reset" the connection. The two changes together allow custom reset schemes to be implemented using the :meth:`.PoolEvents.reset` event, instead of the :meth:`.PoolEvents.checkin` event (which continues to function as it always has). Change-Id: Ie17c4f55d02beb6f570b9de6b3044baffa7d6df6 Fixes: #8717
* | fix test for same mapper to use "isa"Mike Bayer2022-10-301-3/+7
|/ | | | | | | | | Fixed issue in joined eager loading where an assertion fail would occur with a particular combination of outer/inner joined eager loads in conjunction with an inherited subclass mapper as the middle target. Fixes: #8738 Change-Id: I4909e7518302cbb82046e0425abbbdc8eb1c0146
* Merge "use only object_id() function for temp tables" into mainmike bayer2022-10-293-33/+74
|\
| * use only object_id() function for temp tablesMike Barry2022-10-283-33/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue with :meth:`.Inspector.has_table` when used against a temporary table for the SQL Server dialect would fail an invalid object name error on some Azure variants, due to an unnecessary information schema query that is not supported on those server versions. Pull request courtesy Mike Barry. the patch also fills out test support for has_table() against temp tables, temp views, adding to the has_table() support just added for views in #8700. Fixes: #8714 Closes: #8716 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8716 Pull-request-sha: e2ac7a52e2b09a349a703ba1e1a2911f4d3c0912 Change-Id: Ia73e4e9e977a2d6b7e100abd2f81a8c8777dc9bb
* | ensure _ORMJoin transfers parententity from left sideMike Bayer2022-10-283-2/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed bug involving :class:`.Select` constructs which used a combination of :meth:`.Select.select_from` with an ORM entity followed by :meth:`.Select.join` against the entity sent in :meth:`.Select.select_from`, as well as using plain :meth:`.Select.join_from`, which when combined with a columns clause that didn't explicitly include that entity would then cause "automatic WHERE criteria" features such as the IN expression required for a single-table inheritance subclass, as well as the criteria set up by the :func:`_orm.with_loader_criteria` option, to not be rendered for that entity. The correct entity is now transferred to the :class:`.Join` object that's generated internally, so that the criteria against the left side entity is correctly added. Fixes: #8721 Change-Id: I8266430063e2c72071b7262fdd5ec5079fbcba3e
* | Merge "apply basic escaping to anon_labels unconditionally" into mainmike bayer2022-10-281-1/+6
|\ \
| * | apply basic escaping to anon_labels unconditionallyMike Bayer2022-10-271-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue which prevented the :func:`_sql.literal_column` construct from working properly within the context of a :class:`.Select` construct as well as other potential places where "anonymized labels" might be generated, if the literal expression contained characters which could interfere with format strings, such as open parenthesis, due to an implementation detail of the "anonymous label" structure. Fixes: #8724 Change-Id: I3089124fbd055a011c8a245964258503b717d941
* | | Merge "ensure inherited mapper attrs not interpreted as plain dataclass ↵mike bayer2022-10-282-10/+33
|\ \ \ | |_|/ |/| | | | | fields" into main
| * | ensure inherited mapper attrs not interpreted as plain dataclass fieldsMike Bayer2022-10-262-10/+33
| |/ | | | | | | | | | | | | | | | | Fixed issue in new dataclass mapping feature where a column declared on the decalrative base / abstract base / mixin would leak into the constructor for an inheriting subclass under some circumstances. Fixes: #8718 Change-Id: Ic519acf239e2f80541516f10995991cbbbed00bd
* | mssql doc updatesMike Bayer2022-10-281-16/+17
|/ | | | | | clarify some URL things Change-Id: Ic162834052f06fd3a6c010ce5d091903fdc65cd8
* Merge "reconcile Mapper properties ordering against mapped Table" into mainmike bayer2022-10-251-73/+184
|\
| * reconcile Mapper properties ordering against mapped TableMike Bayer2022-10-251-73/+184
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changed a fundamental configuration behavior of :class:`.Mapper`, where :class:`_schema.Column` objects that are explicitly present in the :paramref:`_orm.Mapper.properties` dictionary, either directly or enclosed within a mapper property object, will now be mapped within the order of how they appear within the mapped :class:`.Table` (or other selectable) itself (assuming they are in fact part of that table's list of columns), thereby maintaining the same order of columns in the mapped selectable as is instrumented on the mapped class, as well as what renders in an ORM SELECT statement for that mapper. Previously (where "previously" means since version 0.0.1), :class:`.Column` objects in the :paramref:`_orm.Mapper.properties` dictionary would always be mapped first, ahead of when the other columns in the mapped :class:`.Table` would be mapped, causing a discrepancy in the order in which the mapper would assign attributes to the mapped class as well as the order in which they would render in statements. The change most prominently takes place in the way that Declarative assigns declared columns to the :class:`.Mapper`, specifically how :class:`.Column` (or :func:`_orm.mapped_column`) objects are handled when they have a DDL name that is explicitly different from the mapped attribute name, as well as when constructs such as :func:`_orm.deferred` etc. are used. The new behavior will see the column ordering within the mapped :class:`.Table` being the same order in which the attributes are mapped onto the class, assigned within the :class:`.Mapper` itself, and rendered in ORM statements such as SELECT statements, independent of how the :class:`_schema.Column` was configured against the :class:`.Mapper`. Fixes: #8705 Change-Id: I95cc05061a97fe6b1654bab70e2f6da30f8f3bd3
* | raise for non-Load opt passed to options()Mike Bayer2022-10-251-1/+10
| | | | | | | | | | | | | | | | | | | | | | Fixed the exception that's raised when the :func:`_orm.with_loader_criteria` option is attempted to be used within a specific loader path, like in loader.options(). :func:`_orm.with_loader_criteria` is only intended to be used at the top level. Fixes: #8711 Change-Id: Iaa7b13956b808761e618a6be6406e5c82df1c65c
* | Merge "add Oracle-specific parameter escapes for expanding params" into mainmike bayer2022-10-252-0/+45
|\ \
| * | add Oracle-specific parameter escapes for expanding paramsMike Bayer2022-10-242-0/+45
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue where bound parameter names, including those automatically derived from similarly-named database columns, which contained characters that normally require quoting with Oracle would not be escaped when using "expanding parameters" with the Oracle dialect, causing execution errors. The usual "quoting" for bound parameters used by the Oracle dialect is not used with the "expanding parameters" architecture, so escaping for a large range of characters is used instead, now using a list of characters/escapes that are specific to Oracle. Fixes: #8708 Change-Id: I90c24e48534e1b3a4c222b3022da58159784d91a
* | Merge "skip ad-hoc properties within subclass_load_via_in" into mainmike bayer2022-10-241-2/+11
|\ \ | |/ |/|
| * skip ad-hoc properties within subclass_load_via_inMike Bayer2022-10-231-2/+11
| | | | | | | | | | | | | | | | | | | | Fixed issue where "selectin_polymorphic" loading for inheritance mappers would not function correctly if the :param:`_orm.Mapper.polymorphic_on` parameter referred to a SQL expression that was not directly mapped on the class. Fixes: #8704 Change-Id: I1b6be2650895fd18d2c804f6ba96de966d11041a
* | Merge "Add pep 584 to python immutabledict fallback" into mainmike bayer2022-10-232-3/+18
|\ \
| * | Add pep 584 to python immutabledict fallbackFederico Caselli2022-10-222-3/+18
| |/ | | | | | | | | Fixes: #8695 Change-Id: Ie0412c3a7b2b1ba5bd5112f204318ff763cbb8f4
* | Merge "DeclarativeBase ``__table__`` annotation is not optional" into mainmike bayer2022-10-231-1/+1
|\ \
| * | DeclarativeBase ``__table__`` annotation is not optionalFederico Caselli2022-10-221-1/+1
| |/ | | | | | | Change-Id: I92bfc0cf58fa2e6f9d7e8055f1a337ec806c1410
* | test support for has_table()->view; backport to 1.4Mike Bayer2022-10-231-17/+24
|/ | | | | | | | | | | | | For 1.4 only; in 2.0 this just refines the test suite a bit. Fixed regression which occurred throughout the 1.4 series where the :meth:`.Inspector.has_table` method, which historically reported on views as well, stopped working for SQL Server. The issue is not present in the 2.0 series which uses a different reflection architecture. Test support is added to ensure ``has_table()`` remains working per spec re: views. Fixes: #8700 Change-Id: I119a91ec07911edb08cf0799234827fec9ea1195
* Merge "Only convert Range for sqlalchemy Range object" into mainmike bayer2022-10-213-23/+19
|\
| * Only convert Range for sqlalchemy Range objectMike Bayer2022-10-213-23/+19
| | | | | | | | | | | | | | | | | | | | Refined the new approach to range objects described at :ref:`change_7156` to accommodate driver-specific range and multirange objects, to better accommodate both legacy code as well as when passing results from raw SQL result sets back into new range or multirange expressions. Fixes: #8690 Change-Id: I7e62c47067f695c6380ad0fe2fe19deaf33594d1
* | Merge "allow legacy forms with __allow_unmapped__" into mainmike bayer2022-10-212-41/+43
|\ \ | |/ |/|
| * allow legacy forms with __allow_unmapped__Mike Bayer2022-10-212-41/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improved support for legacy 1.4 mappings that use annotations which don't include ``Mapped[]``, by ensuring the ``__allow_unmapped__`` attribute can be used to allow such legacy annotations to pass through Annotated Declarative without raising an error and without being interpreted in an ORM runtime context. Additionally improved the error message generated when this condition is detected, and added more documentation for how this situation should be handled. Unfortunately the 1.4 WARN_SQLALCHEMY_20 migration warning cannot detect this particular configurational issue at runtime with its current architecture. Fixes: #8692 Change-Id: I5c642bcc1ebb7816f9470ec9bb0951550b6d55f1
* | Version 2.0.0b3 placeholderMike Bayer2022-10-201-1/+1
|/
* collect annotation earlier for mapped_column presentMike Bayer2022-10-201-3/+15
| | | | | | | | | | | | | | | | | | | | Fixed issue with new dataclass mapping feature where arguments passed to the dataclasses API could sometimes be mis-ordered when dealing with mixins that override :func:`_orm.mapped_column` declarations, leading to initializer problems. the change made here is specific to the test case given which regards mapped_column() most specifically. cases that involve relationship() etc. are not tested here, however mapped_column() is the only attribute that's implicit without an instance given on the right side, and is also most common for mixins. not clear if there are more issues in this area, however it appears that we need only adjust the order in which we accommodate grabbing the annotations in order to affect how dataclasses sees the class; that is, we have control over ``__annotations__`` here so dont have to worry about ``cls.__dict__``. Fixes: #8688 Change-Id: I808c86f23d73aa47cd910ae01c3e07093d469fdc
* Merge "Improve typing of DeclarativeBase" into mainmike bayer2022-10-202-1/+7
|\
| * Improve typing of DeclarativeBaseFederico Caselli2022-10-192-1/+7
| | | | | | | | | | | | | | Also allow mapped columns inside indexes, unique cosntraints, primary key constriant Fixes: #8645 Change-Id: If37ab85ead0fbd1125cd6329c2f01a031777b081
* | more many-to-one typingMike Bayer2022-10-193-3/+51
|/ | | | | | | | | | | | | | | | | | since we are typing centric, note this configuration as we have just supported in #8668. Note also I am just taking "backref" out of the basic version of the docs here totally, this doc is already a lot to read / take in without making it even more confusing; backref still has an entirely dedicated docs page which can have all the additional behaviors of backref() described. Additionally, get other "optional" forms to work including ``cls | None`` and ``Union[cls, None]``. Fixes: #8668 Change-Id: I2b026f496a1710ddebfb4aa6cf8459b4892cbc54
* Merge "de-optionalize union types to support Optional for m2o" into mainmike bayer2022-10-191-6/+10
|\
| * de-optionalize union types to support Optional for m2oMike Bayer2022-10-191-6/+10
| | | | | | | | | | | | | | | | | | Fixed bug in new ORM typed declarative mappings where we did not include the ability to use ``Optional[]`` in the type annotation for a many-to-one relationship, even though this is common. Fixes: #8668 Change-Id: Idaf0846e49cc12095394b99ad6fe678735cf9242
* | Merge "call super().__init_subclass__(); support GenericAlias" into mainmike bayer2022-10-192-1/+14
|\ \ | |/
| * call super().__init_subclass__(); support GenericAliasMike Bayer2022-10-192-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | Improved the :class:`.DeclarativeBase` class so that when combined with other mixins like :class:`.MappedAsDataclass`, the order of the classes may be in either order. Added support for mapped classes that are also ``Generic`` subclasses, to be specified as a ``GenericAlias`` object (e.g. ``MyClass[str]``) within statements and calls to :func:`_sa.inspect`. Fixes: #8665 Change-Id: I03063a28b0438a44b9e028fd9d45e8ce08bd18c4
* | Merge "further qualify pyodbc setinputsizes types for long stirngs" into mainmike bayer2022-10-193-12/+38
|\ \ | |/ |/|
| * further qualify pyodbc setinputsizes types for long stirngsMike Bayer2022-10-183-12/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed regression caused by SQL Server pyodbc change :ticket:`8177` where we now use ``setinputsizes()`` by default; for VARCHAR, this fails if the character size is greater than 4000 (or 2000, depending on data) characters as the incoming datatype is NVARCHAR, which has a limit of 4000 characters, despite the fact that VARCHAR can handle unlimited characters. Additional pyodbc-specific typing information is now passed to ``setinputsizes()`` when the datatype's size is > 2000 characters. The change is also applied to the :class:`.JSON` type which was also impacted by this issue for large JSON serializations. Fixes: #8661 Change-Id: I07fa873e95dbd2c94f3d286e93e8b3229c3a9807
* | Revert automatic set of sequence start to 1Federico Caselli2022-10-179-32/+106
|/ | | | | | | | | | | | | | | | | The :class:`.Sequence` construct restores itself to the DDL behavior it had prior to the 1.4 series, where creating a :class:`.Sequence` with no additional arguments will emit a simple ``CREATE SEQUENCE`` instruction **without** any additional parameters for "start value". For most backends, this is how things worked previously in any case; **however**, for MS SQL Server, the default value on this database is ``-2**63``; to prevent this generally impractical default from taking effect on SQL Server, the :paramref:`.Sequence.start` parameter should be provided. As usage of :class:`.Sequence` is unusual for SQL Server which for many years has standardized on ``IDENTITY``, it is hoped that this change has minimal impact. Fixes: #7211 Change-Id: I1207ea10c8cb1528a1519a0fb3581d9621c27b31
* simplify unmapped col eval fallbackMike Bayer2022-10-172-53/+47
| | | | | | | | | | | | | Removed the warning that emits when using ORM-enabled update/delete regarding evaluation of columns by name, first added in :ticket:`4073`; this warning actually covers up a scenario that otherwise could populate the wrong Python value for an ORM mapped attribute depending on what the actual column is, so this deprecated case is removed. In 2.0, ORM enabled update/delete uses "auto" for "synchronize_session", which should do the right thing automatically for any given UPDATE expression. Fixes: #8656 Change-Id: Idb8b4a86d3caed89f69cde1607886face103cf6a
* repair type qualify in _ServerDefaultType; other pyright tweaksMike Bayer2022-10-163-6/+6
| | | | | | | | | | | | | | | | | as we haven't done full pylance / pyright strict typing internally, some of the things pyright reports on specifically will leak out into user code, such as this mapped_column() issue. So we will have to look more closely at pyright strict mode going forward for the release. Fixed typing issue where pylance strict mode would report "partially unknown" datatype for the :func:`_orm.mapped_column` construct. Also repaired a trailing comma and pyright complaining about overloads for orm.composite. Fixes: #8644 Change-Id: Ia48dc5dbd56bbceeacee4f0daf9810bfdea3bee3
* accommodate arbitrary embedded params in insertmanyvaluesMike Bayer2022-10-162-55/+135
| | | | | | | | | | Fixed bug in new "insertmanyvalues" feature where INSERT that included a subquery with :func:`_sql.bindparam` inside of it would fail to render correctly in "insertmanyvalues" format. This affected psycopg2 most directly as "insertmanyvalues" is used unconditionally with this driver. Fixes: #8639 Change-Id: I67903fa86afe208899d4f23f940e0727d1be2ce3
* Version 2.0.0b2 placeholderMike Bayer2022-10-131-1/+1
|
* further 2.0 modernizationsMike Bayer2022-10-131-0/+5
| | | | | | | biggest change here is the old tutorials were removed from the TOC and some additional links to them have been corrected. Change-Id: I79b878a946422eac24ed2449b440fc5d556576c4
* Merge "implement autobegin=False option" into mainmike bayer2022-10-123-51/+127
|\
| * implement autobegin=False optionMike Bayer2022-10-113-51/+127
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added new parameter :paramref:`_orm.Session.autobegin`, which when set to ``False`` will prevent the :class:`_orm.Session` from beginning a transaction implicitly. The :meth:`_orm.Session.begin` method must be called explicitly first in order to proceed with operations, otherwise an error is raised whenever any operation would otherwise have begun automatically. This option can be used to create a "safe" :class:`_orm.Session` that won't implicitly start new transactions. As part of this change, also added a new status variable :class:`_orm.SessionTransaction.origin` which may be useful for event handling code to be aware of the origin of a particular :class:`_orm.SessionTransaction`. Fixes: #6928 Change-Id: I246f895c4a475bff352216e5bc74b6a25e6a4ae7
* | Merge "warn for no polymorphic identity w/ poly hierarchy" into mainmike bayer2022-10-111-3/+20
|\ \