summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Create a real type for Tuple() and handle appropriately in compilerMike Bayer2020-08-175-4/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | Improved the :func:`_sql.tuple_` construct such that it behaves predictably when used in a columns-clause context. The SQL tuple is not supported as a "SELECT" columns clause element on most backends; on those that do (PostgreSQL, not surprisingly), the Python DBAPI does not have a "nested type" concept so there are still challenges in fetching rows for such an object. Use of :func:`_sql.tuple_` in a :func:`_sql.select` or :class:`_orm.Query` will now raise a :class:`_exc.CompileError` at the point at which the :func:`_sql.tuple_` object is seen as presenting itself for fetching rows (i.e., if the tuple is in the columns clause of a subquery, no error is raised). For ORM use,the :class:`_orm.Bundle` object is an explicit directive that a series of columns should be returned as a sub-tuple per row and is suggested by the error message. Additionally ,the tuple will now render with parenthesis in all contexts. Previously, the parenthesization would not render in a columns context leading to non-defined behavior. As part of this change, Tuple receives a dedicated datatype which appears to allow us the very desirable change of removing the bindparam._expanding_in_types attribute as well as ClauseList._tuple_values (which might already have not been needed due to #4645). Fixes: #5127 Change-Id: Iecafa0e0aac2f1f37ec8d0e1631d562611c90200
* Dont run py3k-only test files on Python 3.5Mike Bayer2020-08-131-1/+4
| | | | | | | these are failing on the github runners because 3.5 doesnt have the async keywords. Change-Id: I9c58d38f8d7595313b7648b9840b334da8238bd0
* Merge "Implement rudimentary asyncio support w/ asyncpg"mike bayer2020-08-1414-37/+691
|\
| * Implement rudimentary asyncio support w/ asyncpgMike Bayer2020-08-1314-37/+691
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using the approach introduced at https://gist.github.com/zzzeek/6287e28054d3baddc07fa21a7227904e We can now create asyncio endpoints that are then handled in "implicit IO" form within the majority of the Core internals. Then coroutines are re-exposed at the point at which we call into asyncpg methods. Patch includes: * asyncpg dialect * asyncio package * engine, result, ORM session classes * new test fixtures, tests * some work with pep-484 and a short plugin for the pyannotate package, which seems to have so-so results Change-Id: Idbcc0eff72c4cad572914acdd6f40ddb1aef1a7d Fixes: #3414
* | Merge "Further fixes for ticket 5470"mike bayer2020-08-131-0/+95
|\ \ | |/ |/|
| * Further fixes for ticket 5470Mike Bayer2020-08-131-0/+95
| | | | | | | | | | | | | | | | | | | | The fix for #5470 didn't actually take into account that the "distinct" logic in query was also doubling up the criteria. Added many more tests. the 1.3 version here will be different than 1.4 as the regression is not quite the same. Fixes: #5470 Change-Id: I16a23917cab175761de9c867d9d9ac55031d9b97
* | Use importlib_metadata; add namespace for mariadbMike Bayer2020-08-132-67/+91
|/ | | | | | | | | | | | | | | | | | | | | | | | | | The ``importlib_metadata`` library is used to scan for setuptools entrypoints rather than pkg_resources. as importlib_metadata is a small library that is included as of Python 3.8, the compatibility library is installed as a dependency for Python versions older than 3.8. Unfortunately setuptools "attr:" is broken because it tries to import the module; seems like this is fixed as part of https://github.com/pypa/setuptools/pull/1753 however this is too recent to rely upon for now. Added a new dialect token "mariadb" that may be used in place of "mysql" in the :func:`_sa.create_engine` URL. This will deliver a MariaDB dialect subclass of the MySQLDialect in use that forces the "is_mariadb" flag to True. The dialect will raise an error if a server version string that does not indicate MariaDB in use is received. This is useful for MariaDB-specific testing scenarios as well as to support applications that are hardcoding to MariaDB-only concepts. As MariaDB and MySQL featuresets and usage patterns continue to diverge, this pattern may become more prominent. Fixes: #5400 Fixes: #5496 Change-Id: I330815ebe572b6a9818377da56621397335fa702
* Sweep through UPDATE ordered_values a second timeMike Bayer2020-08-121-9/+104
| | | | | | | | | | | | The fix in 180ae7c1a53385f72b0047496ac001ec5099cc3e didn't do much as the code was not preserving parameter order at all, in fact. Reworked stmt_parameters to be delivered in the correct order up front and preserve throughout crud.py which was not being done at all before. Fixes: #5510 Change-Id: I0795c71df73005a25d1bbf216732d41b41e11a5f
* Merge "Break scalars() and mappings() into separate objects"mike bayer2020-08-122-18/+120
|\
| * Break scalars() and mappings() into separate objectsMike Bayer2020-08-122-18/+120
| | | | | | | | | | | | | | | | | | | | | | | | The issue of Result.fetchXXX() methods returning Row objects unless filtering is applied will not provide a clear enough API story when type annotations are applied, so break out scalars/mappings into separate wrapper objects. this makes some things more intuitive and other things a little more bumpy. however the return type story is now clearer. Fixes: #5503 Change-Id: I629a061823179680dc0723559183859a67ea4db1
* | Merge "Fix mysql CREATE TABLE / COLLATE issue"mike bayer2020-08-121-0/+28
|\ \ | |/ |/|
| * Fix mysql CREATE TABLE / COLLATE issueGord Thompson2020-08-091-0/+28
| | | | | | | | | | Fixes: #5411 Change-Id: Ib0c53f5ed3f9d3ff0586580c9a9cce73b4b870f4
* | Correct for update.ordered_values() and use in new testMike Bayer2020-08-111-1/+3
|/ | | | | | | | | | The test for the parameter fix in c0685e5f41 was not working deterministically on Python 2, so use ordered_values(), however a second issue in ordered_values() was assuming each element was a column, so also test for array-assignment expressions with ordered_values. Change-Id: I944c72a52700ffb4ab5ae1a83ae21f1efc84b505
* render INSERT/UPDATE column expressions up front; pass stateMike Bayer2020-08-081-1/+67
| | | | | | | | | | | | | | | | | | | | | | Fixes related to rendering of complex UPDATE DML which was not correctly preserving positional parameter order in conjunction with DML features that are only known to work on the PostgreSQL database. Both pg8000 and asyncpg use positional parameters which is why these issues are suddenly apparent. crud.py now takes on the task of rendering the column expressions for SET or VALUES so that for the very unusual case that the column expression is a compound expression that includes a bound parameter (namely an array index), the bound parameter order is preserved. Additionally, crud.py passes through the positional_names keyword argument into bindparam_string() which is necessary when CTEs are being rendered, as PG supports complex CTE / INSERT / UPDATE scenarios. Change-Id: I7f03920500e19b721636b84594de78a5bfdcbc82
* Don't link on_connect to first_connect event handlerMike Bayer2020-08-071-0/+69
| | | | | | | | | | | | | Adjusted the dialect initialization process such that the :meth:`_engine.Dialect.on_connect` is not called a second time on the first connection. The hook is called first, then the :meth:`_engine.Dialect.initialize` is called if that connection is the first for that dialect, then no more events are called. This eliminates the two calls to the "on_connect" function which can produce very difficult debugging situations. Fixes: #5497 Change-Id: Icefc2e884e30ee7b4ac84b99dc54bf992a6085e3
* Merge "Add complete platform data to profiling data"mike bayer2020-08-071-570/+570
|\
| * Add complete platform data to profiling dataFederico Caselli2020-08-071-570/+570
| | | | | | | | | | | | | | | | | | Initially to distinsuish between arm and x86_64 architecture, expand out the profile key to include machine, system, python impl in all cases. Ref: #5436 Change-Id: I7e48f0462ba7d9c680b2dac45ce7b0cf709b9b22
* | Merge "Pass schema_translate_map from DDLCompiler to SQLCompiler"mike bayer2020-08-071-0/+77
|\ \ | |/ |/|
| * Pass schema_translate_map from DDLCompiler to SQLCompilerMike Bayer2020-08-071-0/+77
| | | | | | | | | | | | | | | | | | | | | | | | Fixed issue where the :paramref:`_engine.Connection.execution_options.schema_translate_map` feature would not take effect when the :meth:`_schema.Sequence.next_value` function function for a :class:`_schema.Sequence` were used in the :paramref:`_schema.Column.server_default` parameter and the create table DDL were emitted. Fixes: #5500 Change-Id: I74a9fa13d22749d06c8202669f9ea220d9d984d9
* | base all_orm_descriptors ordering on cls.__dict__ + cls.__mro__Mike Bayer2020-08-061-0/+133
|/ | | | | | | | | | | | | Adjusted the workings of the :meth:`_orm.Mapper.all_orm_descriptors` accessor to represent the attributes in the order that they are located in a deterministic way, assuming the use of Python 3.6 or higher which maintains the sorting order of class attributes based on how they were declared. This sorting is not guaranteed to match the declared order of attributes in all cases however; see the method documentation for the exact scheme. Fixes: #5494 Change-Id: I6ee8d4ace3eb8b3f7c9c0f2a3d7e27b5f62abfd3
* Merge "Documentation updates for 1.4"mike bayer2020-08-061-0/+9
|\
| * Documentation updates for 1.4Mike Bayer2020-08-051-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * major additions to 1.4 migration doc; removed additional verbosity regarding caching methodology and reorganized the doc to present itself more as a "what's changed" guide * as we now have a path for asyncio, update that doc so that we aren't spreading obsolete information * updates to the 2.0 migration guide with latest info, however this is still an architecture doc and not a migration guide yet, will need further rework. * start really talking about 1.x vs. 2.0 style everywhere. Querying is most of the docs so this is going to be a prominent theme, start getting it to fit in * Add introductory documentation for ORM example sections as these are too sparse * new documentation for do_orm_execute(), many separate sections, adding deprecation notes to before_compile() and similar * new example suites to illustrate do_orm_execute(), with_loader_criteria() * modernized horizontal sharding examples and added a separate example to distinguish between multiple databases and single database w/ multiple tables use case * introducing DEEP ALCHEMY, will use zzzeeksphinx 1.1.6 * no name for the alchemist yet however the dragon's name is Flambé Change-Id: Id6b5c03b1ce9ddb7b280f66792212a0ef0a1c541
* | Merge "Implement relationship AND criteria; global loader criteria"mike bayer2020-08-068-2/+1188
|\ \ | |/
| * Implement relationship AND criteria; global loader criteriaMike Bayer2020-08-058-2/+1188
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added the ability to add arbitrary criteria to the ON clause generated by a relationship attribute in a query, which applies to methods such as :meth:`_query.Query.join` as well as loader options like :func:`_orm.joinedload`. Additionally, a "global" version of the option allows limiting criteria to be applied to particular entities in a query globally. Documentation is minimal at this point, new examples will be coming in a subsequent commit. Some adjustments to execution options in how they are represented in the ORMExecuteState as well as well as a few ORM tests that forgot to get merged in a preceding commit. Fixes: #4472 Change-Id: I2b8fc57092dedf35ebd16f6343ad0f0d7d332beb
* | Merge "Fixes for MySQL 8"mike bayer2020-08-062-5/+19
|\ \ | |/ |/|
| * Fixes for MySQL 8Mike Bayer2020-08-052-5/+19
| | | | | | | | | | | | | | | | | | | | MySQL 8.0.19 has some changes to how it reports on display widths for int types (seems like it omits it in some cases), and also no longer cares about the length for YEAR. Another adjustment to the ordering of constraints reported in one case also. At least one CI machine is at 8.0.21 now. Change-Id: Ie2101bed3ad75dcbb62cd05abe95ef14ad895cf5
* | Convert lazy loader, selectinload, load_on_ident to lambda statementsMike Bayer2020-08-056-831/+169
|/ | | | | | | | | Building on newly robust lambdas in I29a513c98917b1d503abfdd61e6b6e8800851aa8, convert key loading off of the "baked" system so that baked is no longer used by the ORM. Change-Id: I3abfb45dd6e50f84f29d39434caa0b550ce27864
* Robustness for lambdas, lambda statementsMike Bayer2020-08-054-10/+585
| | | | | | | | | | | | | | | | | | | | in order to accommodate relationship loaders with lambda caching, a lot more is needed. This is a full refactor of the lambda system such that it now has two levels of caching; the first level caches what can be known from the __code__ element, then the next level of caching is against the lambda itself and the contents of __closure__. This allows for the elements inside the lambdas, like columns and entities, to change and then be part of the cache key. Lazy/selectinloads' use of baked queries had to add distinct cache key elements, which was attempted here but overall things needed to be more robust than that. This commit is broken out from the very long and sprawling commit at Id6b5c03b1ce9ddb7b280f66792212a0ef0a1c541 . Change-Id: I29a513c98917b1d503abfdd61e6b6e8800851aa8
* Add MariaDB 1927 to is_disconnect codesMike Bayer2020-08-051-0/+2
| | | | | | | | | Added MariaDB code 1927 to the list of "disconnect" codes, as recent MariaDB versions apparently use this code when the database server was stopped. Fixes: #5493 Change-Id: I63f1d692f36cb0411ead278556e3f8c64ab72ea4
* Merge "Establish future behavior for Session cascade backrefs, bind"mike bayer2020-08-059-310/+504
|\
| * Establish future behavior for Session cascade backrefs, bindMike Bayer2020-08-019-310/+504
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The behavior of the :paramref:`_orm.relationship.cascade_backrefs` flag will be reversed in 2.0 and set to ``False`` unconditionally, such that backrefs don't cascade save-update operations from a forwards-assignment to a backwards assignment. A 2.0 deprecation warning is emitted when the parameter is left at its default of ``True`` at the point at which such a cascade operation actually takes place. The new behavior can be established as always by setting the flag to ``False`` on a specific :func:`_orm.relationship`, or more generally can be set up across the board by setting the the :paramref:`_orm.Session.future` flag to True. Additionally in the interests of expediency, this commit will also move Session away from making use of bound metadata if the future=True flag is set. An application that sets future=True should ideally have to change as little else as possible for full 2.0 behavior. Fixes: #5150 Change-Id: I490d1d61f09c62ffc2de983208aeed25dfe48aec
* | Merge "Genericize str() for types"mike bayer2020-08-024-14/+48
|\ \
| * | Genericize str() for typesMike Bayer2020-08-014-14/+48
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | Remove lookup logic that attempts to locate a dialect for a type, just use StrSQLTypeCompiler. Cleaned up the internal ``str()`` for datatypes so that all types produce a string representation without any dialect present, including that it works for third-party dialect types without that dialect being present. The string representation defaults to being the UPPERCASE name of that type with nothing else. Fixes: #4262 Change-Id: I02149e8a1ba1e7336149e962939b07ae0df83c6b
* | Clean python UUID importsVlastimil Zíma2020-07-301-9/+0
|/ | | | | | | | | | | Fixes: #5482 All supported python versions provide 'uuid' module. Closes: #5483 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5483 Pull-request-sha: fc32498a8b639ff21d5898100592782826d2c6dd Change-Id: I8b41b811da7576f724353425dad5d6f581641b4b
* Merge "Imply `sync_backref` flag in a viewonly relationship"mike bayer2020-07-291-60/+26
|\
| * Imply `sync_backref` flag in a viewonly relationshipFederico Caselli2020-07-071-60/+26
| | | | | | | | | | | | | | | | | | Update :paramref:`_orm.relationship.sync_backref` flag in a relationship to make it implicitly set to False in ``viewonly=True`` relationships, preventing synchronization events in all cases. References: #5237 Change-Id: Ib02b228a1b6e66b5ffd4540af776ac8f759c9a48
* | Ensure is_comparison passed for PG RANGE op() methodsJim Bosch2020-07-261-14/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue where the return type for the various RANGE comparison operators would itself be the same RANGE type rather than BOOLEAN, which would cause an undesirable result in the case that a :class:`.TypeDecorator` that defined result-processing behavior were in use. Pull request courtesy Jim Bosch. Fixes: #5476 Closes: #5477 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5477 Pull-request-sha: 925b117e0c91cdd67d9ddbd9d65f5ca3e88af91f Change-Id: I52ab4d4362d379c8253990f9d328a40990a64520
* | Merge "Allow Grouping to pass along proxy_set of element"mike bayer2020-07-231-0/+20
|\ \
| * | Allow Grouping to pass along proxy_set of elementMike Bayer2020-07-211-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Repaired an issue where the "ORDER BY" clause rendering a label name rather than a complete expression, which is particularly important for SQL Server, would fail to occur if the expression were enclosed in a parenthesized grouping in some cases. This case has been added to test support. Fixes: #5470 Change-Id: Ie0e27c39e5d53be78b32f7810f93d2d0536375e7
* | | Ensure _distinct_on removed within from_selectableMike Bayer2020-07-201-0/+94
|/ / | | | | | | | | Fixes: #5469 Change-Id: I85498d3380c2efb595782d2ba92cfd692c3efc48
* | Fix mssql dialect escaping object names containing ']'Gord Thompson2020-07-181-3/+16
| | | | | | | | | | Fixes: #5467 Change-Id: I054ec219717ba62847a9daf1214e215dd6b70633
* | Repair test modified in 5de0f1cf50cc0170d8eMike Bayer2020-07-161-0/+5
| | | | | | | | | | | | | | | | was "failing" for SQL server since a second set of assertions had been removed, these can be back as long as the session is rolled back afterwards Change-Id: Ie5d75aea41ba98f549cd72d71c6b4fdb30726775
* | Merge "test single and double quote inspection scenarios"2020_tutorialmike bayer2020-07-131-0/+10
|\ \
| * | test single and double quote inspection scenariosMike Bayer2020-07-131-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Applied a sweep through all included dialects to ensure names that contain single or double quotes are properly escaped when querying system tables, for all :class:`.Inspector` methods that accept object names as an argument (e.g. table names, view names, etc). SQLite and MSSQL contained two quoting issues that were repaired. Fixes: #5456 Change-Id: I3bc98806f5166f3d82275650079ff561446f2aef
* | | more docs for autocommit isolation levelMike Bayer2020-07-121-0/+11
|/ / | | | | | | | | | | | | | | this concept is not clear that we offer real DBAPI autocommit everywhere. backport 1.3 with edits as well Change-Id: I2e8328b7fb6e1cdc5453ab29c94276f60c7ca149
* | Correct mock call from 5de0f1cf50Mike Bayer2020-07-121-1/+1
| | | | | | | | | | | | | | | | | | mock in python 2.7 / 3.8 seems to have an "args" accessor but in prior python 3 versions this is not the case, so this is likely a recent addition to "mock" but wasn't present in the python3 vendored versions. Change-Id: Iff8afe75e891c9658c7c7b577831fefd5986940b
* | Merge "Convert remaining ORM APIs to support 2.0 style"mike bayer2020-07-1116-406/+1699
|\ \
| * | Convert remaining ORM APIs to support 2.0 styleMike Bayer2020-07-1116-406/+1699
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is kind of a mixed bag of all kinds to help get us to 1.4 betas. The documentation stuff is a work in progress. Lots of other relatively small changes to APIs and things. More commits will follow to continue improving the documentation and transitioning to the 1.4/2.0 hybrid documentation. In particular some refinements to Session usage models so that it can match Engine's scoping / transactional patterns, and a decision to start moving away from "subtransactions" completely. * add select().from_statement() to produce FromStatement in an ORM context * begin referring to select() that has "plugins" for the few edge cases where select() will have ORM-only behaviors * convert dynamic.AppenderQuery to its own object that can use select(), though at the moment it uses Query to support legacy join calling forms. * custom query classes for AppenderQuery are replaced by do_orm_execute() hooks for custom actions, a separate gerrit will document this * add Session.get() to replace query.get() * Deprecate session.begin->subtransaction. propose within the test suite a hypothetical recipe for apps that rely on this pattern * introduce Session construction level context manager, sessionmaker context manager, rewrite the whole top of the session_transaction.rst documentation. Establish context manager patterns for Session that are identical to engine * ensure same begin_nested() / commit() behavior as engine * devise all new "join into an external transaction" recipe, add test support for it, add rules into Session so it just works, write new docs. need to ensure this doesn't break anything * vastly reduce the verbosity of lots of session docs as I dont think people read this stuff and it's difficult to keep current in any case * constructs like case(), with_only_columns() really need to move to *columns, add a coercion rule to just change these. * docs need changes everywhere I look. in_() is not in the Core tutorial? how do people even know about it? Remove tons of cruft from Select docs, etc. * build a system for common ORM options like populate_existing and autoflush to populate from execution options. * others? Change-Id: Ia4bea0f804250e54d90b3884cf8aab8b66b82ecf
* | | Limit init_subclass test above python 3.6Mike Bayer2020-07-081-1/+1
|/ / | | | | | | | | | | | | | | The commit for I1654befe9eb1c8b8e7fc0784bdbe64284614f0ea #5357 runs the test on all Python 3 versions, however we need to limit at least python 3.6 for this. Change-Id: Ie86b78bbfd8c7bd013ff9aa7f8905328d792c1b3
* | Repair change of "future_select" caught in merge conflictMike Bayer2020-07-081-7/+7
| | | | | | | | | | | | | | | | the recent change to select() apparently seems to have been merged with other statements in the test_update_delete test that was still using the old term. Change-Id: I6be3eb148249bfcf08aae19efcad89803c69c658