summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* | | Merge "Implement DDL visitor for PG ENUM with schema translate support"mike bayer2020-08-192-12/+49
|\ \ \
| * | | Implement DDL visitor for PG ENUM with schema translate supportMike Bayer2020-08-192-12/+49
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue where the :class:`_postgresql.ENUM` type would not consult the schema translate map when emitting a CREATE TYPE or DROP TYPE during the test to see if the type exists or not. Additionally, repaired an issue where if the same enum were encountered multiple times in a single DDL sequence, the "check" query would run repeatedly rather than relying upon a cached value. Fixes: #5520 Change-Id: I79f46e29ac0168e873ff178c242f8d78f6679aeb
* | | Merge "Add JSON support for mssql"mike bayer2020-08-1910-34/+310
|\ \ \
| * | | Add JSON support for mssqlGord Thompson2020-08-1910-34/+310
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | Added support for the :class:`_types.JSON` datatype on the SQL Server dialect using the :class:`_mssql.JSON` implementation, which implements SQL Server's JSON functionality against the ``NVARCHAR(max)`` datatype as per SQL Server documentation. Implementation courtesy Gord Thompson. Fixes: #4384 Change-Id: I28af79a4d8fafaa68ea032228609bba727784f18
* | | Support data types for CREATE SEQUENCE in PostgreSQLFederico Caselli2020-08-181-0/+11
|/ / | | | | | | | | | | | | | | | | Allow specifying the data type when creating a :class:`.Sequence` in PostgreSQL by using the parameter :paramref:`.Sequence.data_type`. Fixes: #5498 Change-Id: I2b4a80aa89b1503c56748dc3ecd2cf145faddd8b
* | Merge "Deliver straight BinaryExpr w/ no negate for any() / all()"mike bayer2020-08-181-2/+10
|\ \
| * | Deliver straight BinaryExpr w/ no negate for any() / all()Mike Bayer2020-08-181-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | Adjusted the :meth:`_types.ARRAY.Comparator.any` and :meth:`_types.ARRAY.Comparator.all` methods to implement a straight "NOT" operation for negation, rather than negating the comparison operator. Fixes: #5518 Change-Id: I87ee9278c321aafe51a679fcfcbb5fbb11307fda
* | | Update dialect for pg8000 version 1.16.0Tony Locke2020-08-186-81/+157
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The pg8000 dialect has been revised and modernized for the most recent version of the pg8000 driver for PostgreSQL. Changes to the dialect include: * All data types are now sent as text rather than binary. * Using adapters, custom types can be plugged in to pg8000. * Previously, named prepared statements were used for all statements. Now unnamed prepared statements are used by default, and named prepared statements can be used explicitly by calling the Connection.prepare() method, which returns a PreparedStatement object. Pull request courtesy Tony Locke. Notes by Mike: to get this all working it was needed to break up JSONIndexType into "str" and "int" subtypes; this will be needed for any dialect that is dependent on setinputsizes(). also includes @caselit's idea to include query params in the dbdriver parameter. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Closes: #5451 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5451 Pull-request-sha: 639751ca9c7544801b9ede02e6cbe15a16c59c82 Change-Id: I2869bc52c330916773a41d11d12c297aecc8fcd8
* | Merge "Create a real type for Tuple() and handle appropriately in compiler"mike bayer2020-08-179-56/+117
|\ \
| * | Create a real type for Tuple() and handle appropriately in compilerMike Bayer2020-08-179-56/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Merge "Make discriminator column used by ConcreteBase configurable"mike bayer2020-08-171-6/+31
|\ \ \
| * | | Make discriminator column used by ConcreteBase configurableJesse Bakker2020-08-171-6/+31
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The name of the virtual column used when using the :class:`_declarative.AbstractConcreteBase` and :class:`_declarative.ConcreteBase` classes can now be customized, to allow for models that have a column that is actually named ``type``. Pull request courtesy Jesse-Bakker. Fixes: #5513 Closes: #5514 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5514 Pull-request-sha: 5e7429f3531e2e22fffe996c9760905578d16ef9 Change-Id: I733737844d4f4e1f52dd2475a66c7044ff7292f5
* | | Merge "Bump minimum MySQL version to 5.0.2; use all-numeric server version"mike bayer2020-08-176-239/+249
|\ \ \
| * | | Bump minimum MySQL version to 5.0.2; use all-numeric server versionMike Bayer2020-08-166-239/+249
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MySQL dialect's server_version_info tuple is now all numeric. String tokens like "MariaDB" are no longer present so that numeric comparison works in all cases. The .is_mariadb flag on the dialect should be consulted for whether or not mariadb was detected. Additionally removed structures meant to support extremely old MySQL versions 3.x and 4.x; the minimum MySQL version supported is now version 5.0.2. In addition, as the "MariaDB" name goes away from server version, expand upon the change in I330815ebe572b6a9818377da56621397335fa702 to support the name "mariadb" throughout the dialect and test suite when mariadb-only mode is used. This changes the "name" field on the MariaDB dialect to "mariadb", which then implies a change throughout the testing requirements system as well as all the dialect-specific DDL argument names such as "mysql_engine" is now specified as "mariadb_engine", etc. Make use of the recent additions to test suite URL provisioning so that we can force MariaDB databases to have a "mariadb-only" dialect which allows us to test this name change fully. Update documentation to refer to MySQL / MariaDB explicitly as well as indicating the "mariadb_" prefix used for options. It seems likely that MySQL and MariaDB version numbers are going to start colliding at some point so having the "mariadb" name be available as a totally separate dialect name should give us some options in this regard. Currently also includes a date related fix to a test for the postgresql dialect that was implicitly assuming a non-UTC timezone Fixes: #4189 Change-Id: I00e76d00f62971e1f067bd61915fa6cc1cf64e5e
* | | error message for LookupRamonWill2020-08-172-2/+29
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Thr proposed change will provide the user with the target Enum Class name as well as up to four possible enum values when a LookupError is raised in the Enum Class. A user requested that the enum name and possible values are included to the LookupError message to make debugging easier. The criteria included using ellipses for Enums containing more than four values and using ellipses for enum values that were greater than a certain number of characters (for this resolution the limit is 11 characters). 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!** Fixes: #4733 Closes: #5490 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5490 Pull-request-sha: 55e76f2ae796b59b7de157cfaae5235dffa359cb Change-Id: I4541f9efed1c05401587a413e9e748d46938bcd1
* | Provision on different drivers dynamicallyMike Bayer2020-08-145-10/+138
| | | | | | | | | | | | | | | | | | | | | | We want TOX_POSTGRESQL and similar to be the fixed variable that is configured from CI environment. These variables should refer to database servers but individual drivers like asyncpg mysqlconnector etc. should come from local tox.ini. add a new system to generate per-driver URLs from a simple list of hostname-based URLs delivered from CI environment. Change-Id: I4267b4a70742765388c7e7c4432c1da9d9adece2
* | Don't import asyncpg prior to python 3.6Mike Bayer2020-08-141-1/+1
| | | | | | | | | | | | | | Continuing on 788ba204a43b37d28cc690138b83e6782f8a46da make sure asyncpg doesn't get imported if version < 3.6. Change-Id: Ic070a0c9d3656f7da7ce2eb85033968fc88a64b9
* | Merge "Implement rudimentary asyncio support w/ asyncpg"mike bayer2020-08-1435-79/+2809
|\ \
| * | Implement rudimentary asyncio support w/ asyncpgMike Bayer2020-08-1335-79/+2809
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-132-6/+13
|\ \ | |/ |/|
| * Further fixes for ticket 5470Mike Bayer2020-08-132-6/+13
| | | | | | | | | | | | | | | | | | | | 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-135-22/+103
|/ | | | | | | | | | | | | | | | | | | | | | | | | | 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-122-15/+29
| | | | | | | | | | | | 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-123-464/+782
|\
| * Break scalars() and mappings() into separate objectsMike Bayer2020-08-123-464/+782
| | | | | | | | | | | | | | | | | | | | | | | | 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/+2
|\ \ | |/ |/|
| * Fix mysql CREATE TABLE / COLLATE issueGord Thompson2020-08-091-0/+2
| | | | | | | | | | Fixes: #5411 Change-Id: Ib0c53f5ed3f9d3ff0586580c9a9cce73b4b870f4
* | Correct for update.ordered_values() and use in new testMike Bayer2020-08-111-3/+5
| | | | | | | | | | | | | | | | | | | | 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
* | update deterministic sort ordering docMike Bayer2020-08-111-13/+20
|/ | | | | | | | reword the sorting in terms of the actual behavior, put correct changed version References: #5494 Change-Id: I725338526afe28454910d029c153e4476f8c686f
* Fix typosKarthikeyan Singaravelan2020-08-092-2/+2
|
* render INSERT/UPDATE column expressions up front; pass stateMike Bayer2020-08-083-55/+167
| | | | | | | | | | | | | | | | | | | | | | 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-074-13/+26
| | | | | | | | | | | | | 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-073-12/+9
|\
| * Add complete platform data to profiling dataFederico Caselli2020-08-073-12/+9
| | | | | | | | | | | | | | | | | | 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-1/+3
|\ \ | |/ |/|
| * Pass schema_translate_map from DDLCompiler to SQLCompilerMike Bayer2020-08-071-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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-063-6/+37
|/ | | | | | | | | | | | | 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
* Documentation updates for 1.4Mike Bayer2020-08-058-48/+141
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* Implement relationship AND criteria; global loader criteriaMike Bayer2020-08-0512-94/+478
| | | | | | | | | | | | | | | | | | | 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
* Convert lazy loader, selectinload, load_on_ident to lambda statementsMike Bayer2020-08-0516-222/+358
| | | | | | | | | 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-0511-333/+935
| | | | | | | | | | | | | | | | | | | | 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/+1
| | | | | | | | | 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-056-15/+62
|\
| * Establish future behavior for Session cascade backrefs, bindMike Bayer2020-08-016-15/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | fix formattingMike Bayer2020-08-041-1/+1
| | | | | | | | Change-Id: I8315cfef6e5c4b87d64fc770998a1229cc690870
* | Add note that fast_executemany uses memoryMike Bayer2020-08-041-7/+11
| | | | | | | | | | | | | | | | Ideally this would be a per-execution option, or Pyodbc could perhaps run the data in chunks. Fixes: #5334 Change-Id: If4a11b312346b8e4c2b8cd38840b3a2ba56dec3b
* | Merge "Genericize str() for types"mike bayer2020-08-022-7/+24
|\ \
| * | Genericize str() for typesMike Bayer2020-08-012-7/+24
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | 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-303-22/+3
|/ | | | | | | | | | | 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 "Consider default FROM DUAL for MySQL"mike bayer2020-07-292-1/+62
|\