summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
Commit message (Collapse)AuthorAgeFilesLines
* Merge "reorganize mapper compile/teardown under registry"mike bayer2021-02-017-158/+389
|\
| * reorganize mapper compile/teardown under registryMike Bayer2021-02-017-158/+389
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Mapper "configuration", which occurs within the :func:`_orm.configure_mappers` function, is now organized to be on a per-registry basis. This allows for example the mappers within a certain declarative base to be configured, but not those of another base that is also present in memory. The goal is to provide a means of reducing application startup time by only running the "configure" process for sets of mappers that are needed. This also adds the :meth:`_orm.registry.configure` method that will run configure for the mappers local in a particular registry only. Fixes: #5897 Change-Id: I14bd96982d6d46e241bd6baa2cf97471d21e7caa
* | set identifier length for MySQL constraints to 64Mike Bayer2021-01-306-8/+229
|/ | | | | | | | | | | | | | | | | | | | | | | | The rule to limit index names to 64 also applies to all DDL names, such as those coming from naming conventions. Add another limiting variable for constraint names and create test cases against all constraint types. Additionally, codified in the test suite MySQL's lack of support for naming of a FOREIGN KEY constraint after the name was given, which apparently assigns the name to an associated KEY but not the constraint itself, until MySQL 8 and MariaDB 10.5 which appear to have resolved the behavior. However it's not clear how Alembic hasn't had issues reported with this so far. Fixed long-lived bug in MySQL dialect where the maximum identifier length of 255 was too long for names of all types of constraints, not just indexes, all of which have a size limit of 64. As metadata naming conventions can create too-long names in this area, apply the limit to the identifier generator within the DDL compiler. Fixes: #5898 Change-Id: I79549474845dc29922275cf13321c07598dcea08
* Merge "Use schema._copy_expression() fully in column collection constraints"mike bayer2021-01-293-12/+32
|\
| * Use schema._copy_expression() fully in column collection constraintsGord Thompson2021-01-293-12/+32
| | | | | | | | | | | | | | | | | | | | Fixed issue where using :meth:`_schema.Table.to_metadata` (called :meth:`_schema.Table.tometadata` in 1.3) in conjunction with a PostgreSQL :class:`_postgresql.ExcludeConstraint` that made use of ad-hoc column expressions would fail to copy correctly. Fixes: #5850 Change-Id: I062480afb23f6f60962b7b55bc93f5e4e6ff05e4
* | Clarify Column.index / Column.unique parametersMike Bayer2021-01-291-12/+95
|/ | | | | | | | | | These parameters need to be more clear that they cause a constraint / index object to be generated. Clarify the rules by which this occurs and include contextual information about naming conventions as well. Change-Id: I8dc96ead4457215abed391fd1b9f732a1eef6e09 References: #5887
* Merge "Render NULL for bindparam w/ None value/literal_binds, warn"mike bayer2021-01-282-4/+13
|\
| * Render NULL for bindparam w/ None value/literal_binds, warnMike Bayer2021-01-282-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adjusted the "literal_binds" feature of :class:`_sql.Compiler` to render NULL for a bound parameter that has ``None`` as the value, either explicitly passed or omitted. The previous error message "bind parameter without a renderable value" is removed, and a missing or ``None`` value will now render NULL in all cases. Previously, rendering of NULL was starting to happen for DML statements due to internal refactorings, but was not explicitly part of test coverage, which it now is. While no error is raised, when the context is within that of a column comparison, and the operator is not "IS"/"IS NOT", a warning is emitted that this is not generally useful from a SQL perspective. Fixes: #5888 Change-Id: Id5939d8dbfb1156a9f8a7f7e76cf18327155331a
* | Allow Oracle CLOB/NCLOB/BLOB in returningMike Bayer2021-01-281-3/+47
|/ | | | | | | | | | | | | Fixed bug in Oracle dialect where retriving a CLOB/BLOB column via :meth:`_dml.Insert.returning` would fail as the LOB value would need to be read when returned; additionally, repaired support for retrieval of Unicode values via RETURNING under Python 2. As of yet, we still don't know how to reproduce the ORA-24813 error indicated in the issue. Fixes: #5812 Change-Id: I666f893e762dfa4d34dd2e324480565b226fb3a4
* Repair incorrect symbol PyDict_GetItemWithError for Python 2Mike Bayer2021-01-271-0/+34
| | | | | | | | | | | | * ensure on python 2 correct cflags to fail on undefined symbols take effect * fail for implicit function declaration * python 2 does not publish PyDict_GetItemWithError but has it as _PyDict_GetItemWIthError but only as of Python 2.7.12 Change-Id: I007509afddf7f44ca64e52fa9140be39f815fa7a
* Merge "Fix many spell glitches in docstrings and comments"mike bayer2021-01-2641-78/+78
|\
| * Fix many spell glitches in docstrings and commentsLele Gaifax2021-01-2441-79/+79
| | | | | | | | | | | | | | | | | | | | These were revealed by running `pylint --disable all --enable spelling --spelling-dict en_US` over all sources. Closes: #5868 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5868 Pull-request-sha: bb249195d92e3b806e81ecf1192d5a1b3cd5db48 Change-Id: I96080ec93a9fbd20ce21e9e16265b3c77f22bb14
* | Merge "Improve c implementation of immutabledict"mike bayer2021-01-261-7/+24
|\ \
| * | Improve c implementation of immutabledictFederico Caselli2021-01-251-7/+24
| | | | | | | | | | | | | | | | | | | | | Avoids using the call methods and instead uses the dict c interface. Fixes: #5871 Change-Id: I7a1211104da319b0793a149f1a24f9f95c9f6630
* | | Merge "Replace with_labels() and apply_labels() in ORM/Core"mike bayer2021-01-2612-62/+268
|\ \ \
| * | | Replace with_labels() and apply_labels() in ORM/CoreGord Thompson2021-01-2612-62/+268
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace :meth:`_orm.Query.with_labels` and :meth:`_sql.GenerativeSelect.apply_labels` with explicit getters and setters ``get_label_style`` and ``set_label_style`` to accommodate the three supported label styles: ``LABEL_STYLE_DISAMBIGUATE_ONLY`` (default), ``LABEL_STYLE_TABLENAME_PLUS_COL``, and ``LABEL_STYLE_NONE``. In addition, for Core and "future style" ORM queries, ``LABEL_STYLE_DISAMBIGUATE_ONLY`` is now the default label style. This style differs from the existing "no labels" style in that labeling is applied in the case of column name conflicts; with ``LABEL_STYLE_NONE``, a duplicate column name is not accessible via name in any case. For legacy ORM queries using :class:`_query.Query`, the table-plus-column names labeling style applied by ``LABEL_STYLE_TABLENAME_PLUS_COL`` continues to be used so that existing test suites and logging facilities see no change in behavior by default, however this style of labeling is no longer required for SQLAlchemy queries to function, as result sets are commonly matched to columns using a positional approach since SQLAlchemy 1.0. Within test suites, all use of apply_labels() / use_labels now uses the new methods. New tests added to test/sql/test_deprecations.py nad test/orm/test_deprecations.py to cover just the old apply_labels() method call. Tests in ORM that made explicit use apply_labels()/ etc. where it isn't needed for the ORM to work correctly use default label style now. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Fixes: #4757 Change-Id: I5fdcd2ed4ae8c7fe62f8be2b6d0e8f66409b6a54
* | | Fill-out dataclass-related attr resolutionMike Bayer2021-01-254-21/+132
|/ / | | | | | | | | | | | | | | | | Fixed issue where mixin attribute rules were not taking effect correctly for attributes pulled from dataclasses using the approach added in #5745. Fixes: #5876 Change-Id: I45099a42de1d9611791e72250fe0edc69bed684c
* | Merge "Limit AsyncAdaptedQueue to Python 3.7"mike bayer2021-01-241-10/+4
|\ \
| * | Limit AsyncAdaptedQueue to Python 3.7Federico Caselli2021-01-241-10/+4
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tests here are failing for python 3.6 due to the lack of asyncio.run(). It seems to be non-trivial to vendor a working version of this in Python 3.6 as the tests here are running it in alternate threads. The python documentation imports everything directly from the asyncio package, and it seems that py < 3.8 does not have the asyncio.exception module Closes: #5865 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5865 Pull-request-sha: 35cc1fa3f6ff962676f571ae30851f4b4d96762a Change-Id: I9398c9fb2aa87f3228ce2f59277de732091bd541
* | Merge "Remove errant assertion from unit of work"mike bayer2021-01-241-1/+0
|\ \ | |/ |/|
| * Remove errant assertion from unit of workMike Bayer2021-01-241-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed ORM unit of work regression where an errant "assert primary_key" statement interferes with primary key generation sequences that don't actually consider the columns in the table to use a real primary key constraint, instead using :paramref:`_orm.mapper.primary_key` to establish certain columns as "primary". Also remove errant "identity" requirement which does not seem to represent any current backend and is applied to test/sql/test_defaults.py->AutoIncrementTest, but these tests work on all backends. Fixes: #5867 Change-Id: I4502ca5079d824d7b4d055194947aa1a00effde7
* | Merge "include negation symbol in numeric default match"mike bayer2021-01-231-2/+2
|\ \ | |/ |/|
| * include negation symbol in numeric default matchMike Bayer2021-01-231-2/+2
| | | | | | | | | | | | | | | | Fixed bug where MySQL server default reflection would fail for numeric values with a negation symbol present. Fixes: #5860 Change-Id: I02cacdb4f9ec7d9113c27bf0d9214c4e14f4d4f9
* | Merge "remove __allowlist__"mike bayer2021-01-231-4/+0
|\ \
| * | remove __allowlist__Mike Bayer2021-01-231-4/+0
| | | | | | | | | | | | | | | | | | this testing element is not used Change-Id: I484c9a9f070122545fcdabe5a7f13b0bfca17023
* | | Merge "Improve error message when await_ call errors"mike bayer2021-01-232-4/+15
|\ \ \ | |/ / |/| |
| * | Improve error message when await_ call errorsFederico Caselli2021-01-212-4/+15
| |/ | | | | | | | | Fixes: #5832 Change-Id: Ia2ed8f1d1ec54e5f6e1a8f817a69446fdb3b7f6d
* | Merge "Removed some legacy terms in favor of modern equivalents. (D&I)"mike bayer2021-01-231-1/+1
|\ \
| * | Removed some legacy terms in favor of modern equivalents. (D&I)jonathan vanasco2021-01-211-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | Migrated testing fixture: `TestBase.__whitelist__` -> `TestBase.__allowlist__` Migrated tox commands from deprecated to current: `whitelist_externals` > `allowlist_externals` Migrated test_session: `blacklist` -> `blocklist` Change-Id: I395d5ee977ff22fa703276b9b873cc96c59b9a35
* | Fix a couple of bugs in the asyncio implementationFederico Caselli2021-01-214-16/+56
|/ | | | | | | | | | | | | Log an informative message if a connection is not closed and the gc is reclaiming it when using an async dpapi, that does not support running IO at that stage. The ``AsyncAdaptedQueue`` used by default on async dpapis should instantiate a queue only when it's first used to avoid binding it to a possibly wrong event loop. Fixes: #5823 Change-Id: Ibfc50e209b1937ae3d6599ae7997f028c7a92c33
* Revert "Implement support for functions as FROM with columns clause support"Mike Bayer2021-01-218-527/+75
| | | | | | | This reverts commit 05a31f2708590161d4b3b4c7ff65196c99b4a22b. Atom has this little button called "push" and just pushes to master, I wasn't even *on* master. oops
* Implement support for functions as FROM with columns clause supportMike Bayer2021-01-208-75/+527
| | | | | | | WIP Fixes: #3566 Change-Id: I5b093b72533ef695293e737eb75850b9713e5e03
* chain joins from SelectState context, not SelectMike Bayer2021-01-201-1/+14
| | | | | | | | | | | | | Fixed issue in new :meth:`_sql.Select.join` method where chaining from the current JOIN wasn't looking at the right state, causing an expression like "FROM a JOIN b <onclause>, b JOIN c <onclause>" rather than "FROM a JOIN b <onclause> JOIN c <onclause>". Added :meth:`_sql.Select.outerjoin_from` method to complement :meth:`_sql.Select.join_from`. Fixes: #5858 Change-Id: I1346ebe0963bbd1e4bf868650e3ee1d6d3072f04
* Merge "Document Table/Column accessors"mike bayer2021-01-202-2/+112
|\
| * Document Table/Column accessorsMike Bayer2021-01-192-2/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | As Sphinx will not allow us to add attributes to the .rst file while maintaining order, these have to be added as class-level attributes. Inlcude notes that "index" and "unique" parameters, while indicated by Column.index / Column.unique, do not actually indicate if the column is part of an index. Fixes: #5851 Change-Id: I18fbaf6c504c4b1005b4c51057f80397fb48b387
* | Merge "Disallow non-native psycopg2 Unicode in Python 3; update docs"mike bayer2021-01-191-56/+64
|\ \ | |/ |/|
| * Disallow non-native psycopg2 Unicode in Python 3; update docsFederico Caselli2021-01-191-56/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue where the psycopg2 dialect would silently pass the ``use_native_unicode=False`` flag without actually having any effect under Python 3, as the psycopg2 DBAPI uses Unicode unconditionally under Python 3. This usage now raises an :class:`_exc.ArgumentError` when used under Python 3. Added test support for Python 2. Additionally, added documentation for client_encoding parameter that may be passed to libpq directly via psycopg2. Change-Id: I40ddf6382c157fa9399c21f0e01064197ea100f8
* | Merge "``Identity`` implies ``nullable=False``."mike bayer2021-01-174-21/+51
|\ \
| * | ``Identity`` implies ``nullable=False``.Federico Caselli2021-01-164-21/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Altered the behavior of the :class:`_schema.Identity` construct such that when applied to a :class:`_schema.Column`, it will automatically imply that the value of :paramref:`_sql.Column.nullable` should default to ``False``, in a similar manner as when the :paramref:`_sql.Column.primary_key` parameter is set to ``True``. This matches the default behavior of all supporting databases where ``IDENTITY`` implies ``NOT NULL``. The PostgreSQL backend is the only one that supports adding ``NULL`` to an ``IDENTITY`` column, which is here supported by passing a ``True`` value for the :paramref:`_sql.Column.nullable` parameter at the same time. Fixes: #5775 Change-Id: I0516d506ff327cff35cda605e8897a27440e0373
* | | introduce generalized decorator to prevent invalid method callsMike Bayer2021-01-165-13/+72
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces the ``_exclusive_against()`` utility decorator that can be used to prevent repeated invocations of methods that typically should only be called once. An informative error message is now raised for a selected set of DML methods (currently all part of :class:`_dml.Insert` constructs) if they are called a second time, which would implicitly cancel out the previous setting. The methods altered include: :class:`_sqlite.Insert.on_conflict_do_update`, :class:`_sqlite.Insert.on_conflict_do_nothing` (SQLite), :class:`_postgresql.Insert.on_conflict_do_update`, :class:`_postgresql.Insert.on_conflict_do_nothing` (PostgreSQL), :class:`_mysql.Insert.on_duplicate_key_update` (MySQL) Fixes: #5169 Change-Id: I9278fa87cd3470dcf296ff96bb0fb17a3236d49d
* | Merge "Create explicit GC ordering between ConnectionFairy/ConnectionRecord"mike bayer2021-01-163-9/+55
|\ \
| * | Create explicit GC ordering between ConnectionFairy/ConnectionRecordMike Bayer2021-01-154-17/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue where connection pool would not return connections to the pool or otherwise be finalized upon garbage collection under pypy if the checked out connection fell out of scope without being closed. This is a long standing issue due to pypy's difference in GC behavior that does not call weakref finalizers if they are relative to another object that is also being garbage collected. A strong reference to the related record is now maintained so that the weakref has a strong-referenced "base" to trigger off of. Fixes: #5842 Change-Id: Id5448fdacb6cceaac1ea40b2fbc851f052ed8e86
* | | Merge "Guard against re-entrant autobegin in Core, ORM"mike bayer2021-01-163-5/+12
|\ \ \
| * | | Guard against re-entrant autobegin in Core, ORMMike Bayer2021-01-153-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed bug in "future" version of :class:`.Engine` where emitting SQL during the :meth:`.EngineEvents.do_begin` event hook would cause a re-entrant condition due to autobegin, including the recipe documented for SQLite to allow for savepoints and serializable isolation support. Fixed issue in new :class:`_orm.Session` similar to that of the :class:`_engine.Connection` where the new "autobegin" logic could be tripped into a re-entrant state if SQL were executed within the :meth:`.SessionEvents.after_transaction_create` event hook. Also repair the new "testing_engine" pytest fixture to set up for "future" engine appropriately, which wasn't working leading to the test_execute.py tests not using the future engine since recent f1e96cb0874927a475d0c11139. Fixes: #5845 Change-Id: Ib2432d8c8bd753e24be60720ec47affb2df15a4a
* | | | run handle error for commit/rollback fail and cancel transactionMike Bayer2021-01-152-6/+26
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed bug in asyncpg dialect where a failure during a "commit" or less likely a "rollback" should cancel the entire transaction; it's no longer possible to emit rollback. Previously the connection would continue to await a rollback that could not succeed as asyncpg would reject it. Fixes: #5824 Change-Id: I5a4916740c269b410f4d1a78ed25191de344b9d0
* | | Merge "Add missing requirements to suite tests"mike bayer2021-01-151-2/+8
|\ \ \ | |_|/ |/| |
| * | Add missing requirements to suite testsGord Thompson2021-01-151-2/+8
| | | | | | | | | | | | | | | Fixes: #5841 Change-Id: I53e8405e6ca8c3fd6909744632b76db724d9eb1f
* | | Merge "update execute() arg formats in modules and tests"mike bayer2021-01-1510-28/+42
|\ \ \ | |/ / |/| |
| * | update execute() arg formats in modules and testsMike Bayer2021-01-1510-28/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | continuing with producing a SQLAlchemy 1.4.0b2 that internally does not emit any of its own 2.0 deprecation warnings, migrate the *args and **kwargs passed to execute() methods that now must be a single list or dictionary. Alembic 1.5 is again waiting on this internal consistency to be present so that it can pass all tests with no 2.0 deprecation warnings. Change-Id: If6b792e57c8c5dff205419644ab68e631575a2fa
* | | Merge "Add mssql+turbodbc to external dialect list"mike bayer2021-01-151-0/+10
|\ \ \