Commit Graph

13289 Commits

Author SHA1 Message Date
Mike Bayer 3710382de1 update selectin docs
* correct many-to-one example that doesnt use JOIN or ORDER BY
anymore

* Oracle does tuple IN, let's test it

* many-to-many is supported but joins all the way right now

* remove verbiage about yield_per for the moment to simplify
updates to how yield_per works w/ new style execution.  yield_per
is difficult to explain and the section seems kind of complicated
with those details added at the moment.

Change-Id: I010ed36f554f06310f336a5b12760c447b38ec01
2020-10-31 19:36:09 -04:00
mike bayer 78d60e108e Merge "tutorial 2.0 WIP" 2020-10-31 19:50:07 +00:00
Mike Bayer 654b462d66 tutorial 2.0 WIP
Add SelectBase.exists() method as it seems strange this is
not available already.  The Exists construct itself does
not provide full SELECT-building capabilities so it makes
sense this should be used more like a scalar_subquery.

Make sure stream_results is getting set up when yield_per
is used, for 2.0 style statements as well.  this was
hardcoded inside of Query.yield_per() and is now moved
to take place within QueryContext.

Change-Id: Icafcd4fd9b708772343d56edf40995c9e8f835d6
2020-10-31 13:44:53 -04:00
mike bayer b159d0942c Merge "while working on #5435, I found some misses from the previous PR for #5429" 2020-10-31 14:54:39 +00:00
mike bayer c67b338590 Merge "Deprecate bind args, execute() methods that were missed" 2020-10-31 01:05:01 +00:00
Mike Bayer 0718add371 Deprecate bind args, execute() methods that were missed
in particular text(bind), DDL.execute().

Change-Id: Ie85ae9f61219182f5649f68e5f52b4923843199c
2020-10-30 20:22:13 -04:00
jonathan vanasco 580657f068 while working on #5435, I found some misses from the previous PR for #5429
Change-Id: I0be15f6234c74302734672450a3275add762bdb8
2020-10-30 11:59:47 -04:00
mike bayer 841eb21664 Merge "Apply underscore naming to several more operators" 2020-10-30 15:14:18 +00:00
jonathan vanasco 9ddbd585a6 Apply underscore naming to several more operators
The operator changes are:

* `isfalse` is now `is_false`
* `isnot_distinct_from` is now `is_not_distinct_from`
* `istrue` is now `is_true`
* `notbetween` is now `not_between`
* `notcontains` is now `not_contains`
* `notendswith` is now `not_endswith`
* `notilike` is now `not_ilike`
* `notlike` is now `not_like`
* `notmatch` is now `not_match`
* `notstartswith` is now `not_startswith`
* `nullsfirst` is now `nulls_first`
* `nullslast` is now `nulls_last`

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.

Fixes: #5435
Change-Id: Ifbd7cb1cdda5981990243c4fc4b4ff467dc132ac
2020-10-30 10:02:29 -04:00
Mike Bayer 163a97c6d5 rename "bulk" UPDATE and DELETE to not use the word "bulk"
This term confuses this feature with the lesser used
"bulk insert/update" feature, and also "bulk" is not as
descriptive here as only a single statement is run; there's
not a large set of data passed in.

For now call it UPDATE/DELETE with arbitrary WHERE clause,
or ORM-enabled UPDATE/DELETE.

Change-Id: I317fcda9d73d4c2dd250031a745dd3d72e4f1fc6
2020-10-29 23:23:26 -04:00
Mike Bayer b9f7a92d82 Clarify bulk operations caveats
Fixes: #5678
Change-Id: I186b26d1265c106bb87fb9e680229cad1eb8d7ea
2020-10-29 23:12:19 -04:00
Mike Bayer 22af738cc1 Implement PropComparator.and_() for remaining options
In c7b489b258 we implemented
with_loader_criteria() for everyone as well as PropComparator.and_()
for joinedload() and join(), but forgot to do anything for
lazyload(), selectinload(), or subqueryload().  Even though
I actually documented it in terms of lazyload().

Fixes: #4472
Change-Id: I0ef410a83c34e63b9c9c9c3277c0063d8971ec14
2020-10-29 14:34:22 -04:00
jonathan vanasco 10851b0028 added docstring about expire_on_commit for #5243
Fixes: #5243
Closes: #5328
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5328
Pull-request-sha: e760ed4ef1

Change-Id: I8e7bc3429dc279d447cc66400c76b4d2a04626aa
2020-10-26 10:49:27 -04:00
mike bayer 8d588b06d9 Merge "Correct reflection for composite primary keys" 2020-10-26 14:29:12 +00:00
Mike Bayer a1c51879ae improve engine logging docs
the text here was a little confusing and didn't refer to major
configurational elements such as hide_parameters.

Change-Id: I4e2179e5a64c326d30b65a8871b924725c41b453
2020-10-24 12:59:22 -04:00
fulpm 7937a409f9 Correct reflection for composite primary keys
Fixes: #5661

### Description
Fixes reflection of composite primary keys to maintain the correct column order in the MSSQL
and SQLite dialects.

Closes: #5662
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5662
Pull-request-sha: b568dec707

Change-Id: I452b23cbf7f389c4a0a34cffce5c32498efe37d2
2020-10-21 17:47:33 -06:00
Mike Bayer 91e14cc42c Don't load expired objects from evaluator
part 2 of e3dc20ff27, the
pre-evaluate step was also emitting SELECT for expired objects.

Fixes: #5664
Change-Id: I9f5de2a5d480eafeb290ec0c45ce2a82ec93475b
2020-10-21 15:22:52 -04:00
Mike Bayer e3dc20ff27 Don't populate expired attrs w/ evaluator
Fixed bug in :meth:`_orm.Query.update` where objects in the
:class:`_orm.Session` that were already expired would be unnecessarily
SELECTed individually when they were refreshed by the "evaluate"
synchronize strategy.

For 1.4 there was also a similar issue with fetch that would actually
get the wrong data back, as the new value would be loaded, then
applied with the evaluator.

Fixes: #5664
Change-Id: I6e6aff88462654fcefa9fce2b45f5446c418deee
2020-10-21 14:03:12 -04:00
Mike Bayer 04d45f8ade Improve assoc proxy docs for 1.3 changes
Fixes: #5647
Change-Id: I98979577f5354eba993ade9fc5056db718f47a18
2020-10-20 10:46:34 -04:00
Mike Bayer e9051d9b44 Add FAQ entry for retry subject; recipe w/ autocommit
In order to invalidate a connection within a Transaction
block and an execution context, we need to take advantage
of the simpler transaction design added in 1.4.  The recipe
can be done on 1.3 but it requires a lot more hacking
and isn't worth it.

Clearly since the recipe is part of the tests now we can
in the future consider adding a feature that's built
in for this case but it would have to absolutely guarantee
the DBAPI is in autocommit mode and also prevent
any "write" operations from taking place.   Recipe for now.

Fixes: #5657
Change-Id: Ia9ea8cced084d154e83e4d1c259e080b776ec38a
2020-10-19 18:48:58 -04:00
Mike Bayer 3e49b8d051 Ensure no compiler visit method tries to access .statement
Fixed structural compiler issue where some constructs such as MySQL /
PostgreSQL "on conflict / on duplicate key" would rely upon the state of
the :class:`_sql.Compiler` object being fixed against their statement as
the top level statement, which would fail in cases where those statements
are branched from a different context, such as a DDL construct linked to a
SQL statement.

Fixes: #5656
Change-Id: I568bf40adc7edcf72ea6c7fd6eb9d07790de189e
2020-10-19 13:13:15 -04:00
Mike Bayer 296c84313a Ensure escaping of percent signs in columns, parameters
Improved support for column names that contain percent signs in the string,
including repaired issues involving anoymous labels that also embedded a
column name with a percent sign in it, as well as re-established support
for bound parameter names with percent signs embedded on the psycopg2
dialect, using a late-escaping process similar to that used by the
cx_Oracle dialect.

* Added new constructor for _anonymous_label() that ensures incoming
  string tokens based on column or table names will have percent
  signs escaped; abstracts away the format of the label.

* generalized cx_Oracle's quoted_bind_names facility into the compiler
  itself, and leveraged this for the psycopg2 dialect's issue with
  percent signs in names as well.  the parameter substitution is now
  integrated with compiler.construct_parameters() as well as the
  recently reworked set_input_sizes(), reducing verbosity in the
  cx_Oracle dialect.

Fixes: #5653

Change-Id: Ia2ad13ea68b4b0558d410026e5a33f5cb3fbab2c
2020-10-17 13:15:57 -04:00
mike bayer 3179f70408 Merge "Add deprecation for base Executable.bind" 2020-10-17 14:11:48 +00:00
Mike Bayer 5162f2bc5f Add deprecation for base Executable.bind
These attributes will be removed in SQLAlchemy 2.0.

Also alters the deprecation message to qualify the
type of object correctly.  this in turn requires changes
in the warnings filter and deprecation tests.

Change-Id: I5779d9813e88f42e5db0c7b5e3ffff1d1535c203
2020-10-16 19:15:58 -04:00
Mike Bayer 87c24c498c Genericize setinputsizes and support pyodbc
Reworked the "setinputsizes()" set of dialect hooks to be correctly
extensible for any arbirary DBAPI, by allowing dialects individual hooks
that may invoke cursor.setinputsizes() in the appropriate style for that
DBAPI.   In particular this is intended to support pyodbc's style of usage
which is fundamentally different from that of cx_Oracle.  Added support
for pyodbc.

Fixes: #5649
Change-Id: I9f1794f8368bf3663a286932cfe3992dae244a10
2020-10-16 14:28:04 -04:00
Mike Bayer 41d3e16773 indicate legacy ping recipe for handle_error cases
in prep for a new feature as part of #5648.

Change-Id: I6720b0ea797c188de5e8163f79fb7b7994d6e76e
2020-10-15 13:21:34 -04:00
Mike Bayer a2ea05800d move misplaced section
Change-Id: I472049fbdda70da94bbf1cf7b5e10d04721bc771
2020-10-14 18:18:13 -04:00
Mike Bayer f2615fac0b Merge remote-tracking branch 'origin/pr/5636'
Change-Id: I785a3c8a49f2d75279ade65bd86915de1178a3ff
2020-10-14 16:37:40 -04:00
mike bayer 2555f095d0 Merge "Add SQL Server 01000 disconnect" 2020-10-14 20:34:43 +00:00
Mike Bayer b03d5358ec block python keywords from random list of names
Change-Id: I0259bed2ee06e741889e8b9bed6bf6ad106fa425
2020-10-14 13:50:44 -04:00
Mike Bayer 01633d94a5 Add SQL Server 01000 disconnect
Fixes: #5646
Change-Id: I25fcba7cf866871f1232b586e7e604162bd8cc43
2020-10-14 13:14:42 -04:00
mike bayer 3bdf56dc7d Merge "Deprecate strings indicating attribute names" 2020-10-14 15:00:49 +00:00
Evan Taylor Yates 7740ce6900 Add discussed changes
PR link: https://github.com/sqlalchemy/sqlalchemy/pull/5636
2020-10-13 12:21:30 -07:00
Mike Bayer 348260943a Deprecate strings indicating attribute names
Using strings to represent relationship names in ORM operations such as
:meth:`_orm.Query.join`, as well as strings for all ORM attribute names
in loader options like :func:`_orm.selectinload`
is deprecated and will be removed in SQLAlchemy 2.0.  The class-bound
attribute should be passed instead.  This provides much better specificity
to the given method, allows for modifiers such as ``of_type()``, and
reduces internal complexity.

Additionally, the ``aliased`` and ``from_joinpoint`` parameters to
:meth:`_orm.Query.join` are also deprecated.   The :func:`_orm.aliased`
construct now provides for a great deal of flexibility and capability
and should be used directly.

Fixes: #4705
Fixes: #5202
Change-Id: I32f61663d68026154906932913c288f269991adc
2020-10-13 14:43:38 -04:00
Mike Bayer 34f8622b68 cherry-pick changelog update for 1.3.21 2020-10-12 18:33:32 -04:00
Mike Bayer a2cb257ec9 cherry-pick changelog from 1.3.20 2020-10-12 18:33:31 -04:00
Mike Bayer 501c5dff8e typo
Change-Id: I0a753a2b48ed932c3209b93df0a96efe90af17c5
2020-10-12 18:29:20 -04:00
Mike Bayer 6bf0e4ce35 changelog edits for 1.3.20
Change-Id: Ic053a30e9f0e6c99b638a0629e1192336bff3f76
2020-10-12 18:22:01 -04:00
RamonWill 1cda8e18bf Support indexing on expressions and functions for the MySQL dialect
A user noticed that creating an index where the "key part" was an expression
or function would raise an error for MySQL because the key part was not
parenthesized. The proposed change will check whether a key part is not a
Column or Unary Expression  and parenthesize if the case is False.

This fix also contains a minor fix to a test case that was previously incorrect
(`def test_create_index_expr():`).

**Have a nice day!**
Fixes: #5462

Closes: #5587
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5587
Pull-request-sha: 7515e50cd7

Change-Id: Id1b3b3026983c0e05808baa243e354f82b78180c
2020-10-12 17:38:34 -04:00
mike bayer 3fcdb7cca0 Merge "Deprecate bound metadata" 2020-10-12 19:51:53 +00:00
Mike Bayer c76e3776f5 Deprecate bound metadata
The :paramref:`_schema.MetaData.bind` argument as well as the overall
concept of "bound metadata" is deprecated in SQLAlchemy 1.4 and will be
removed in SQLAlchemy 2.0.  The parameter as well as related functions now
emit a :class:`_exc.RemovedIn20Warning` when :ref:`deprecation_20_mode` is
in use.

Added new parameter :paramref:`_automap.AutomapBase.prepare.autoload_with`
which supersedes :paramref:`_automap.AutomapBase.prepare.reflect`
and :paramref:`_automap.AutomapBase.prepare.engine`.

Fixes: #4634
Fixes: #5142

Change-Id: Iaabf9b481931e2fb68b97b5954c32e65772a298e
2020-10-12 13:57:43 -04:00
Mike Bayer 9e82f32f27 Deprecate duplicated column names in Table definition
The :class:`_schema.Table` class now raises a deprecation warning
when columns with the same name are defined. To replace a column a new
parameter :paramref:`_schema.Table.append_column.replace_existing` was
added to the :meth:`_schema.Table.append_column` method.

The :meth:`_expression.ColumnCollection.contains_column` will now
raises an error when called with a string, suggesting the caller
to use ``in`` instead.

Co-authored-by: Federico Caselli <cfederico87@gmail.com>
Change-Id: I1d58c8ebe081079cb669e7ead60886ffc1b1a7f5
2020-10-12 13:52:06 -04:00
mike bayer a3e2eb7c3c Merge "Repair reduction in Over" 2020-10-12 17:45:10 +00:00
Mike Bayer 9322de12f5 Repair reduction in Over
Fixed issue where a plain pickle dumps call of the :class:`_sql.Over`
construct didn't work.

Fixes: #5644
Change-Id: I4b07f74ecd5d52f0794128585367012200a38a36
2020-10-12 12:48:17 -04:00
Mike Bayer 286fe9b0b1 Ensure all cursor self.handle_exception() calls are covered
Fixes: #5642
Change-Id: I07a77483e6e2ec593d87d3d3467a4339c5f77a26
2020-10-12 12:31:10 -04:00
Mike Bayer b2f2bf1acc repair pg8000 and pin to 1.16.6 min version
Due to https://github.com/tlocke/pg8000/commit/3a2e7439ae3613367ec231218d7e0f541466d1e5
we no longer decode the description.  pin to 1.16.6 as minimum version
so that we don't need to track version changes in code.

Change-Id: I192c851eb2337f37467560a3cbb87f7235884788
2020-10-12 12:03:40 -04:00
mike bayer d0b5ce2ad4 Merge "Drop python 3.5 support" 2020-10-10 16:02:26 +00:00
mike bayer 2827aa9119 Merge "generalize scoped_session proxying and apply to asyncio elements" 2020-10-10 06:01:17 +00:00
Mike Bayer 2665a0c4cb generalize scoped_session proxying and apply to asyncio elements
Reworked the proxy creation used by scoped_session() to be
based on fully copied code with augmented docstrings and
moved it into langhelpers.  asyncio session, engine,
connection can now take
advantage of it so that all non-async methods are availble.

Overall implementation of most important accessors / methods
on AsyncConnection, etc. , including awaitable versions
of invalidate, execution_options, etc.

In order to support an event dispatcher on the async
classes while still allowing them to hold __slots__,
make some adjustments to the event system to allow
that to be present, at least rudimentally.

Fixes: #5628
Change-Id: I5eb6929fc1e4fdac99e4b767dcfd49672d56e2b2
2020-10-10 01:17:25 -04:00
mike bayer f8f3c34f86 Merge "Add python 3.9 to ci test and wheel workflow" 2020-10-09 21:22:34 +00:00