Mike Bayer [Mon, 13 Jul 2020 14:49:57 +0000 (10:49 -0400)]
test single and double quote inspection scenarios
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.
Mike Bayer [Wed, 8 Jul 2020 19:48:32 +0000 (15:48 -0400)]
Limit init_subclass test above python 3.6
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.
Mike Bayer [Wed, 8 Jul 2020 19:32:38 +0000 (15:32 -0400)]
Propose --nomemory by default
the memory tests are solely responsible for the largest chunk of
time and CPU energy taken up in running the tests. Regressions
in this area are nonexistent unless major changes are being
taken up. Try to revert them to False and see if a single
gerrit job can perhaps run these.
jonathan vanasco [Tue, 30 Jun 2020 16:31:58 +0000 (12:31 -0400)]
added semicolon (;) to improve warning message clarity
### Description
Added a semicolon to improve the clarity of warning message. I actually had a table named `backend`, and thought it was involved!
While updating the code, I noticed no test that directly tests for this warning message. There are tests for the `Can't sort tables for DROP;` prefix of this message and the `exc.CircularDependencyError`; and some tests for the `exc.CircularDependencyError` message itself. I couldn't find any test for this particular message though. (Just thought I'd bring that up)
Added a ``**kw`` argument to the :meth:`.DeclarativeMeta.__init__` method.
This allows a class to support the :pep:`487` metaclass hook
``__init_subclass__``. Pull request courtesy Ewen Gillies.
1. move all discussion of how to customize connection
to the engines.rst section. have the section in pooling.rst
point to engines.
2. ensure all of the common use cases for connection modification
are listed out in order of level of modification. the use
case of modifying an existing connection is separate from that of
modifying how connect is called; ensure that poolevents.connect
is referred to just as prominently as dialectevents.do_connect.
3. completely replace any discussion of create_engine.creator, as this
hook does not offer anything beyond what do_connect() does.
"creator" is more about using a Pool object directly without an
Engine, which is no longer a documented use case.
Mike Bayer [Mon, 29 Jun 2020 19:45:20 +0000 (15:45 -0400)]
Include DATETIME / DateTime with the MySQL TIMESTAMP examples
To eliminate any remaining confusion, clarify that
DATETIME (as well as DateTime) and TIMESTAMP are treated
similarly with the MySQL dialect regarding ON UPDATE.
Mike Bayer [Mon, 29 Jun 2020 18:35:22 +0000 (14:35 -0400)]
Docuemnt current workarounds for MySQL TIMESTAMP
MySQL 8 no longer generates the DEFAULT or ON UPDATE
clauses for TIMESTAMP by default, hence users will begin to hit
this regularly. add warnings that this non-standard SQL is not
accommodated by server_onupdate and docuemnt the workaround
used in issues such as #4652.
Mike Bayer [Thu, 25 Jun 2020 15:12:40 +0000 (11:12 -0400)]
Use index name to determine if an index is for the PK
Fixed bug in Oracle dialect where indexes that contain the full set of
primary key columns would be mistaken as the primary key index itself,
which is omitted, even if there were multiples. The check has been refined
to compare the name of the primary key constraint against the index name
itself, rather than trying to guess based on the columns present in the
index.
Mike Bayer [Fri, 19 Jun 2020 14:25:42 +0000 (10:25 -0400)]
Propose black py27 + py35 mode for the rest of Py2K
py27 mode produces one failure for flake8 which is the
space added between exec and parenthesis. however apparently
we can add multiple versions to target-versions which allows
the exec() calls to come out in python 3 style.
The issue we want to improve is issues of trailing
commas being added. I'm not really able to get black to
consistently add or remove these trailing commas in any
case no matter what I set target-version towards.
Mike Bayer [Thu, 11 Jun 2020 18:31:57 +0000 (14:31 -0400)]
Add version token to error URL
the sqlalche.me redirector now supports the numerical version
code in the URL, e.g. /13/, /14/, /20/, etc., so that we can
redirect to the error codes for the appropriate version
of SQLAlchemy in use without going through the catch-all "latest"
link. If a particular version of the docs is no longer on the
site, the redirect will revert to falling through the "latest"
link (which ultimately lands on the current release version,
/13/ at the time of this writing).
Added "exists" to the list of reserved words for SQLite so that this word
will be quoted when used as a label or column name. Pull request courtesy
Thodoris Sotiropoulos.
### Description
There were a few remnant uses of master/slave in the code and docs. The project previously made a decision to move away from them to use modern and inclusive terminology.
This PR does not cover a bug or necessitate a documented entry into the changelog, so an issue ticket was not created.
### Checklist
This pull request is:
- [x] A documentation / typographical error fix
- [x] A short code fix
- [ ] A new feature implementation
Mike Bayer [Thu, 4 Jun 2020 17:28:21 +0000 (13:28 -0400)]
Document that type_coerce does not currently imply parenthesization
We've had a few issues where the current solution
is to use the self_group() method, so document that as
the current approach for the parenthesization use case.
Whether or not type_coerce() is changed later, this is
how it works at the moment.
Mike Bayer [Mon, 1 Jun 2020 00:34:03 +0000 (20:34 -0400)]
Support multiple dotted sections in mssql schema names
Refined the logic used by the SQL Server dialect to interpret multi-part
schema names that contain many dots, to not actually lose any dots if the
name does not have bracking or quoting used, and additionally to support a
"dbname" token that has many parts including that it may have multiple,
independently-bracketed sections.
This fix addresses #5364 to some degree but probably does not
resolve it fully.
Haoyu Sun [Fri, 29 May 2020 18:31:07 +0000 (14:31 -0400)]
Add default expression to query_expression()
Added a new parameter :paramref:`_orm.query_expression.default_expr` to the
:func:`_orm.query_expression` construct, which will be appled to queries
automatically if the :func:`_orm.with_expression` option is not used. Pull
request courtesy Haoyu Sun.
Gord Thompson [Fri, 29 May 2020 13:20:54 +0000 (07:20 -0600)]
Fix is_disconnect false positive for mssql+pyodbc
Fixed an issue where the ``is_disconnect`` function in the SQL Server
pyodbc dialect was incorrectly reporting the disconnect state when the
exception messsage had a substring that matched a SQL Server ODBC error
code.
Mike Bayer [Wed, 27 May 2020 14:18:33 +0000 (10:18 -0400)]
Render table hints in generic SQL
Added :meth:`.Select.with_hint` output to the generic SQL string that is
produced when calling ``str()`` on a statement. Previously, this clause
would be omitted under the assumption that it was dialect specific.
The hint text is presented within brackets to indicate the rendering
of such hints varies among backends.
Fixes: #4860
# Description
Add nowait, skip_lock, of arguments to for_update_clause for mysql
### Checklist
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.
Mike Bayer [Fri, 22 May 2020 17:14:58 +0000 (13:14 -0400)]
Don't emit pyodbc "no driver" warning for empty URL
Fixed an issue in the pyodbc connector such that a warning about pyodbc
"drivername" would be emitted when using a totally empty URL. Empty URLs
are normal when producing a non-connected dialect object or when using the
"creator" argument to create_engine(). The warning now only emits if the
driver name is missing but other parameters are still present.
Miguel Grinberg [Thu, 21 May 2020 09:54:47 +0000 (05:54 -0400)]
Fix query string escaping in engine URLs
Fixed issue in :class:`.URL` object where stringifying the object
would not URL encode special characters, preventing the URL from being
re-consumable as a real URL. Pull request courtesy Miguel Grinberg.
Mike Bayer [Sat, 16 May 2020 17:05:00 +0000 (13:05 -0400)]
Reword delete-orphan on many error message and document
For many years we have encountered users making use of the
"single_parent" flag in response to the error message for
"delete-orphan" expressing this as a means to cancel the current
error. However, the actual issue here is usually a misuse
of the delete-orphan cascade setting. Reword the error message to
be much more descriptive about what this means and add new
error link sections describing the situation in as much detail
as possible.
Dylan Modesitt [Wed, 6 May 2020 18:17:23 +0000 (14:17 -0400)]
Add 'schema' parameter to table
Added a "schema" parameter to the :func:`_expression.table` construct,
allowing ad-hoc table expressions to also include a schema name.
Pull request courtesy Dylan Modesitt.
Mike Bayer [Thu, 14 May 2020 14:51:29 +0000 (10:51 -0400)]
Actively unset reset agent in discard transaction
The assumptions in _discard_transaction from 916e1fea25afcd07fa1d1d2f72043b372cd02223 were too narrow,
assuming that if the given transaction were not our
"current" one, that this would not be the reset agent. however
as the legacy behvaior is that even a "nested" transaction gets
set as "self._transaction", this did not accommodate for the nested
transaction being thrown away. We will attempt to refine all of this
logic in #5327 for 1.4 /master assuming this is feasible for the
full suite of current use cases.
Mike Bayer [Wed, 13 May 2020 16:42:08 +0000 (12:42 -0400)]
Assert reset agent always set correctly and is active
Fixed fairly critical issue where the DBAPI connection could be returned to
the connection pool while still in an un-rolled-back state. The reset agent
responsible for rolling back the connection could be corrupted in the case
that the transaction was "closed" without being rolled back or committed,
which can occur in some scenarios when using ORM sessions and emitting
.close() in a certain pattern involving savepoints. The fix ensures that
the reset agent is always active.
Note for 1.3 the cherry-pick modifies the approach from master as
transaction handling has diverged.
Mike Bayer [Thu, 7 May 2020 17:56:38 +0000 (13:56 -0400)]
Use cx_oracle.LONG_STRING /LONG_BINARY for CLOB/BLOB
Changed the implementation of fetching CLOB and BLOB objects to use
cx_Oracle's native implementation which fetches CLOB/BLOB objects inline
with other result columns, rather than performing a separate fetch. As
always, this can be disabled by setting auto_convert_lobs to False.
As part of this change, the behavior of a CLOB that was given a blank
string on INSERT now returns None on SELECT, which is now consistent with
that of VARCHAR on Oracle.
Mike Bayer [Fri, 8 May 2020 15:25:14 +0000 (11:25 -0400)]
Expand CTE testing and begin to make this more prominent.
SQLite supports CTEs as do both the MariaDB and MySQL
databases now. Expand test support and begin adding
new tutorial sections to make this concept more prominent.
Also fix some formatting issues in the tutorial, and start
moving more towards {opensql} - the "SQL" button thing
is cool but the tutorials mainly need to illustrate how
the SQL looks for things. Screens are bigger now and
we likely should move away from the SQL button almost
entirely.
CTE for the tutorial needed zzzeeksphinx fix to recognize
"WITH" so bumping that to latest release number in git.
Mike Bayer [Thu, 7 May 2020 21:13:35 +0000 (17:13 -0400)]
Warn when sorted_tables is not actually sorting
A warning is emitted when making use of the :attr:`.MetaData.sorted_tables`
attribute as well as the :func:`_schema.sort_tables` function, and the
given tables cannot be correctly sorted due to a cyclic dependency between
foreign key constraints. In this case, the functions will no longer sort
the involved tables by foreign key, and a warning will be emitted. Other
tables that are not part of the cycle will still be returned in dependency
order. Previously, the sorted_table routines would return a collection that
would unconditionally omit all foreign keys when a cycle was detected, and
no warning was emitted.
Introduce :paramref:`_orm.relationship.sync_backref` flag in a relationship
to control if the synchronization events that mutate the in-Python
attributes are added.
This flag is implied in a ``viewonly=True`` relationship.
This supersedes the previous change #5149, that warned that ``viewonly=True``
relationship target of a back_populates or backref configuration would be
disallowed.
Mike Bayer [Wed, 6 May 2020 13:47:26 +0000 (09:47 -0400)]
Clarify create_engine encoding; update cx_Oracle
The create_engine()->encoding parameter is mostly irrelevant
under Python 3. make it clear this parameter is not generally
useful anymore and refer readers to the dialect documenation.
Update cx_Oracle documentation to feature many examples of
the encoding / nencoding parameters, remove extra detail that
is not generally useful and reorganize information into
more specific sections, de-emphasizing legacy / Python 2
specific sections.