summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
Commit message (Collapse)AuthorAgeFilesLines
* Build out new declarative systems; deprecate mapper()Mike Bayer2020-09-1016-1166/+1852
| | | | | | | | | | | | | The ORM Declarative system is now unified into the ORM itself, with new import spaces under ``sqlalchemy.orm`` and new kinds of mappings. Support for decorator-based mappings without using a base class, support for classical style-mapper() calls that have access to the declarative class registry for relationships, and full integration of Declarative with 3rd party class attribute systems like ``dataclasses`` and ``attrs`` is now supported. Fixes: #5508 Change-Id: I130b2b6edff6450bfe8a3e6baa099ff04b5471ff
* Add more docs for populate_existing(); link with_for_updateMike Bayer2020-09-102-2/+23
| | | | | | | | | | | | | The populate_existing() method is actually changing to be an execution option, however it has almost no mention in the narrative docs so add docs in terms of the 1.x version first, including that we mention you almost definitely want to use this method if you are also using with_for_update(). Fixes: #5572 Fixes: #4774 Change-Id: Ieca916400622c1ffc1ae81204132a02a0983594c
* Repair documentation issuesMike Bayer2020-09-092-7/+41
| | | | | | | Fixes some remaining issues detailed at #5428. Fixes: #5428 Change-Id: I942a64411766fc82f30791eee570747a218af77d
* Merge "Update select usage to use the new 1.4 format"mike bayer2020-09-0827-370/+307
|\
| * Update select usage to use the new 1.4 formatFederico Caselli2020-09-0827-370/+307
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change includes mainly that the bracketed use within select() is moved to positional, and keyword arguments are removed from calls to the select() function. it does not yet fully address other issues such as keyword arguments passed to the table.select(). Additionally, allows False / None to both be considered as "disable" for all of select.correlate(), select.correlate_except(), query.correlate(), which establishes consistency with passing of ``False`` for the legact select(correlate=False) argument. Change-Id: Ie6c6e6abfbd3d75d4c8de504c0cf0159e6999108
* | Merge "Fix typo in :paramref:`_engine.create_engine.isolation_level` names"mike bayer2020-09-081-2/+2
|\ \
| * | Fix typo in :paramref:`_engine.create_engine.isolation_level` namesFederico Caselli2020-09-081-2/+2
| |/ | | | | | | | | Fixes: #5563 Change-Id: I29204fdf679d750c66ed17daf70bc8d7cb1b7f65
* | Fix typo in I0ad6d7a095e49d331618274c40ce75c76afdc7ddFederico Caselli2020-09-081-2/+2
|/ | | | Change-Id: I649662d440f83df379922e8c967d28f635f9c85b
* Merge "Create connection characteristics API; implement postgresql flags"mike bayer2020-09-088-23/+289
|\
| * Create connection characteristics API; implement postgresql flagsMike Bayer2020-09-088-23/+289
| | | | | | | | | | | | | | | | | | | | | | Added support for PostgreSQL "readonly" and "deferrable" flags for all of psycopg2, asyncpg and pg8000 dialects. This takes advantage of a newly generalized version of the "isolation level" API to support other kinds of session attributes set via execution options that are reliably reset when connections are returned to the connection pool. Fixes: #5549 Change-Id: I0ad6d7a095e49d331618274c40ce75c76afdc7dd
* | PostgreSQL dialect-level isolation_level parameter is legacyMike Bayer2020-09-081-17/+29
|/ | | | | | | | | The isolation level section in the docs inadvertently copied the PostgreSQL example using the PGDialect.isolation_level parameter and not the execution_options. ensure only the execution_options version is documented. Change-Id: I94e02ede62d3dded40e3fcbce8d04608dc063108
* Don't rely on string col name in adapt_to_contextMike Bayer2020-09-061-22/+66
| | | | | | | | | | | | | | | fixed an issue where even though the method claims to be matching up columns positionally, it was failing on that by looking in "keymap" based on string name. Adds a new member to the _keymap recs MD_RESULT_MAP_INDEX so that we can efficiently link from the generated keymap back to the compiled._result_columns structure without any ambiguity. Fixes: #5559 Change-Id: Ie2fa9165c16625ef860ffac1190e00575e96761f
* Merge "Add new MySQL reserved words: `cube`, `lateral`."mike bayer2020-09-031-0/+2
|\
| * Add new MySQL reserved words: `cube`, `lateral`.StefanosChaliasos2020-08-301-0/+2
| | | | | | | | | | | | | | | | Closes: #5539 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5539 Pull-request-sha: 8c228be322023041b11691d93dafa1be090f01a0 Change-Id: Ic756472a19563e793cf7e33b24eb1ad5e913dbc0
* | Add caveat re: with_expression and already-loaded objectMike Bayer2020-09-021-0/+6
| | | | | | | | | | | | | | Adds a test for the populate_existing() behavior as well. Fixes: #5553 Change-Id: Ib0db6227c3fec7d0065f2a7caa36b3fd94ef14fd
* | Merge "Improve reflection for mssql temporary tables"mike bayer2020-09-015-9/+91
|\ \
| * | Improve reflection for mssql temporary tablesGord Thompson2020-09-015-9/+91
| | | | | | | | | | | | | | | Fixes: #5506 Change-Id: I718474d76e3c630a1b71e07eaa20cefb104d11de
* | | Merge "Add support for classical mapping of dataclasses"mike bayer2020-09-013-5/+25
|\ \ \
| * | | Add support for classical mapping of dataclassesVáclav Klusák2020-09-013-5/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added support for direct mapping of Python classes that are defined using the Python ``dataclasses`` decorator. See the section :ref:`mapping_dataclasses` for background. Pull request courtesy Václav Klusák. Fixes: #5027 Closes: #5516 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5516 Pull-request-sha: bb48c63d1561ca48c954ad9f84a3eb2646571115 Change-Id: Ie33db2aae4adeeb5d99633fe926b9c30bab0b885
* | | | Merge "MariaDB dialect implementation"mike bayer2020-09-013-0/+244
|\ \ \ \ | |_|/ / |/| | |
| * | | MariaDB dialect implementationGeorg Richter2020-08-313-0/+244
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes: #5459 Closes: #5515 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5515 Pull-request-sha: 760090b9067304cc65fece12fcf10b522afc4a2a Change-Id: I30e8fbc02b7b5329ca228cd39f6fb7cfd0e43092
* | | Merge "Provide a more detailed error message for Query.join()"mike bayer2020-09-011-2/+24
|\ \ \
| * | | Provide a more detailed error message for Query.join()RamonWill2020-08-311-2/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An :class:`.ArgumentError` with more detail is now raised if the target parameter for :meth:`_query.Query.join` is set to an unmapped object. Prior to this change a less detailed ``AttributeError`` was raised. Pull request courtesy Ramon Williams. Fixes: #4428 Closes: #5452 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5452 Pull-request-sha: b148df547037e9a254fe331eff8e922c78426261 Change-Id: I873453d1fdb651178216aac698baac63ae5a94e8
* | | | Fix a mis-reference in create_async_engine().Fantix King2020-08-311-1/+1
| |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `AsyncMethodRequired` is actually from `sqlalchemy.ext.asyncio.exc`, so here it should be referenced as `async_exc.AsyncMethodRequired`, instead of `exc.AsyncMethodRequired`. Fixes: #5529 Closes: #5545 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5545 Pull-request-sha: d8f885c587dd058f909d4f3bdbec3d0fca176680 Change-Id: I6886558bfd33d3e9e283fbd60c0ec971a1f22c0c
* | | Fix AsyncEngine connect() bug when pool is exhaustedFantix King2020-08-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Description Decorating the referenced `await_fallback` with `staticmethod` would stop `AsyncAdaptedQueue.await_` from being treated as a bound method. ### Checklist This pull request is: - [x] A short code fix Fixes #5546 **Have a nice day!** Closes: #5547 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5547 Pull-request-sha: 6f18ee290e7d9fe24ce2a4a4ed8069b46082ca18 Change-Id: Ie335ee650f1dee0d1fce59e448217a48307b3435
* | | Support extra / single inh criteria with ORM update/deleteMike Bayer2020-08-304-19/+146
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ORM bulk update and delete operations, historically available via the :meth:`_orm.Query.update` and :meth:`_orm.Query.delete` methods as well as via the :class:`_dml.Update` and :class:`_dml.Delete` constructs for :term:`2.0 style` execution, will now automatically accommodate for the additional WHERE criteria needed for a single-table inheritance discrminiator. Joined-table inheritance is still not directly supported. The new :func:`_orm.with_loader_criteria` construct is also supported for all mappings with bulk update/delete. Fixes: #5018 Fixes: #3903 Change-Id: Id90827cc7e2bc713d1255127f908c8e133de9295
* | | Merge "internal test framework files for standardization of is_not/not_in;"mike bayer2020-08-302-2/+12
|\ \ \
| * | | internal test framework files for standardization of is_not/not_in;jonathan vanasco2020-08-292-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | this is safe for 1.3.x Change-Id: Icba38fdc20f5d8ac407383a4278ccb346e09af38
* | | | Update connection docs for migrating off of nestingMike Bayer2020-08-291-4/+4
| | | | | | | | | | | | | | | | Change-Id: I3a81140f00a4a9945121bfb8ec4c0e3953b4085f
* | | | See if the future is hereMike Bayer2020-08-287-30/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The docs are going to talk a lot about session.execute(select()) for ORM queries, and additionally it's much easier to help users with queries and such if we can use this new syntax. I'm hoping to see how hard it is to get a unified tutorial started that switches to new syntax. Basically, new syntax is much easier to explain and less buggy. But, if we are starting to present new syntax with the explicit goal of being easier to explain for less experienced programmers, the "future" thing is going to just be an impediment to that. See if we can remove "future" from session.execute(), so that ORM-enabled select() statements return ORM results at that level. This does not change the presence of the "future" flag for the Session's construction and for its transactional behaviors. The only perceptible change of the future flag for session.execute() is that session.execute(select()) where the statement has ORM entities in it now returns ORM new style tuples rather than old style tuples. Like mutating a URL, it's hopefully not very common that people are doing this. Change-Id: I0aa10322bb787d554d32772e3bc60548f1bf6206
* | | | Emit v2.0 deprecation warning for "implicit autocommit"Gord Thompson2020-08-287-36/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "Implicit autocommit", which is the COMMIT that occurs when a DML or DDL statement is emitted on a connection, is deprecated and won't be part of SQLAlchemy 2.0. A 2.0-style warning is emitted when autocommit takes effect, so that the calling code may be adjusted to use an explicit transaction. As part of this change, DDL methods such as :meth:`_schema.MetaData.create_all` when used against a :class:`_engine.Engine` or :class:`_engine.Connection` will run the operation in a BEGIN block if one is not started already. The MySQL and MariaDB dialects now query from the information_schema.tables system view in order to determine if a particular table exists or not. Previously, the "DESCRIBE" command was used with an exception catch to detect non-existent, which would have the undesirable effect of emitting a ROLLBACK on the connection. There appeared to be legacy encoding issues which prevented the use of "SHOW TABLES", for this, but as MySQL support is now at 5.0.2 or above due to :ticket:`4189`, the information_schema tables are now available in all cases. Fixes: #4846 Change-Id: I733a7e0e17477a63607fb9931c87c393bbd7ac57
* | | | Merge "Add support for regular expression on supported backend."mike bayer2020-08-2711-3/+443
|\ \ \ \
| * | | | Add support for regular expression on supported backend.Federico Caselli2020-08-2711-3/+443
| | |_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Two operations have been defined: * :meth:`~.ColumnOperators.regexp_match` implementing a regular expression match like function. * :meth:`~.ColumnOperators.regexp_replace` implementing a regular expression string replace function. Fixes: #1390 Change-Id: I44556846e4668ccf329023613bd26861d5c674e6
* | | | Raise NotImplemenedError for association proxy __clause_element__Mike Bayer2020-08-271-0/+6
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | It's not possible right now to use an association proxy element as a plain column expression to be SELECTed from or used in a SQL function. An informative error is now raised when this occurs. Fixes: #5542 Change-Id: I334e767ebc0b56c1dccc4a1e5185b0435af77b93
* | | Document caveat about backrefs and attribute_mapped_collectionMike Bayer2020-08-261-4/+7
| | | | | | | | | | | | | | | Fixes: #5538 Change-Id: I2bda6bed40d35560a71bf0ed09d141047ce59e82
* | | Merge "make URL immutable"mike bayer2020-08-2612-119/+713
|\ \ \
| * | | make URL immutableMike Bayer2020-08-2512-119/+713
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | it's not really correct that URL is mutable and doesn't do any argument checking. propose replacing it with an immutable named tuple with rich copy-and-mutate methods. At the moment this makes a hard change to the CreateEnginePlugin docs that previously recommended url.query.pop(). I can't find any plugins on github other than my own that are using this feature, so see if we can just make a hard change on this one. Fixes: #5526 Change-Id: I28a0a471d80792fa8c28f4fa573d6352966a4a79
* | | | Merge "More descriptive error for non-mapped string prop name"mike bayer2020-08-261-1/+17
|\ \ \ \
| * | | | More descriptive error for non-mapped string prop namejonathan vanasco2020-08-251-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue where using a loader option against a string attribute name that is not actually a mapped attribute, such as a plain Python descriptor, would raise an uninformative AttributeError; a descriptive error is now raised. Fixes: #4589 Closes: #4594 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4594 Pull-request-sha: 2b7ed5240f49be90f9390e3d041c9cb957083465 Change-Id: I66b9937991eb7cdbe074a92f490af1c80d16449e
* | | | | Merge "Updates for MariaDB sequences"mike bayer2020-08-256-131/+181
|\ \ \ \ \ | |_|_|_|/ |/| | | |
| * | | | Updates for MariaDB sequencesFederico Caselli2020-08-226-131/+181
| | |_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MariaDB should not run a Sequence if it has optional=True. Additionally, rework the rules in crud.py to accommodate the new combination MariaDB brings us, which is a dialect that supports both cursor.lastrowid, explicit sequences, *and* no support for returning. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Fixes: #5528 Change-Id: I9a8ea69a34983affa95dfd22186e2908fdf0d58c
* | | | Merge "Improve docs of Identity columns."mike bayer2020-08-241-1/+1
|\ \ \ \ | |_|/ / |/| | |
| * | | Improve docs of Identity columns.Federico Caselli2020-08-241-1/+1
| |/ / | | | | | | | | | Change-Id: Iba85ac3c2c9f40878768d74a5dd33083fc68e504
* | | Add deprecation warning for mssql legacy_schema_aliasingGord Thompson2020-08-242-8/+15
|/ / | | | | | | | | Fixes: #4809 Change-Id: I9ce2a5dfb79d86624c187ee28b5911fd14328ce2
* | Merge "Add support for identity columns"mike bayer2020-08-2110-79/+480
|\ \ | |/ |/|
| * Add support for identity columnsFederico Caselli2020-08-1910-79/+480
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Added the :class:`_schema.Identity` construct that can be used to configure identity columns rendered with GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY. Currently the supported backends are PostgreSQL >= 10, Oracle >= 12 and MSSQL (with different syntax and a subset of functionalities). Fixes: #5362 Fixes: #5324 Fixes: #5360 Change-Id: Iecea6f3ceb36821e8b96f0b61049b580507a1875
* | Merge "Raise UnmappedInstanceError if the attribute of a database object is ↵mike bayer2020-08-201-1/+8
|\ \ | | | | | | | | | an unmapped object."
| * | Raise UnmappedInstanceError if the attribute of a database object is an ↵RamonWill2020-08-131-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | unmapped object. The proposed change will raise an UnmappedInstanceError instead of an attribute error if an instance an Instrumented Attribute is unmapped. ### Description If a user tries to access an attribute of a database object that is unmapped then an error is raised. The reason for this is because the __get__ descriptor uses instance_state(instance) which uses the operator.attrgetter method to see if the object in question has the attribute "_sa_instance_state" that mapped objects have. If it doesn't contain this attribute it means that the object is unmapped. 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: #3858 Closes: #5478 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5478 Pull-request-sha: 853051c9225446b69f52b13ade78709ad2617f6d Change-Id: I5989c81227e55e628babdd11406d1e8ec0e8d93a
* | | Merge "normalize execute style for events, 2.0"mike bayer2020-08-205-76/+237
|\ \ \
| * | | normalize execute style for events, 2.0Mike Bayer2020-08-205-76/+237
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The _execute_20 and exec_driver_sql methods should wrap up the parameters so that they represent the single list / single dictionary style of invocation into the legacy methods. then the before_ after_ execute event handlers should be receiving the parameter dictionary as a single dictionary. this requires that we break out distill_params to work differently if event handlers are present. additionally, add deprecation warnings for old argument passing styles. Change-Id: I97cb4d06adfcc6b889f10d01cc7775925cffb116