]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
4 years agoUpdate docs with actual MariaDB JSON support 5474/head
DefteZ [Fri, 24 Jul 2020 23:45:41 +0000 (01:45 +0200)] 
Update docs with actual MariaDB JSON support

4 years agoMerge "Revise setinputsizes approach"
mike bayer [Thu, 23 Jul 2020 16:11:47 +0000 (16:11 +0000)] 
Merge "Revise setinputsizes approach"

4 years agoMerge "Allow Grouping to pass along proxy_set of element"
mike bayer [Thu, 23 Jul 2020 16:10:55 +0000 (16:10 +0000)] 
Merge "Allow Grouping to pass along proxy_set of element"

4 years agoAllow Grouping to pass along proxy_set of element
Mike Bayer [Tue, 21 Jul 2020 16:36:20 +0000 (12:36 -0400)] 
Allow Grouping to pass along proxy_set of element

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

4 years agoEnsure _distinct_on removed within from_selectable
Mike Bayer [Mon, 20 Jul 2020 20:51:24 +0000 (16:51 -0400)] 
Ensure _distinct_on removed within from_selectable

Fixes: #5469
Change-Id: I85498d3380c2efb595782d2ba92cfd692c3efc48

4 years agoRevise setinputsizes approach
Mike Bayer [Sun, 19 Jul 2020 21:39:14 +0000 (17:39 -0400)] 
Revise setinputsizes approach

in order to support asyncpg as well as pg8000,
we need to revise setinputsizes to work for more cases as well
as adjust NativeForEmulated a bit to work more completely with
the INTERVAL datatype.

- put most of the setinputsizes work into the compiler where
the computation can be cached.

- support per-element setinputsizes for a tuple

- adjust TypeDecorator so that _unwrapped_dialect_impl
will honor a type that the dialect links to directly in
it's adaption mapping.    Decouble _unwrapped_dialect_impl
from TypeDecorator._gen_dialect_impl() which has a different
purpose.   This allows setinputsizes to do the right thing
with the INTERVAL datatype.

- test cases for Oracle with Variant continue to work

Change-Id: I9e1ea33aeca3b92b365daa4a356d778191070c03

4 years agoFix mssql dialect escaping object names containing ']'
Gord Thompson [Sat, 18 Jul 2020 00:06:41 +0000 (18:06 -0600)] 
Fix mssql dialect escaping object names containing ']'

Fixes: #5467
Change-Id: I054ec219717ba62847a9daf1214e215dd6b70633

4 years agoMerge "Add requirement for test_get_view_definition"
mike bayer [Thu, 16 Jul 2020 18:57:13 +0000 (18:57 +0000)] 
Merge "Add requirement for test_get_view_definition"

4 years agoRepair test modified in 5de0f1cf50cc0170d8e
Mike Bayer [Thu, 16 Jul 2020 18:55:12 +0000 (14:55 -0400)] 
Repair test modified in 5de0f1cf50cc0170d8e

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

5 years agoRepair doubled "using engines in fork()" section
Mike Bayer [Wed, 15 Jul 2020 23:14:46 +0000 (19:14 -0400)] 
Repair doubled "using engines in fork()" section

This section was written twice in two different ways with
the same recipe.  consolidate into one section and
add additional caveats regading dispose.

Change-Id: I20524935e7c10e3624d561ea2735312fd04e673d
References: #5460

5 years agoAdd requirement for test_get_view_definition
Gord Thompson [Wed, 15 Jul 2020 22:00:56 +0000 (16:00 -0600)] 
Add requirement for test_get_view_definition

Bypass the test if the views are not being created.

Change-Id: I3945acb418575d12e5fe0e4657eb5e3b1c08b90e

5 years agoMerge "test single and double quote inspection scenarios"
mike bayer [Mon, 13 Jul 2020 19:07:35 +0000 (19:07 +0000)] 
Merge "test single and double quote inspection scenarios"

5 years agotest single and double quote inspection scenarios
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.

Fixes: #5456
Change-Id: I3bc98806f5166f3d82275650079ff561446f2aef

5 years agoMerge "more docs for autocommit isolation level"
mike bayer [Mon, 13 Jul 2020 15:17:51 +0000 (15:17 +0000)] 
Merge "more docs for autocommit isolation level"

5 years agoMerge "Make call-count profiling tests on osx have their own platform key"
mike bayer [Mon, 13 Jul 2020 02:02:45 +0000 (02:02 +0000)] 
Merge "Make call-count profiling tests on osx have their own platform key"

5 years agomore docs for autocommit isolation level
Mike Bayer [Sun, 12 Jul 2020 23:52:54 +0000 (19:52 -0400)] 
more docs for autocommit isolation level

this concept is not clear that we offer real
DBAPI autocommit everywhere.  backport 1.3 with edits
as well

Change-Id: I2e8328b7fb6e1cdc5453ab29c94276f60c7ca149

5 years agoCorrect mock call from 5de0f1cf50
Mike Bayer [Sun, 12 Jul 2020 14:48:03 +0000 (10:48 -0400)] 
Correct mock call from 5de0f1cf50

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

5 years agoCorrect incorrect readme.rst file
Mike Bayer [Sun, 12 Jul 2020 14:29:01 +0000 (10:29 -0400)] 
Correct incorrect readme.rst file

in the move to setup.cfg at
9ca81f5f79498356c4f3387c17edda0ed3dad451 we put the wrong
README file.

Change-Id: I25193d248e325e9473f26901925f91bef54ca07a

5 years agoFurther corrections to session docs
Mike Bayer [Sat, 11 Jul 2020 22:54:15 +0000 (18:54 -0400)] 
Further corrections to session docs

many more to come.

One issue is that references to documentation sections
inside of decorator-configured deprecation warnings will
also generate a meaningless token when the runtime warning
is emitted.  It would be nice to improve upon this somehow.

Change-Id: I16b214b3d310850bbfb0d9ade70235f5a9735eba

5 years agoMerge "Convert remaining ORM APIs to support 2.0 style"
mike bayer [Sat, 11 Jul 2020 18:59:14 +0000 (18:59 +0000)] 
Merge "Convert remaining ORM APIs to support 2.0 style"

5 years agoConvert remaining ORM APIs to support 2.0 style
Mike Bayer [Wed, 8 Jul 2020 18:31:17 +0000 (14:31 -0400)] 
Convert remaining ORM APIs to support 2.0 style

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

5 years agoMake call-count profiling tests on osx have their own platform key
Federico Caselli [Sat, 11 Jul 2020 17:10:26 +0000 (19:10 +0200)] 
Make call-count profiling tests on osx have their own platform key

They previously would use the linux profiles, but recently some discrepancies in
the function call count on osx would make the tests fail.

Change-Id: Ifdfdca1676972de4179f59cdaae196f6805d4a21

5 years agoMerge "Improvements to test_computed_col_default_not_set"
mike bayer [Thu, 9 Jul 2020 15:51:26 +0000 (15:51 +0000)] 
Merge "Improvements to test_computed_col_default_not_set"

5 years agoImprovements to test_computed_col_default_not_set
Rafi Shamim [Thu, 9 Jul 2020 14:35:33 +0000 (10:35 -0400)] 
Improvements to test_computed_col_default_not_set

<!-- Provide a general summary of your proposed changes in the Title field above -->

### Description
<!-- Describe your changes in detail -->
- Update the test so it looks at computed_default_table instead of
  computed_column_table.
- Stop inspecting autoincrement; instead directly check for
  default/non-default values for the relevant columns.

Fixes: #5414
### 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:

- [ ] 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!**

Closes: #5417
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5417
Pull-request-sha: 5918af6abb991e6d2322ea4252e56d456da628dc

Change-Id: Id9484ae7f297735345016be5b7461325825503da

5 years agoLimit init_subclass test above python 3.6
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.

Change-Id: Ie86b78bbfd8c7bd013ff9aa7f8905328d792c1b3

5 years agoPropose --nomemory by default
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.

Change-Id: Ibaead2d1c0a76f1339bee63652a8aead689e8b75

5 years agoRepair change of "future_select" caught in merge conflict
Mike Bayer [Wed, 8 Jul 2020 19:12:30 +0000 (15:12 -0400)] 
Repair change of "future_select" caught in merge conflict

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

5 years agoMerge remote-tracking branch 'origin/pr/5410'
Mike Bayer [Wed, 8 Jul 2020 18:41:48 +0000 (14:41 -0400)] 
Merge remote-tracking branch 'origin/pr/5410'

Change-Id: Ib052efc33ddd58d38e16c0cc721abee668b861d5

5 years agoMerge remote-tracking branch 'origin/pr/5439'
Mike Bayer [Wed, 8 Jul 2020 18:37:04 +0000 (14:37 -0400)] 
Merge remote-tracking branch 'origin/pr/5439'

Change-Id: Ibab5889b14c546a8c43c5eaf88ed5d1f53713880

5 years agoMerge "Add future=True to create_engine/Session; unify select()"
mike bayer [Wed, 8 Jul 2020 15:07:44 +0000 (15:07 +0000)] 
Merge "Add future=True to create_engine/Session; unify select()"

5 years agoAdd future=True to create_engine/Session; unify select()
Mike Bayer [Fri, 26 Jun 2020 20:15:19 +0000 (16:15 -0400)] 
Add future=True to create_engine/Session; unify select()

Several weeks of using the future_select() construct
has led to the proposal there be just one select() construct
again which features the new join() method, and otherwise accepts
both the 1.x and 2.x argument styles.   This would make
migration simpler and reduce confusion.

However, confusion may be increased by the fact that select().join()
is different  Current thinking is we may be better off
with a few hard behavioral changes to old and relatively unknown APIs
rather than trying to play both sides within two extremely similar
but subtly different APIs.  At the moment, the .join() thing seems
to be the only behavioral change that occurs without the user
taking any explicit steps.   Session.execute() will still
behave the old way as we are adding a future flag.

This change also adds the "future" flag to Session() and
session.execute(), so that interpretation of the incoming statement,
as well as that the new style result is returned, does not
occur for existing applications unless they add the use
of this flag.

The change in general is moving the "removed in 2.0" system
further along where we want the test suite to fully pass
even if the SQLALCHEMY_WARN_20 flag is set.

Get many tests to pass when SQLALCHEMY_WARN_20 is set; this
should be ongoing after this patch merges.

Improve the RemovedIn20 warning; these are all deprecated
"since" 1.4, so ensure that's what the messages read.
Make sure the inforamtion link is on all warnings.
Add deprecation warnings for parameters present and
add warnings to all FromClause.select() types of methods.

Fixes: #5379
Fixes: #5284
Change-Id: I765a0b912b3dcd0e995426427d8bb7997cbffd51
References: #5159

5 years agoMerge "ensure we unwrap desc() /label() all the way w/ order by"
mike bayer [Tue, 7 Jul 2020 18:58:18 +0000 (18:58 +0000)] 
Merge "ensure we unwrap desc() /label() all the way w/ order by"

5 years agoensure we unwrap desc() /label() all the way w/ order by
Mike Bayer [Tue, 7 Jul 2020 15:26:39 +0000 (11:26 -0400)] 
ensure we unwrap desc() /label() all the way w/ order by

The deprecated logic to move order_by expressions
up into the columns clause needed adjustment to accommodate
for a more deeply-wrapped structure when desc() + label()
 are combined in an order by column.  This structure
now comes from coercions in 1.4.  it's not clear to me
at the moment why it's different from 1.3 but
this shouldn't really matter.

Fixes: #5443
Change-Id: If909a86f715992318d7aa283603197f7711f1d3b

5 years agoMerge "Add **kw support to DeclarativeMeta.__init__"
mike bayer [Tue, 7 Jul 2020 00:18:20 +0000 (00:18 +0000)] 
Merge "Add **kw support to DeclarativeMeta.__init__"

5 years agoMerge "added semicolon (;) to improve warning message clarity"
mike bayer [Mon, 6 Jul 2020 20:48:18 +0000 (20:48 +0000)] 
Merge "added semicolon (;) to improve warning message clarity"

5 years agoAdd **kw support to DeclarativeMeta.__init__
EwenGillies [Sun, 5 Jul 2020 14:50:50 +0000 (10:50 -0400)] 
Add **kw support to DeclarativeMeta.__init__

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.

Fixes: #5357
Closes: #5363
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5363
Pull-request-sha: 0ad05a768316cba03a4d312ab39d3e8fbca7ac54

Change-Id: I1654befe9eb1c8b8e7fc0784bdbe64284614f0ea

5 years agoConsolidate connection customization documentation
Mike Bayer [Mon, 6 Jul 2020 15:11:54 +0000 (11:11 -0400)] 
Consolidate connection customization documentation

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.

Change-Id: Ibe366d2a6e63eb420a6136fdc71ce0fb545edf8f

5 years agoEnsure synchronize_session works with lambda statements
Mike Bayer [Sun, 5 Jul 2020 17:44:58 +0000 (13:44 -0400)] 
Ensure synchronize_session works with lambda statements

A few places have logic that assumes the top-level statement
is the actual UPDATE or DELETE which is not the case with a
lambda.  Ensure the correct object is used.  This
fixes issues specific to both "fetch" strategy
as well as "evaluate" strategy.

Fixes: #5442
Change-Id: Ic9cc01c696c3c338d5bc79688507e6717c4c169b

5 years agoDocument pyodbc built-in pooling
Mike Bayer [Sun, 5 Jul 2020 14:28:20 +0000 (10:28 -0400)] 
Document pyodbc built-in pooling

PyODBC apparently pools connections by default and this
is a module-wide setting only.    Documenent that this happens
and how to disable it.

Fixes: #5440
Change-Id: I415bda7beb2211c66991b6c804b0ddb4d79e427f

5 years agoresolves #3757 5439/head
RamonWill [Sat, 4 Jul 2020 17:17:40 +0000 (18:17 +0100)] 
resolves #3757

5 years agoresolves #5333 typo correction 'explcit' should be 'explicit'. 5410/head
RamonWill [Sat, 4 Jul 2020 13:30:19 +0000 (14:30 +0100)] 
resolves #5333 typo correction 'explcit' should be 'explicit'.

5 years agointroduce deferred lambdas
Mike Bayer [Mon, 16 Dec 2019 22:06:43 +0000 (17:06 -0500)] 
introduce deferred lambdas

The coercions system allows us to add in lambdas as arguments
to Core and ORM elements without changing them at all.   By allowing
the lambda to produce a deterministic cache key where we can also
cheat and yank out literal parameters means we can move towards
having 90% of "baked" functionality in a clearer way right in
Core / ORM.

As a second step, we can have whole statements inside the lambda,
and can then add generation with __add__(), so then we have
100% of "baked" functionality with full support of ad-hoc
literal values.

Adds some more short_selects tests for the moment for comparison.

Other tweaks inside cache key generation as we're trying to
approach a certain level of performance such that we can
remove the use of "baked" from the loader strategies.

As we have not yet closed #4639, however the caching feature
has been fully integrated as of
b0cfa7379cf8513a821a3dbe3028c4965d9f85bd, we will also
add complete caching documentation here and close that issue
as well.

Closes: #4639
Fixes: #5380
Change-Id: If91f61527236fd4d7ae3cad1f24c38be921c90ba

5 years agotypo
Mike Bayer [Thu, 2 Jul 2020 00:10:38 +0000 (20:10 -0400)] 
typo

Change-Id: I8b10309e47b07065893f6f41dfdbd67ad3e96bad

5 years agoenhance question template
Mike Bayer [Thu, 2 Jul 2020 00:08:42 +0000 (20:08 -0400)] 
enhance question template

we need to know all version / database information for questions
as well and users should be encouraged to follow MCVE form
if possible.

Change-Id: Ic3a4c4dbb021069b7765aa351a4d4d18a821160d

5 years agoAdd missing function to documentation: cte, values, Exits, Values
Federico Caselli [Tue, 30 Jun 2020 19:40:56 +0000 (21:40 +0200)] 
Add missing function to documentation: cte, values, Exits, Values

Fixes: #5432
Change-Id: I22e4ba3a7131165c551bcba7e377fa45d71d70e0

5 years agoadded semicolon (;) to improve warning message clarity
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)

No issue created, because this is minor.

Closes: #5431
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5431
Pull-request-sha: 87fb5733ff4fc1a13dd94277716814ea852f654c

Change-Id: I87a504d30a7dd5155c34f7d7f30b2116d0d3cd3f

5 years agoMerge "Use python version in extras_require; integrate with tox"
mike bayer [Mon, 29 Jun 2020 21:16:51 +0000 (21:16 +0000)] 
Merge "Use python version in extras_require; integrate with tox"

5 years agoMerge "Rename Table.tometadata to to_metadata"
mike bayer [Mon, 29 Jun 2020 19:50:29 +0000 (19:50 +0000)] 
Merge "Rename Table.tometadata to to_metadata"

5 years agoInclude DATETIME / DateTime with the MySQL TIMESTAMP examples
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.

Change-Id: I222522440706902d5d2d11e670e76f16000438e0
References: #5427

5 years agoMerge "Remove _generate_path_cache_key()"
mike bayer [Mon, 29 Jun 2020 19:36:37 +0000 (19:36 +0000)] 
Merge "Remove _generate_path_cache_key()"

5 years agoMerge "Provide example for exists"
mike bayer [Mon, 29 Jun 2020 19:05:53 +0000 (19:05 +0000)] 
Merge "Provide example for exists"

5 years agoMerge "Fixes: #4556 - Test that prevents passing a filter to Session.query when runni...
mike bayer [Mon, 29 Jun 2020 19:04:32 +0000 (19:04 +0000)] 
Merge "Fixes: #4556 - Test that prevents passing a filter to Session.query when running an update"

5 years agoUse python version in extras_require; integrate with tox
Mike Bayer [Mon, 29 Jun 2020 18:01:07 +0000 (14:01 -0400)] 
Use python version in extras_require; integrate with tox

We want to use Oracle version >=7 for all platforms,
but <8 for Python 2.

Similarly, we want to use mysqlclient >= 1.4.0 for all
platforms, but < 2 for Python 2.

Have tox.ini defer to setup.cfg for DBAPIs.

We're not testing mysql-connector-python right now so remove
this from tox.ini.

Change-Id: I02611937da71d2950545e42c34f0b9798478e2a8

5 years agoDocuemnt current workarounds for MySQL TIMESTAMP
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.

Fixes: #5427
Change-Id: Ie048dcc91c648dd0b80ed395208c1d665b6c968b

5 years agoRename Table.tometadata to to_metadata
Gord Thompson [Sat, 27 Jun 2020 14:53:23 +0000 (08:53 -0600)] 
Rename Table.tometadata to to_metadata

Renamed the :meth:`_schema.Table.tometadata` method to
:meth:`_schema.Table.to_metadata`.  The previous name remains with a
deprecation warning.

Updated the "decorate" utility function to support decoration
of functions that include non-builtins as default values.

Moves test for deprecated "databases" package into
test/dialect/test_deprecations.py

Fixes: #5413
Fixes: #5426
Change-Id: I6ed899871c935f9e46360127c17ccb7cf97cea6e

5 years agoRemove _generate_path_cache_key()
Mike Bayer [Sun, 28 Jun 2020 16:47:32 +0000 (12:47 -0400)] 
Remove _generate_path_cache_key()

loader options can now make a deterministic cache key based
 on the structure they are given, and this accommodates for
aliased classes as well so that these cache keys are now
"safe".     Have baked query call upon
the regular cache key method.

Change-Id: Iaa2ef4064cfb16146f415ca73080f32003dd830d

5 years agoAdd an extra step to pool test_sync
Mike Bayer [Sun, 28 Jun 2020 02:57:52 +0000 (22:57 -0400)] 
Add an extra step to pool test_sync

Have observed CI failure with windows where not all
three connections got pulled out at the same time here
as the threads got serialized.  make sure all three
connections get used.

Change-Id: Ic2f7c7de1069358d95035f90c725c7dddd4f34d4

5 years agoMerge "ORM executemany returning"
mike bayer [Sun, 28 Jun 2020 02:34:18 +0000 (02:34 +0000)] 
Merge "ORM executemany returning"

5 years agoORM executemany returning
Mike Bayer [Fri, 17 Apr 2020 14:55:08 +0000 (10:55 -0400)] 
ORM executemany returning

Build on #5401 to allow the ORM to take advanage
of executemany INSERT + RETURNING.

Implemented the feature

updated tests

to support INSERT DEFAULT VALUES, needed to come up with
a new syntax for compiler INSERT INTO table (anycol) VALUES (DEFAULT)
which can then be iterated out for executemany.

Added graceful degrade to plain executemany for PostgreSQL <= 8.2

Renamed EXECUTEMANY_DEFAULT to EXECUTEMANY_PLAIN

Fix issue where unicode identifiers or parameter names wouldn't
work with execute_values() under Py2K, because we have to
encode the statement and therefore have to encode the
insert_single_values_expr too.

Correct issue from #5401 to support executemany + return_defaults
for a PK that is explicitly pre-generated, meaning we aren't actually
getting RETURNING but need to return it from compiled_parameters.

Fixes: #5263
Change-Id: Id68e5c158c4f9ebc33b61c06a448907921c2a657

5 years agoProvide example for exists
Federico Caselli [Sat, 27 Jun 2020 19:46:28 +0000 (21:46 +0200)] 
Provide example for exists

Fixes: #5423
Change-Id: I716f8de17c49d7eefbbce5ddd9da203bfc9fe47f

5 years agoMerge "Fix a wide variety of typos and broken links"
mike bayer [Fri, 26 Jun 2020 15:30:57 +0000 (15:30 +0000)] 
Merge "Fix a wide variety of typos and broken links"

5 years agoMerge "Default psycopg2 executemany mode to "values_only""
mike bayer [Fri, 26 Jun 2020 00:13:25 +0000 (00:13 +0000)] 
Merge "Default psycopg2 executemany mode to "values_only""

5 years agoFix a wide variety of typos and broken links
aplatkouski [Mon, 22 Jun 2020 15:34:39 +0000 (11:34 -0400)] 
Fix a wide variety of typos and broken links

Note the PR has a few remaining doc linking issues
listed in the comment that must be addressed separately.

Signed-off-by: aplatkouski <5857672+aplatkouski@users.noreply.github.com>
Closes: #5371
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5371
Pull-request-sha: 7e7d233cf3a0c66980c27db0fcdb3c7d93bc2510

Change-Id: I9c36e8d8804483950db4b42c38ee456e384c59e3

5 years agoDefault psycopg2 executemany mode to "values_only"
Mike Bayer [Tue, 23 Jun 2020 20:21:04 +0000 (16:21 -0400)] 
Default psycopg2 executemany mode to "values_only"

The psycopg2 dialect now defaults to using the very performant
``execute_values()`` psycopg2 extension for compiled INSERT statements,
and also impements RETURNING support when this extension is used.  This
allows INSERT statements that even include an autoincremented SERIAL
or IDENTITY value to run very fast while still being able to return the
newly generated primary key values.   The ORM will then integrate this
new feature in a separate change.

Implements RETURNING for insert with executemany

Adds support to return_defaults() mode and inserted_primary_key
to support mutiple INSERTed rows, via return_defauls_rows
and inserted_primary_key_rows accessors.

within default execution context, new cached compiler
getters are used to fetch primary keys from rows

inserted_primary_key now returns a plain tuple. this
is not yet a row-like object however this can be
added.

Adds distinct "values_only" and "batch" modes, as
"values" has a lot of benefits but "batch" breaks
cursor.rowcount

psycopg2 minimum version 2.7 so we can remove the
large number of checks for very old versions of
psycopg2

simplify tests to no longer distinguish between
native and non-native json

Fixes: #5401
Change-Id: Ic08fd3423d4c5d16ca50994460c0c234868bd61c

5 years agocherry-pick changelog update for 1.3.19
Mike Bayer [Thu, 25 Jun 2020 19:00:50 +0000 (15:00 -0400)] 
cherry-pick changelog update for 1.3.19

5 years agocherry-pick changelog from 1.3.18
Mike Bayer [Thu, 25 Jun 2020 19:00:49 +0000 (15:00 -0400)] 
cherry-pick changelog from 1.3.18

5 years agoMerge "Use index name to determine if an index is for the PK"
mike bayer [Thu, 25 Jun 2020 18:25:26 +0000 (18:25 +0000)] 
Merge "Use index name to determine if an index is for the PK"

5 years agoUse index name to determine if an index is for the PK
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.

Fixes: #5421
Change-Id: I47c2ccdd0b13977cfd9ef249d4de06371c4fb241

5 years agoUse time.perf_counter() for cache time measurement
Mike Bayer [Wed, 24 Jun 2020 23:47:52 +0000 (19:47 -0400)] 
Use time.perf_counter() for cache time measurement

See https://twitter.com/raymondh/status/1275937373080023040

Change-Id: Iaa0abb0c433ccedfbd88d00e3970120242ba379b

5 years agoFixes: #4556 - Test that prevents passing a filter to Session.query when running...
ramonvg [Wed, 24 Jun 2020 13:51:56 +0000 (09:51 -0400)] 
Fixes: #4556 - Test that prevents passing a filter to Session.query when running an update
### Description
There was a bug in 1.3.8 that allowed passing a `BinaryExpression` to `Session().query`. I assume it was fixed in https://github.com/sqlalchemy/sqlalchemy/commit/3ab2364e78641c4f0e4b6456afc2cbed39b0d0e6 since now it raises:
```
sqlalchemy.exc.ArgumentError: subject table for an INSERT, UPDATE or DELETE expected, got <sqlalchemy.sql.elements.BinaryExpression object at 0x7f3d90426370>.
```

I'm just adding a test that ensures the behavior. Fixes: [4556](https://github.com/sqlalchemy/sqlalchemy/issues/4556)

### 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:

- [ ] 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!**

Closes: #5419
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5419
Pull-request-sha: af7601dff1a0dce94802627a9fe2398be60d8186

Change-Id: Ic1a9075e7e8520510964fdd3d7ac14fba550110c

5 years agoMerge "Propose using RETURNING for bulk updates, deletes"
mike bayer [Tue, 23 Jun 2020 15:55:39 +0000 (15:55 +0000)] 
Merge "Propose using RETURNING for bulk updates, deletes"

5 years agoPropose using RETURNING for bulk updates, deletes
Mike Bayer [Sun, 21 Jun 2020 16:21:21 +0000 (12:21 -0400)] 
Propose using RETURNING for bulk updates, deletes

This patch makes several improvements in the area of
bulk updates and deletes as well as the new session mechanics.

RETURNING is now used for an UPDATE or DELETE statement
emitted for a diaelct that supports "full returning"
in order to satisfy the "fetch" strategy; this currently
includes PostgreSQL and SQL Server.  The Oracle dialect
does not support RETURNING for more than one row,
so a new dialect capability "full_returning" is added
in addition to the existing "implicit_returning", indicating
this dialect supports RETURNING for zero or more rows,
not just a single identity row.

The "fetch" strategy will gracefully degrade to
the previous SELECT mechanics for dialects that do not
support RETURNING.

Additionally, the "fetch" strategy will attempt to use
evaluation for the VALUES that were UPDATEd, rather
than just expiring the updated attributes.   Values should
be evalutable in all cases where the value is not
a SQL expression.

The new approach also incurs some changes in the
session.execute mechanics, where do_orm_execute() event
handlers can now be chained to each return results;
this is in turn used by the handler to detect on a
per-bind basis if the fetch strategy needs to
do a SELECT or if it can do RETURNING.  A test suite is
added to test_horizontal_shard that breaks up a single
UPDATE or DELETE operation among multiple backends
where some are SQLite and don't support RETURNING and
others are PostgreSQL and do.

The session event mechanics are corrected
in terms of the "orm pre execute" hook, which now
receives a flag "is_reentrant" so that the two
ORM implementations for this can skip on their work
if they are being called inside of ORMExecuteState.invoke(),
where previously bulk update/delete were calling its
SELECT a second time.

In order for "fetch" to get the correct identity when
called as pre-execute, it also requests the identity_token
for each mapped instance which is now added as an optional
capability of a SELECT for ORM columns.   the identity_token
that's placed by horizontal_sharding is now made available
within each result row, so that even when fetching a
merged result of plain rows we can tell which row belongs
to which identity token.

The evaluator that takes place within the ORM bulk update and delete for
synchronize_session="evaluate" now supports the IN and NOT IN operators.
Tuple IN is also supported.

Fixes: #1653
Change-Id: I2292b56ae004b997cef0ba4d3fc350ae1dd5efc1

5 years agoAdd pip list to workflow, update setuptools
Federico Caselli [Mon, 22 Jun 2020 18:01:38 +0000 (20:01 +0200)] 
Add pip list to workflow, update setuptools

Change-Id: I2e32ba315a79dcfc7c5f79ed6517ac0cee4f55e3

5 years agoMerge "Apply dialect_options copy fix"
mike bayer [Sat, 20 Jun 2020 18:48:34 +0000 (18:48 +0000)] 
Merge "Apply dialect_options copy fix"

5 years agoMerge "Propose black py27 + py35 mode for the rest of Py2K"
mike bayer [Fri, 19 Jun 2020 21:44:18 +0000 (21:44 +0000)] 
Merge "Propose black py27 + py35 mode for the rest of Py2K"

5 years agoMerge "Added reflection method :meth:`.Inspector.get_sequence_names`"
mike bayer [Fri, 19 Jun 2020 21:00:37 +0000 (21:00 +0000)] 
Merge "Added reflection method :meth:`.Inspector.get_sequence_names`"

5 years agoMerge "Move most setup options to setup.cfg"
mike bayer [Fri, 19 Jun 2020 20:55:46 +0000 (20:55 +0000)] 
Merge "Move most setup options to setup.cfg"

5 years agoMove most setup options to setup.cfg
Mike Bayer [Thu, 18 Jun 2020 22:45:40 +0000 (18:45 -0400)] 
Move most setup options to setup.cfg

Installation has been modernized to use setup.cfg for most package
metadata.

Fixes: #5404
Change-Id: Id59c0c4e7f81eca89999d1f1f8b03c89835a09d1

5 years agoMerge "perf tweaks"
mike bayer [Fri, 19 Jun 2020 15:21:39 +0000 (15:21 +0000)] 
Merge "perf tweaks"

5 years agoAdd note indicating order of join() calls are important
Mike Bayer [Fri, 19 Jun 2020 15:06:08 +0000 (11:06 -0400)] 
Add note indicating order of join() calls are important

Fixes: #5406
Change-Id: I186792b32bd156d5ddf256dcd018af32ad5b515e

5 years agoPropose black py27 + py35 mode for the rest of Py2K
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.

Change-Id: Iceb9e9aeb5f5e0d317fb877ef06eca0290997fe4

5 years agoperf tweaks
Mike Bayer [Fri, 19 Jun 2020 04:32:00 +0000 (00:32 -0400)] 
perf tweaks

- avoid abc checks in distill_20
- ColumnEntity subclasses are unique to their compile state and
have no querycontext specific state.  They can do a simple memoize of their
fetch_column without using attributes, and they can memoize their
_getter() too so that it goes into the cache, just like
instance_processor() does.
- unify ORMColumnEntity and RawColumnEntity for the row processor part,
add some test coverage for the case where it is used in a from_statement
- do a faster generate if there are no memoized entries
- query._params is always immutabledict
Change-Id: I1e2dfe607a1749b5b434fc11f9348ee631501dfa

5 years agoApply dialect_options copy fix
Gord Thompson [Sat, 6 Jun 2020 16:04:34 +0000 (10:04 -0600)] 
Apply dialect_options copy fix

Fixes: #5276
Change-Id: Ic608310d4a85934fc9fa4d72daef66323c6e2525

5 years agoWarn when transaction context manager ends on inactive transaction
Mike Bayer [Fri, 12 Jun 2020 17:09:15 +0000 (13:09 -0400)] 
Warn when transaction context manager ends on inactive transaction

if .rollback() or .commit() is called inside the transaction
context manager, the transaction object is deactivated.
the context manager continues but will not be able to correctly
fulfill it's closing state.  Ensure a warning is emitted when
this happens.

Change-Id: I8fc3a73f7c21575dda5bcbd6fb74ddb679771630

5 years agoAdd version token to error URL
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).

Change-Id: I3bb463fd6fb6c8767c95a57f3699aba715a9a72d

5 years agoAdd 'exists' to SQLite's reserved keywords
Thodoris Sotiropoulos [Thu, 11 Jun 2020 14:50:41 +0000 (10:50 -0400)] 
Add 'exists' to SQLite's reserved keywords

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.

Fixes: #5395
Closes: #5396
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5396
Pull-request-sha: 5608317a38db7b63115e3b467d182a3e5cc31580

Change-Id: Ia4769de2dec159dcf282eb4b30c11560da51a5c7

5 years agoMerge "Add documentation regarding row constructo in PostgreSQL"
mike bayer [Thu, 11 Jun 2020 03:14:46 +0000 (03:14 +0000)] 
Merge "Add documentation regarding row constructo in PostgreSQL"

5 years agoMerge "Improve ``Rendering Bound Parameters Inline`` documentation"
mike bayer [Thu, 11 Jun 2020 03:13:28 +0000 (03:13 +0000)] 
Merge "Improve ``Rendering Bound Parameters Inline`` documentation"

5 years agoMerge "Turn on caching everywhere, add logging"
mike bayer [Wed, 10 Jun 2020 22:03:37 +0000 (22:03 +0000)] 
Merge "Turn on caching everywhere, add logging"

5 years agoTurn on caching everywhere, add logging
Mike Bayer [Sun, 7 Jun 2020 00:40:43 +0000 (20:40 -0400)] 
Turn on caching everywhere, add logging

A variety of caching issues found by running
all tests with statement caching turned on.

The cache system now has a more conservative approach where
any subclass of a SQL element will by default invalidate
the cache key unless it adds the flag inherit_cache=True
at the class level, or if it implements its own caching.

Add working caching to a few elements that were
omitted previously; fix some caching implementations
to suit lesser used edge cases such as json casts
and array slices.

Refine the way BaseCursorResult and CursorMetaData
interact with caching; to suit cases like Alembic
modifying table structures, don't cache the
cursor metadata if it were created against a
cursor.description using non-positional matching,
e.g. "select *".   if a table re-ordered its columns
or added/removed, now that data is obsolete.

Additionally we have to adapt the cursor metadata
_keymap regardless of if we just processed
cursor.description, because if we ran against
a cached SQLCompiler we won't have the right
columns in _keymap.

Other refinements to how and when we do this
adaption as some weird cases
were exposed in the Postgresql dialect,
a text() construct that names just one column that
is not actually in the statement.   Fixed that
also as it looks like a cut-and-paste artifact
that doesn't actually affect anything.

Various issues with re-use of compiled result maps
and cursor metadata in conjunction with tables being
changed, such as change in order of columns.

mappers can be cleared but the class remains, meaning
a mapper has to use itself as the cache key not the class.

lots of bound parameter / literal issues, due to Alembic
creating a straight subclass of bindparam that renders
inline directly.   While we can update Alembic to not
do this, we have to assume other people might be doing
this, so bindparam() implements the inherit_cache=True
logic as well that was a bit involved.

turn on cache stats in logging.

Includes a fix to subqueryloader which moves all setup to
the create_row_processor() phase and elminates any storage
within the compiled context.   This includes some changes
to create_row_processor() signature and a revising of the
technique used to determine if the loader can participate
in polymorphic queries, which is also applied to
selectinloading.

DML update.values() and ordered_values() now coerces the
keys as we have tests that pass an arbitrary class here
which only includes __clause_element__(), so the
key can't be cached unless it is coerced.  this in turn
changed how composite attributes support bulk update
to use the standard approach of ClauseElement with
annotations that are parsed in the ORM context.

memory profiling successfully caught that the Session
from Query was getting passed into _statement_20()
so that was a big win for that test suite.

Apparently Compiler had .execute() and .scalar() methods
stuck on it, these date back to version 0.4 and there
was a single test in the PostgreSQL dialect tests
that exercised it for no apparent reason.   Removed
these methods as well as the concept of a Compiler
holding onto a "bind".

Fixes: #5386
Change-Id: I990b43aab96b42665af1b2187ad6020bee778784

5 years agoMerge "updated historical terms with modern equivalents"
mike bayer [Tue, 9 Jun 2020 16:28:00 +0000 (16:28 +0000)] 
Merge "updated historical terms with modern equivalents"

5 years agoFix capitalization typos in engines.rst 5385/head
Abraham Sangha [Mon, 8 Jun 2020 16:17:09 +0000 (10:17 -0600)] 
Fix capitalization typos in engines.rst

5 years agoConvert bulk update/delete to new execution model
Mike Bayer [Wed, 3 Jun 2020 21:38:35 +0000 (17:38 -0400)] 
Convert bulk update/delete to new execution model

This reorganizes the BulkUD model in sqlalchemy.orm.persistence
to be based on the CompileState concept and to allow plain
update() / delete() to be passed to session.execute() where
the ORM synchronize session logic will take place.
Also gets "synchronize_session='fetch'" working with horizontal
sharding.

Adding a few more result.scalar_one() types of methods
as scalar_one() seems like what is normally desired.

Fixes: #5160
Change-Id: I8001ebdad089da34119eb459709731ba6c0ba975

5 years agoupdated historical terms with modern equivalents
jonathan vanasco [Sat, 6 Jun 2020 01:58:23 +0000 (21:58 -0400)] 
updated historical terms with modern equivalents

### 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

Closes: #5381
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5381
Pull-request-sha: 92597e83d0e1e18960dbb39b604b313e7a1cbb30

Change-Id: I1fb34fe5ab6c19fd7360568d7b51cdea9d271b3b

5 years agoFix connection string escaping for mssql+pyodbc
Gord Thompson [Thu, 4 Jun 2020 18:38:13 +0000 (12:38 -0600)] 
Fix connection string escaping for mssql+pyodbc

Fixes: #5373
Change-Id: Ia41e8f1ef8644c54d23ebfdf3f909c785adf0fb0

5 years agoImprove ``Rendering Bound Parameters Inline`` documentation
Federico Caselli [Thu, 4 Jun 2020 17:53:29 +0000 (19:53 +0200)] 
Improve ``Rendering Bound Parameters Inline`` documentation

This is mainly to make this section more discoverable by users

Change-Id: I58ba19e4a9ae85b227e5b5553ba5c30c01f3e005

5 years agoDocument that type_coerce does not currently imply parenthesization
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.

Fixes: #5375
Change-Id: I97414762a87ec8f1fd1adc1b6be5a52e576814ca
References: #5344

5 years agoMerge "Folds two identical exception handlers into a single one"
mike bayer [Wed, 3 Jun 2020 22:23:32 +0000 (22:23 +0000)] 
Merge "Folds two identical exception handlers into a single one"

5 years agoMerge "Default create_constraint to False"
mike bayer [Wed, 3 Jun 2020 22:22:37 +0000 (22:22 +0000)] 
Merge "Default create_constraint to False"

5 years agoDefault create_constraint to False
Mike Bayer [Tue, 2 Jun 2020 18:21:03 +0000 (14:21 -0400)] 
Default create_constraint to False

The :paramref:`.Enum.create_constraint` and
:paramref:`.Boolean.create_constraint` parameters now default to False,
indicating when a so-called "non-native" version of these two datatypes is
created, a CHECK constraint will not be generated by default.   These CHECK
constraints present schema-management maintenance complexities that should
be opted in to, rather than being turned on by default.

Fixes: #5367
Change-Id: I0a3fb608ce32143fa757546cc17ba2013e93272a