summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Merge "Modernize tests - select(whereclause)"mike bayer2021-07-122-9/+2
|\
| * Modernize tests - select(whereclause)Gord Thompson2021-07-042-9/+2
| | | | | | | | Change-Id: I306cfbea9920b35100e3087dcc21d7ffa6c39c55
* | Replace all http:// links to https://Federico Caselli2021-07-0417-17/+17
|/ | | | | | Also replace http://pypi.python.org/pypi with https://pypi.org/project Change-Id: I84b5005c39969a82140706472989f2a30b0c7685
* Modernize testsGord Thompson2021-07-031-1/+0
| | | | | | Eliminate engine.execute() and engine.scalar() Change-Id: I99f76d0e615ddebab2da4fd07a40a0a2796995c7
* Modernize tests - Connection.connectGord Thompson2021-06-261-1/+0
| | | | Change-Id: I61639dc2d7e7bcae6c53e2a15680b11fce3efa5d
* turn pg provision error into a warningMike Bayer2021-06-262-0/+11
| | | | | | | | | | | | | We haven't had any real cases of the PG "cant drop tables" condition since this error was first introduced; instead we seem to get it for a non-critical query during pool reconnect tests, and I have not been able to isolate what is causing it. Therefore turn the error into a new class of warning that can emit within the test suite without failing the test, so that if we do get a real PG drop timeout, the warning will be there to show us what the query was in which it was stuck. Change-Id: I1a9b3c4f7a25b7b9c1af722a721fc44ad5575b0f
* init extra_criteria_entities in fromstatement w/ DMLMike Bayer2021-06-071-4/+4
| | | | | | | | | | | | Fixed issue in experimental "select ORM objects from INSERT/UPDATE" use case where an error was raised if the statement were against a single-table-inheritance subclass. Additionally makes some adjustments in the SQL assertion fixture to test a FromStatement w/ DML. Fixes: #6591 Change-Id: I53a627ab18a01dc6d9b5037e28312a1177891327
* delete exception traceback in _expect_raisesMike Bayer2021-06-021-0/+7
| | | | | | | | | | a new segfault is observed in python 3.10.0b2 in conjunction with asyncio and possibly greenlet. Ensuring the traceback object is deleted from scope here, which is a good idea anyway, apparently seems to resolve the issue. Change-Id: Ia83bafb088ef19853044f1d436db259cbfd1e5f4 References: https://github.com/python-greenlet/greenlet/issues/242
* temporarily disable test_no_attach_to_event_loopMike Bayer2021-06-021-2/+10
| | | | | | | | | | | | | | this test currently causes the test suite to hang; it previously was not actually running the worker thread as the testing_engine() fixture was rejecting the "transfer_staticpool" keyword argument. as we seem to have a greenlet-related segfault in 3.10.0b2 I am going to have to get the greenlet devs to run the test suite so i want to get anything not totally smooth out of it for the moment. Change-Id: Ib453d0bc23ca013598bc80ff29e5da496771d5b1
* Remove pytest warning filterFederico Caselli2021-05-281-6/+0
| | | | Change-Id: Ie18b66e4a8d59be12ee549347bd508036282c1c9
* get tests to pass on python 3.10Mike Bayer2021-05-271-2/+11
| | | | | | | | | | | | | | Resolved various deprecation warnings which were appearing as of Python version 3.10.0b1. block aiomysql on python 3.10 as they are using the "loop" argument that's removed sqlcipher-binary has no builds on 3.10, block it for 3.10 Fixes: #6540 Fixes: #6543 Change-Id: Iec1e3881fb289878881ae043b1a18c3ecdf5f077
* Provide primary key values for data in tests that aren't about primary keys.Jim Fulton2021-05-243-17/+33
| | | | | | | | | | | | | | | (message written by Mike) some backends such as BigQuery have no autoincrement mechanism at all. while we would like to pursue a strategy where provisioning.py could provide for an in-Python sequence generator, at least remove the need for autoincrement in suite tests that don't need it. Fixes: #6469 Closes: #6504 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6504 Pull-request-sha: c075014ef7de33e6eb3f389d24251ba184655e0b Change-Id: I98e237a38417b68c87d0201717205d7655b1f44e
* Merge "Remove pep484 type comments from the code"mike bayer2021-05-182-17/+2
|\
| * Remove pep484 type comments from the codeFederico Caselli2021-05-162-17/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Current effort is around the stub package, and having typing in two places makes thing worse, since the types here are usually outdated compared to the version in the stubs. Once v2 gets under way we can start consolidating the types here. Fixes: #6461 Change-Id: I7132a444bd7138123074bf5bc664b4bb119a85ce
* | Use type_ when creating literals in _LiteralRoundTripFixtureJim Fulton2021-05-171-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #6496 by passing the `type_` argument passed to `run` to `literal`. 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: #6497 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6497 Pull-request-sha: 5f82408b2c25c7593f7202533dde4e29f045de5d Change-Id: Ieed822c157f91d95fe3a07ea4482a36777539c35
* Update black flak8 and zimportsFederico Caselli2021-05-121-1/+1
| | | | Change-Id: I488c9557eda390e4a88319affd4c8813ee274f80
* Merge "don't cache TypeDecorator by default"mike bayer2021-05-061-0/+2
|\
| * don't cache TypeDecorator by defaultMike Bayer2021-05-061-0/+2
| | | | | | | | | | | | | | | | | | | | The :class:`.TypeDecorator` class will now emit a warning when used in SQL compilation with caching unless the ``.cache_ok`` flag is set to ``True`` or ``False``. ``.cache_ok`` indicates that all the parameters passed to the object are safe to be used as a cache key, ``False`` means they are not. Fixes: #6436 Change-Id: Ib1bb7dc4b124e38521d615c2e2e691e4915594fb
* | Merge "unify transactional context managers"mike bayer2021-05-061-0/+144
|\ \
| * | unify transactional context managersMike Bayer2021-05-051-0/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Applied consistent behavior to the use case of calling ``.commit()`` or ``.rollback()`` inside of an existing ``.begin()`` context manager, with the addition of potentially emitting SQL within the block subsequent to the commit or rollback. This change continues upon the change first added in :ticket:`6155` where the use case of calling "rollback" inside of a ``.begin()`` contextmanager block was proposed: * calling ``.commit()`` or ``.rollback()`` will now be allowed without error or warning within all scopes, including that of legacy and future :class:`_engine.Engine`, ORM :class:`_orm.Session`, asyncio :class:`.AsyncEngine`. Previously, the :class:`_orm.Session` disallowed this. * The remaining scope of the context manager is then closed; when the block ends, a check is emitted to see if the transaction was already ended, and if so the block returns without action. * It will now raise **an error** if subsequent SQL of any kind is emitted within the block, **after** ``.commit()`` or ``.rollback()`` is called. The block should be closed as the state of the executable object would otherwise be undefined in this state. Fixes: #6288 Change-Id: I8b21766ae430f0fa1ac5ef689f4c0fb19fc84336
* | | Merge "Parenthesize for empty not in"mike bayer2021-05-051-0/+20
|\ \ \ | |_|/ |/| |
| * | Parenthesize for empty not inMike Bayer2021-05-051-0/+20
| |/ | | | | | | | | | | | | | | | | | | | | | | | | Fixed regression caused by the "empty in" change just made in :ticket:`6397` 1.4.12 where the expression needs to be parenthesized for the "not in" use case, otherwise the condition will interfere with the other filtering criteria. also amends StrSQLCompiler to use the newer "empty IN" style for its compilation process. Fixes: #6428 Change-Id: I182a552fc0d3065a9e38c0f4ece2deb143735c36
* | mypy: load extra test files from environment variableMaico Timmerman2021-05-041-0/+9
|/ | | | | | | | | | Add --mypy-extra-test-path parameter to pytest execution to list extra directories to load test files from. This enables the stubs repo to load this plugin and specify it's own test directory to run mypy tests. Supports both single file tests and incremental tests based on patch files. Change-Id: Id6424ff15b2f527183b9713384df3d625a8e6eb8
* Merge "Support stream_results in the pg8000 dialect"mike bayer2021-05-021-0/+2
|\
| * Support stream_results in the pg8000 dialectTony Locke2021-04-291-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Description This change adds support for stream_results for the pg8000 dialect by adding a server side cursor. The server-side cursor is a wrapper around a standard DBAPI cursor, and uses the SQL-level cursors. This is being discussed in issue https://github.com/sqlalchemy/sqlalchemy/issues/6198 and this pull request is really to give a concrete example of what I was suggesting. ### 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: #6356 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6356 Pull-request-sha: 071e118a6b09a26c511b39b0d589ebd2de8d508c Change-Id: Id1a865adf0ff64294c71814681f5b4d593939db6
* | Merge "Use non-subquery form for empty IN"mike bayer2021-04-291-52/+135
|\ \ | |/ |/|
| * Use non-subquery form for empty INMike Bayer2021-04-291-52/+135
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Revised the "EMPTY IN" expression to no longer rely upon using a subquery, as this was causing some compatibility and performance problems. The new approach for selected databases takes advantage of using a NULL-returning IN expression combined with the usual "1 != 1" or "1 = 1" expression appended by AND or OR. The expression is now the default for all backends other than SQLite, which still had some compatibility issues regarding tuple "IN" for older SQLite versions. Third party dialects can still override how the "empty set" expression renders by implementing a new compiler method ``def visit_empty_set_op_expr(self, type_, expand_op)``, which takes precedence over the existing ``def visit_empty_set_expr(self, element_types)`` which remains in place. Fixes: #6258 Fixes: #6397 Change-Id: I2df09eb00d2ad3b57039ae48128fdf94641b5e59