Remove silent ignore for skip_locked w/ unsupported backends
For SQLAlchemy 1.4:
The "skip_locked" keyword used with ``with_for_update()`` will render "SKIP
LOCKED" on all MySQL backends, meaning it will fail for MySQL less than
version 8 and on current MariaDB backends. This is because those backends
do not support "SKIP LOCKED" or any equivalent, so this error should not be
silently ignored. This is upgraded from a warning in the 1.3 series.
For SQLAlchemy 1.3:
The "skip_locked" keyword used with ``with_for_update()`` will emit a
warning when used on MariaDB backends, and will then be ignored. This is
a deprecated behavior that will raise in SQLAlchemy 1.4, as an application
that requests "skip locked" is looking for a non-blocking operation which
is not available on those backends.
Mike Bayer [Mon, 14 Sep 2020 14:14:48 +0000 (10:14 -0400)]
Pass all pool parameters in recreate()
The following pool parameters were not being propagated to the new pool
created when :meth:`_engine.Engine.dispose` were called: ``pre_ping``,
``use_lifo``. Additionally the ``recycle`` and ``reset_on_return``
parameters were not propagated for the :class:`_engine.AssertionPool`
class. These issues have been fixed.
Several operators are renamed to achieve more consistent naming across
SQLAlchemy.
The operator changes are:
* `isnot` is now `is_not`
* `not_in_` is now `not_in`
Because these are core operators, the internal migration strategy for this
change is to support legacy terms for an extended period of time -- if not
indefinitely -- but update all documentation, tutorials, and internal usage
to the new terms. The new terms are used to define the functions, and
the legacy terms have been deprecated into aliases of the new terms.
Mike Bayer [Sun, 13 Sep 2020 17:15:29 +0000 (13:15 -0400)]
Update session.execute() and related documentation
The docs here were completely out of date and referred
to behaviors that are no longer true, behaviors that are
deprecated, etc. For the moment, take out all the verbiage
so that nothing incorrect is present. New ORM documentation
will need to be constructed to support this statement.
Mike Bayer [Sun, 13 Sep 2020 14:36:16 +0000 (10:36 -0400)]
Deprecate engine-wise ss cursors; repair mariadbconnector
The server_side_cursors engine-wide feature relies upon
regexp parsing of statements a well as general guessing as
to when the feature should be used. This is not within the
2.0 way of doing things and should be removed.
Additionally, mariadbconnector defaults to unbuffered cursors;
add new cursor hooks so that mariadbconnector can specify
buffered or unbuffered cursors without too much difficulty.
This will also correctly default mariadbconnector to buffered
cursors which should repair the segfaults we've been getting.
Try to restore the assert_raises that was removed in 5b6dfc0c38bf1f01da4b8 to see if mariadbconnector segfaults
are resolved.
Mike Bayer [Sat, 12 Sep 2020 20:07:50 +0000 (16:07 -0400)]
Ensure cursor is closed for scalar() if make_row fails
As we have some tests that are against enums which
can raise on fetch, if we call scalar() and it fails,
we need to close the cursor. mariadb segfaults
etc. seem to have been caused by this.
Improved support for covering indexes (with INCLUDE columns). Added the
ability for postgresql to render CREATE INDEX statements with an INCLUDE
clause from Core. Index reflection also report INCLUDE columns separately
for both mssql and postgresql (11+).
RamonWill [Thu, 20 Aug 2020 19:05:39 +0000 (15:05 -0400)]
Reflect mssql/postgresql filtered/partial indexes
Added support for inspection / reflection of partial indexes / filtered
indexes, i.e. those which use the ``mssql_where`` or ``postgresql_where``
parameters, with :class:`_schema.Index`. The entry is both part of the
dictionary returned by :meth:`.Inspector.get_indexes` as well as part of a
reflected :class:`_schema.Index` construct that was reflected. Pull
request courtesy Ramon Williams.
Mike Bayer [Fri, 11 Sep 2020 14:50:58 +0000 (10:50 -0400)]
Emit deprecation warning for **kw passed to session.execute()
Passing keyword arguments to methods such as :meth:`_orm.Session.execute`
to be passed into the :meth:`_orm.Session.get_bind` method is deprecated;
the new :paramref:`_orm.Session.execute.bind_arguments` dictionary should
be passed instead.
Mike Bayer [Mon, 31 Aug 2020 15:46:55 +0000 (11:46 -0400)]
Build out new declarative systems; deprecate mapper()
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.
Mike Bayer [Thu, 10 Sep 2020 15:56:34 +0000 (11:56 -0400)]
Add more docs for populate_existing(); link with_for_update
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().
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.
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.
Mike Bayer [Tue, 8 Sep 2020 15:01:28 +0000 (11:01 -0400)]
PostgreSQL dialect-level isolation_level parameter is legacy
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.
<!-- Provide a general summary of your proposed changes in the Title field above -->
### Description
Outdated path to in-repo changelog. Removed whitespace as well.
### 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:
- [x] 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.
- [ ] 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.
Mike Bayer [Sat, 5 Sep 2020 23:45:04 +0000 (19:45 -0400)]
Don't rely on string col name in adapt_to_context
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.
Mike Bayer [Thu, 3 Sep 2020 18:48:57 +0000 (14:48 -0400)]
Block non-mysqldb / pymysql from testing Enum
The mariadbconnector driver is having sporadic interpreter
crashes within this test suite. hopefully the crashes
are specific to these tests else we'll have to remove
mariadb from CI.
Václav Klusák [Mon, 17 Aug 2020 15:58:56 +0000 (11:58 -0400)]
Add support for classical mapping of dataclasses
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.
RamonWill [Tue, 25 Aug 2020 00:14:15 +0000 (20:14 -0400)]
Provide a more detailed error message for Query.join()
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.
Fantix King [Sat, 29 Aug 2020 16:37:34 +0000 (12:37 -0400)]
Fix a mis-reference in create_async_engine().
`AsyncMethodRequired` is actually from
`sqlalchemy.ext.asyncio.exc`, so here it
should be referenced as `async_exc.AsyncMethodRequired`,
instead of `exc.AsyncMethodRequired`.
RamonWill [Sun, 30 Aug 2020 13:05:06 +0000 (09:05 -0400)]
Include PostgreSQL in trigger test and correct documentation example
Include PostgreSQL dialect in trigger test and correct DDL example in documentation
A user highlighted that the syntax in the DDL trigger example was incorrect for PostgreSQL. The trigger tests where also skipping the PostgreSQL dialect until the syntax was corrected. This PR fixes both of these issues.
This pull request is:
- [X ] 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.
- [ ] 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.
Mike Bayer [Sun, 30 Aug 2020 22:13:36 +0000 (18:13 -0400)]
Support extra / single inh criteria with ORM update/delete
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.
Mike Bayer [Fri, 28 Aug 2020 21:56:43 +0000 (17:56 -0400)]
See if the future is here
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.
Gord Thompson [Fri, 21 Aug 2020 16:29:29 +0000 (10:29 -0600)]
Emit v2.0 deprecation warning for "implicit autocommit"
"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.
Federico Caselli [Thu, 20 Aug 2020 20:42:28 +0000 (22:42 +0200)]
Update authors file
Add all authors with more than 10 commits. The email are
omitted to avoid possible spam (even if they
are not private since they are in the git history, they
are at least not grep friendly)
Output obtained by `git shortlog --summary | sort -r`
Add support for regular expression on supported backend.
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.
Mike Bayer [Thu, 27 Aug 2020 19:50:47 +0000 (15:50 -0400)]
Raise NotImplemenedError for association proxy __clause_element__
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.
Mike Bayer [Fri, 21 Aug 2020 18:44:04 +0000 (14:44 -0400)]
make URL immutable
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.
jonathan vanasco [Mon, 20 Apr 2020 17:56:49 +0000 (13:56 -0400)]
More descriptive error for non-mapped string prop name
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.
Federico Caselli [Fri, 21 Aug 2020 22:30:44 +0000 (00:30 +0200)]
Updates for MariaDB sequences
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
Mike Bayer [Wed, 19 Aug 2020 16:08:26 +0000 (12:08 -0400)]
normalize execute style for events, 2.0
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.
Gord Thompson [Sat, 1 Aug 2020 21:56:12 +0000 (15:56 -0600)]
Add JSON support for mssql
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.
Mike Bayer [Wed, 19 Aug 2020 02:53:09 +0000 (22:53 -0400)]
Implement DDL visitor for PG ENUM with schema translate support
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.
Federico Caselli [Sat, 30 May 2020 12:45:00 +0000 (14:45 +0200)]
Add support for identity columns
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).
Mike Bayer [Tue, 18 Aug 2020 18:17:06 +0000 (14:17 -0400)]
Deliver straight BinaryExpr w/ no negate for any() / all()
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.