summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing
Commit message (Collapse)AuthorAgeFilesLines
* Merge "2.0 removals: LegacyRow, connectionless execution, close_with_result" ↵mike bayer2021-10-313-13/+4
|\ | | | | | | into main
| * 2.0 removals: LegacyRow, connectionless execution, close_with_resultMike Bayer2021-10-313-13/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in order to remove LegacyRow / LegacyResult, we have to also lose close_with_result, which connectionless execution relies upon. also includes a new profiles.txt file that's all against py310, as that's what CI is on now. some result counts changed by one function call which was enough to fail the low-count result tests. Replaces Connectable as the common interface between Connection and Engine with EngineEventsTarget. Engine is no longer Connectable. Connection and MockConnection still are. References: #7257 Change-Id: Iad5eba0313836d347e65490349a22b061356896a
* | Merge "Remove deprecated dialects and drivers" into mainmike bayer2021-10-313-40/+4
|\ \
| * | Remove deprecated dialects and driversFederico Caselli2021-10-313-40/+4
| |/ | | | | | | | | Fixes: #7258 Change-Id: I3577f665eca04f2632b69bcb090f0a4ec9271db9
* | The ``has_table`` method now also checks viewsFederico Caselli2021-10-311-0/+26
|/ | | | | | | | | | | | The :meth:`_engine.Inspector.has_table` method will now consistently check for views of the given name as well as tables. Previously this behavior was dialect dependent, with PostgreSQL, MySQL/MariaDB and SQLite supporting it, and Oracle and SQL Server not supporting it. Third party dialects should also seek to ensure their :meth:`_engine.Inspector.has_table` method searches for views as well as tables for the given name. Fixes: #7161 Change-Id: I9e523c76741b19596c81ef577dc6f0823e44183b
* warnings removal, merge_resultMike Bayer2021-10-291-16/+0
| | | | | | | | | | | this is the last warning to remove. Also fixes some mistakes I made with the new Base20DeprecationWarning and LegacyAPIWarning classes created, where functions in deprecations.py were still hardcoded to RemovedIn20Warning. Change-Id: I9a6045ac9b813fd2f9668c4bc518c46a7774c6ef
* Merge "warnings: session.autocommit, subtransactions" into mainmike bayer2021-10-291-2/+0
|\
| * warnings: session.autocommit, subtransactionsMike Bayer2021-10-291-2/+0
| | | | | | | | Change-Id: I7eb7c87c9656f8043ea90d53897958afad2b8fe9
* | warnings: with_polymorphic()Mike Bayer2021-10-291-5/+0
|/ | | | | | | | Also clarifies a behavior of None/False for the selectable parameter to with_polymorphic() Fixes: #7262 Change-Id: I58c4004e0af227d3995e9ae2461470440f97f252
* Merge "Modernize tests - session_query_get" into mainmike bayer2021-10-291-1/+0
|\
| * Modernize tests - session_query_getGord Thompson2021-10-281-1/+0
| | | | | | | | | | Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: I92013aad471baf32df1b51b756e86d95449b5cfd
* | warnings: cascade_backrefsMike Bayer2021-10-281-2/+0
|/ | | | | | | this one is a little different in that the thing changing is the detection of a behavior, not an explicit API. Change-Id: Id142943a2b901b39fe9053d0120c1e820dc1a6d0
* Merge "deprecation warnings: with_parent, aliased, from_joinpoint" into mainmike bayer2021-10-272-4/+1
|\
| * deprecation warnings: with_parent, aliased, from_joinpointMike Bayer2021-10-272-4/+1
| | | | | | | | | | | | | | | | | | most of the work for aliased / from_joinpoint has been done already as I added all new tests for these and moved most aliased/from_joinpoint to test/orm/test_deprecations.py already Change-Id: Ia23e332dec183de17b2fb9d89d946af8d5e89ae7
* | Merge "Remove depractions:" into mainmike bayer2021-10-261-2/+0
|\ \ | |/ |/|
| * Remove depractions:Federico Caselli2021-10-261-2/+0
| | | | | | | | | | | | | | - Passing bind arguments to Session.execute - This Session located a target engine via bound metadata Change-Id: I916c8c4cff344ee5652fceac4dfd241dd8160f7b
* | warnings: select_entity_from()Mike Bayer2021-10-251-1/+0
| | | | | | | | Change-Id: I8c259e61134c38a1fa907c308068337473c82914
* | deprecation warnings: strings in loader options, join, with_parentMike Bayer2021-10-251-8/+0
|/ | | | | | | | | | | | | Repairs one in-library deprecation warning regarding mapper propagation of options raises maxfail to 250, as 25 is too low when we are trying to address many errors at once. the 25 was originally due to the fact that our fixtures would be broken after that many failures in most cases, which today should not be the case nearly as often. Change-Id: I26affddf42e2cae2aaf9561633e9b8cd431eb189
* Modernize tests - query_from_selfGord Thompson2021-10-171-1/+0
| | | | Change-Id: Ic14fdb5b6c49b668698de146bbafbd996da3d843
* Reflect table can reflect table with no columnsSumit Khanna2021-10-142-0/+64
| | | | | | | | | | | | | | | The :meth:`_engine.Inspector.reflect_table` method now supports reflecting tables that do not have user defined columns. This allows :meth:`_schema.MetaData.reflect` to properly complete reflection on databases that contain such tables. Currently, only PostgreSQL is known to support such a construct among the common database backends. Fixes: #3247 Closes: #7118 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7118 Pull-request-sha: cb8ce01957e9a1453290a7c2728af8c60ef55fa1 Change-Id: I906cebe17d13554d79086b92f3e1e51ffba3e818
* rename elements to mainMike Bayer2021-10-112-2/+2
| | | | | | | There are still some SQLite / MySQL specific occurrences of "master" but this is most of it. Change-Id: I0144c992e2f0207777e20e058b63a11c031986b9
* Enable tests of fetch/offset for mariadb>=10.6Federico Caselli2021-10-082-0/+10
| | | | | Fixes: #6999 Change-Id: I29cf3908a6c872611409a3e7256296314c81dea1
* Modernize tests - calling_mapper_directlyGord Thompson2021-09-303-33/+34
| | | | | | | | | | | | | a few changes for py2k: * map_imperatively() includes the check that a class is being sent, this was only working for mapper() before * the test suite didn't place the py2k "autouse" workaround in the correct order, seemingly, tried to adjust the per-test ordering setup in pytestplugin.py Change-Id: I4cc39630724e810953cfda7b2afdadc8b948e3c2
* remove declarative warningsMike Bayer2021-09-292-5/+1
| | | | | | | * sqlalchemy.ext.declarative names * declarative_base(bind) Change-Id: I0ca26894b224458b58e46504c5ff7b5d3031a829
* warn or deprecate for auto-aliasing in joinsMike Bayer2021-09-282-41/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An extra layer of warning messages has been added to the functionality of :meth:`_orm.Query.join` and the ORM version of :meth:`_sql.Select.join`, where a few places where "automatic aliasing" continues to occur will now be called out as a pattern to avoid, mostly specific to the area of joined table inheritance where classes that share common base tables are being joined together without using explicit aliases. One case emits a legacy warning for a pattern that's not recommended, the other case is fully deprecated. The automatic aliasing within ORM join() which occurs for overlapping mapped tables does not work consistently with all APIs such as ``contains_eager()``, and rather than continue to try to make these use cases work everywhere, replacing with a more user-explicit pattern is clearer, less prone to bugs and simplifies SQLAlchemy's internals further. The warnings include links to the errors.rst page where each pattern is demonstrated along with the recommended pattern to fix. * Improved the exception message generated when configuring a mapping with joined table inheritance where the two tables either have no foreign key relationships set up, or where they have multiple foreign key relationships set up. The message is now ORM specific and includes context that the :paramref:`_orm.Mapper.inherit_condition` parameter may be needed particularly for the ambiguous foreign keys case. * Add explicit support in the _expect_warnings() assertion for nested _expect_warnings calls * generalize the NoCache fixture, which we also need to catch warnings during compilation consistently * generalize the __str__() method for the HasCode mixin so all warnings and errors include the code link in their string Fixes: #6974 Change-Id: I84ed79ba2112c39eaab7973b6d6f46de7fa80842
* Relax the Python version check for `__class_getitem__` testslayday2021-09-191-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | <!-- Provide a general summary of your proposed changes in the Title field above --> ### Description `__class_getitem__` to support generics was introduced in Python 3.7. In 3.9 some built-ins were made generic but the functionality for user-defined classes has been there since 3.7. ### 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: #7049 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7049 Pull-request-sha: 7bd16d416db010e7140313fe326861cc263b8864 Change-Id: I4f45b9585d263636e613cc5c86e710fa31c7d283
* Surface driver connection object when using a proxied dialectFederico Caselli2021-09-172-6/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | Improve the interface used by adapted drivers, like the asyncio ones, to access the actual connection object returned by the driver. The :class:`_engine._ConnectionRecord` and :class:`_engine._ConnectionFairy` now have two new attributes: * ``dbapi_connection`` always represents a DBAPI compatible object. For pep-249 drivers, this is the DBAPI connection as it always has been, previously accessed under the ``.connection`` attribute. For asyncio drivers that SQLAlchemy adapts into a pep-249 interface, the returned object will normally be a SQLAlchemy adaption object called :class:`_engine.AdaptedConnection`. * ``driver_connection`` always represents the actual connection object maintained by the third party pep-249 DBAPI or async driver in use. For standard pep-249 DBAPIs, this will always be the same object as that of the ``dbapi_connection``. For an asyncio driver, it will be the underlying asyncio-only connection object. The ``.connection`` attribute remains available and is now a legacy alias of ``.dbapi_connection``. Fixes: #6832 Change-Id: Ib72f97deefca96dce4e61e7c38ba430068d6a82e
* Add `asyncmy` supportlong2ice2021-09-171-1/+1
| | | | | | | | | | | | | | | Added initial support for the ``asyncmy`` asyncio database driver for MySQL and MariaDB. This driver is very new, however appears to be the only current alternative to the ``aiomysql`` driver which currently appears to be unmaintained and is not working with current Python versions. Much thanks to long2ice for the pull request for this dialect. Fixes: #6993 Closes: #7000 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7000 Pull-request-sha: f7d6c811fc72324a83c8af635bbca8b268b0098e Change-Id: I4ef54b43334feff7e3a710fc4de6821437f3bb68
* Fix various lib / test / examples typos (#7017)Kevin Kirsche2021-09-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fix: lib/sqlalchemy/sql/lambdas.py * fix: lib/sqlalchemy/sql/compiler.py * fix: lib/sqlalchemy/sql/selectable.py * fix: lib/sqlalchemy/orm/relationships.py * fix: lib/sqlalchemy/dialects/mssql/base.py * fix: lib/sql/test_compiler.py * fix: lib/sqlalchemy/testing/requirements.py * fix: lib/sqlalchemy/orm/path_registry.py * fix: lib/sqlalchemy/dialects/postgresql/psycopg2.py * fix: lib/sqlalchemy/cextension/immutabledict.c * fix: lib/sqlalchemy/cextension/resultproxy.c * fix: ./lib/sqlalchemy/dialects/oracle/cx_oracle.py * fix: examples/versioned_rows/versioned_rows_w_versionid.py * fix: examples/elementtree/optimized_al.py * fix: test/orm/test_attribute.py * fix: test/sql/test_compare.py * fix: test/sql/test_type_expression.py * fix: capitalization in test/dialect/mysql/test_compiler.py * fix: typos in test/dialect/postgresql/test_reflection.py * fix: typo in tox.ini comment * fix: typo in /lib/sqlalchemy/orm/decl_api.py * fix: typo in test/orm/test_update_delete.py * fix: self-induced typo * fix: typo in test/orm/test_query.py * fix: typos in test/dialect/mssql/test_types.py * fix: typo in test/sql/test_types.py
* Merge "Modernize tests - remaining DML"mike bayer2021-09-101-7/+0
|\
| * Modernize tests - remaining DMLGord Thompson2021-08-121-7/+0
| | | | | | | | | | | | | | dialect_keyword_arguments preserve_parameter_order Change-Id: I92efce4689635ef4b68fc02100c0c10aff9a0edc
* | ensure pysqlite dialect enumerates correct isolation levelsMike Bayer2021-08-301-0/+4
| | | | | | | | | | | | | | | | | | Fixed bug where the error message for SQLite invalid isolation level on the pysqlite driver would fail to indicate that "AUTOCOMMIT" is one of the valid isolation levels. Change-Id: Icbceab9a28af6a560859761fa92320b5473269a9 References: #6959
* | fix spelling (#6926)William Maio2021-08-241-1/+1
| |
* | send user defined options from the current queryMike Bayer2021-08-171-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Revised the means by which the :attr:`_orm.ORMExecuteState.user_defined_options` accessor receives :class:`_orm.UserDefinedOption` and related option objects from the context, with particular emphasis on the "selectinload" on the loader strategy where this previously was not working; other strategies did not have this problem. The objects that are associated with the current query being executed, and not that of a query being cached, are now propagated unconditionally. This essentially separates them out from the "loader strategy" options which are explicitly associated with the compiled state of a query and need to be used in relation to the cached query. The effect of this fix is that a user-defined option, such as those used by the dogpile.caching example as well as for other recipes such as defining a "shard id" for the horizontal sharing extension, will be correctly propagated to eager and lazy loaders regardless of whether a cached query was ultimately invoked. Fixes: #6887 Change-Id: Ieaae5b01c85de26ea732ebd625e6e5823a470492
* | rewrite _extra_criteria in selectinload; propagate correctly to LoadMike Bayer2021-08-171-3/+21
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue in :func:`_orm.selectinload` where use of the new :meth:`_orm.PropComparator.and_` feature within options that were nested more than one level deep would fail to update bound parameter values that were in the nested criteria, as a side effect of SQL statement caching. Implementation adds a new step that rewrites the parameters inside of all _extra_criteria when invoking selectinload as well as subqueryload. Additionally, changed how Load() gets "extra_criteria", in that it pulls it from UnboundLoad._extra_criteria instead of re-fetching it from the path elements, which are not updated by this new step. This patch also builds upon the removal of lambda queries for use in loader strategies in #6889. lambdas made this issue much more difficult to diagnose. An attempt to reintroduce lambdas here after finally identifying the "extra_criteria" issue above showed that lambdas still impact the assertsql fixture, meaning we have a statement structure that upon calling .compile() still delivers stale data due to lambdas, even if caching is turned off, and the non-cached test was still failing due to stale data within the lambdas. This is basically the complexity that #6889 fixes and as there's no real performance gain to using lambdas in these strategies on top of the existing statement caching that does most of the work, it should be much less likely going forward to have as many deeply confusing issues as we've had within selectinload/lazyload in the 1.4 series. Fixes: #6881 Change-Id: I919c079d2ed06125def5f8d6d81f3f305e158c04
* Merge "limit greenlet dependency to pypi-listed platforms"mike bayer2021-08-111-0/+12
|\
| * limit greenlet dependency to pypi-listed platformsMike Bayer2021-08-111-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The setup requirements have been modified such ``greenlet`` is a default requirement only for those platforms that are well known for ``greenlet`` to be installable and for which there is already a pre-built binary on pypi; the current list is ``x86_64 aarch64 ppc64le amd64 win32``. For other platforms, greenlet will not install by default, which should enable installation and test suite running of SQLAlchemy 1.4 on platforms that don't support ``greenlet``, excluding any asyncio features. In order to install with the ``greenlet`` dependency included on a machine architecture outside of the above list, the ``[asyncio]`` extra may be included by running ``pip install sqlalchemy[asyncio]`` which will then attempt to install ``greenlet``. Additionally, the test suite has been repaired so that tests can complete fully when greenlet is not installed, with appropriate skips for asyncio-related tests. Fixes: #6136 Change-Id: I8f3a1c00a4a8b6a273484af1da1f7aaadf588ae7
* | Merge "Modernize tests - dml_values"mike bayer2021-08-071-2/+0
|\ \
| * | Modernize tests - dml_valuesGord Thompson2021-07-261-2/+0
| |/ | | | | | | Change-Id: Ida86ed40c43d91813151621b847376976773a5f9
* | Merge "Modernize tests - remaining core SQL"mike bayer2021-08-071-8/+0
|\ \
| * | Modernize tests - remaining core SQLGord Thompson2021-07-231-8/+0
| | | | | | | | | | | | Change-Id: I7d8c1f451c32dea28173b2206e66db1d0927fccf
* | | Provide default for implicitly_named_constraintsGord Thompson2021-08-031-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | … so third-party dialect testing won't fail with: "AttributeError: 'Requirements' object has no attribute 'implicitly_named_constraints'" Change-Id: Iafa3e36f3dd169c338dd6eaee21c73aa35e854cc
* | | Merge "Support generics in code to allow Column[int] etc"mike bayer2021-07-291-0/+5
|\ \ \ | |_|/ |/| |
| * | Support generics in code to allow Column[int] etcFederico Caselli2021-07-271-0/+5
| |/ | | | | | | | | | | Fixes: #6804 Fixes: #6759 Change-Id: Ie7f32c38a22dbfa059b5709b883ff464b16031ae
* | Modernize tests - dml_whereclauseGord Thompson2021-07-262-6/+9
|/ | | | | | | | | Fixed issue where the unit of work would internally use a 2.0-deprecated SQL expression form, emitting a deprecation warning when SQLALCHEMY_WARN_20 were enabled. Fixes: #6812 Change-Id: I0a031e728527a1c3382848b6ddc793939362b128
* Merge "Modernize tests - legacy_select"mike bayer2021-07-212-5/+3
|\
| * Modernize tests - legacy_selectGord Thompson2021-07-212-5/+3
| | | | | | | | Change-Id: I04057cc3d3f93de60b02999803e2ba6a23cdf68d
* | dont warn for dictionary passed positionallyMike Bayer2021-07-213-19/+12
|/ | | | | | | | | | | | | Fixed issue where use of the :paramref:`_sql.case.whens` parameter passing a dictionary positionally and not as a keyword argument would emit a 2.0 deprecation warning, referring to the deprecation of passing a list positionally. The dictionary format of "whens", passed positionally, is still supported and was accidentally marked as deprecated. Removes warning filter for case statement. Fixes: #6786 Change-Id: I8efd1882563773bec89ae5e34f0dfede77fc4683
* limit None->null coercion to not occur with crudMike Bayer2021-07-151-18/+73
| | | | | | | | | | | | | | | | | | | Fixed issue where type-specific bound parameter handlers would not be called upon in the case of using the :meth:`_sql.Insert.values` method with the Python ``None`` value; in particular, this would be noticed when using the :class:`_types.JSON` datatype as well as related PostgreSQL specific types such as :class:`_postgresql.JSONB` which would fail to encode the Python ``None`` value into JSON null, however the issue was generalized to any bound parameter handler in conjunction with this specific method of :class:`_sql.Insert`. The issue with coercions forcing out ``null()`` may still impact SQL expression usage as well; the change here is limited to crud as the behavior there is relevant to some use cases, which may need to be evaluated separately. Fixes: #6770 Change-Id: If53edad811b37dada7578a89daf395628db058a6
* Modernize tests - unionGord Thompson2021-07-121-1/+0
| | | | Change-Id: I2ccb714a249350f23e2b5f78f5f9ffb0d4f7efb0