diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-06-26 16:15:19 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-07-08 11:05:11 -0400 |
commit | 91f376692d472a5bf0c4b4033816250ec1ce3ab6 (patch) | |
tree | 31f7f72cbe981eb73ed0ba11808d4fb5ae6b7d51 /test/ext/test_horizontal_shard.py | |
parent | 3dc9a4a2392d033f9d1bd79dd6b6ecea6281a61c (diff) | |
download | sqlalchemy-91f376692d472a5bf0c4b4033816250ec1ce3ab6.tar.gz |
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
Diffstat (limited to 'test/ext/test_horizontal_shard.py')
-rw-r--r-- | test/ext/test_horizontal_shard.py | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/test/ext/test_horizontal_shard.py b/test/ext/test_horizontal_shard.py index 9855cd5ab..455e26b14 100644 --- a/test/ext/test_horizontal_shard.py +++ b/test/ext/test_horizontal_shard.py @@ -10,6 +10,7 @@ from sqlalchemy import ForeignKey from sqlalchemy import inspect from sqlalchemy import Integer from sqlalchemy import MetaData +from sqlalchemy import select from sqlalchemy import sql from sqlalchemy import String from sqlalchemy import Table @@ -17,7 +18,6 @@ from sqlalchemy import testing from sqlalchemy import update from sqlalchemy import util from sqlalchemy.ext.horizontal_shard import ShardedSession -from sqlalchemy.future import select as future_select from sqlalchemy.orm import clear_mappers from sqlalchemy.orm import create_session from sqlalchemy.orm import deferred @@ -179,7 +179,7 @@ class ShardTest(object): tokyo.reports.append(Report(80.0, id_=1)) newyork.reports.append(Report(75, id_=1)) quito.reports.append(Report(85)) - sess = create_session() + sess = create_session(future=True) for c in [tokyo, newyork, toronto, london, dublin, brasilia, quito]: sess.add(c) sess.flush() @@ -219,7 +219,7 @@ class ShardTest(object): def test_query_explicit_shard_via_bind_opts(self): sess = self._fixture_data() - stmt = future_select(WeatherLocation).filter(WeatherLocation.id == 1) + stmt = select(WeatherLocation).filter(WeatherLocation.id == 1) tokyo = ( sess.execute(stmt, bind_arguments={"shard_id": "asia"}) @@ -257,16 +257,14 @@ class ShardTest(object): sess = self._fixture_data() tokyo = ( - sess.execute( - future_select(WeatherLocation).filter_by(city="Tokyo") - ) + sess.execute(select(WeatherLocation).filter_by(city="Tokyo")) .scalars() .one() ) eq_(tokyo.city, "Tokyo") asia_and_europe = sess.execute( - future_select(WeatherLocation).filter( + select(WeatherLocation).filter( WeatherLocation.continent.in_(["Europe", "Asia"]) ) ).scalars() @@ -536,12 +534,12 @@ class ShardTest(object): eq_( set( row.temperature - for row in sess.execute(future_select(Report.temperature)) + for row in sess.execute(select(Report.temperature)) ), {80.0, 75.0, 85.0}, ) - temps = sess.execute(future_select(Report)).scalars().all() + temps = sess.execute(select(Report)).scalars().all() eq_(set(t.temperature for t in temps), {80.0, 75.0, 85.0}) sess.execute( @@ -554,7 +552,7 @@ class ShardTest(object): eq_( set( row.temperature - for row in sess.execute(future_select(Report.temperature)) + for row in sess.execute(select(Report.temperature)) ), {86.0, 75.0, 91.0}, ) @@ -568,12 +566,12 @@ class ShardTest(object): eq_( set( row.temperature - for row in sess.execute(future_select(Report.temperature)) + for row in sess.execute(select(Report.temperature)) ), {80.0, 75.0, 85.0}, ) - temps = sess.execute(future_select(Report)).scalars().all() + temps = sess.execute(select(Report)).scalars().all() eq_(set(t.temperature for t in temps), {80.0, 75.0, 85.0}) # MARKMARK @@ -588,7 +586,7 @@ class ShardTest(object): eq_( set( row.temperature - for row in sess.execute(future_select(Report.temperature)) + for row in sess.execute(select(Report.temperature)) ), {86.0, 81.0, 91.0}, ) @@ -599,7 +597,7 @@ class ShardTest(object): def test_bulk_delete_future_synchronize_evaluate(self): sess = self._fixture_data() - temps = sess.execute(future_select(Report)).scalars().all() + temps = sess.execute(select(Report)).scalars().all() eq_(set(t.temperature for t in temps), {80.0, 75.0, 85.0}) sess.execute( @@ -611,7 +609,7 @@ class ShardTest(object): eq_( set( row.temperature - for row in sess.execute(future_select(Report.temperature)) + for row in sess.execute(select(Report.temperature)) ), {75.0}, ) @@ -623,7 +621,7 @@ class ShardTest(object): def test_bulk_delete_future_synchronize_fetch(self): sess = self._fixture_data() - temps = sess.execute(future_select(Report)).scalars().all() + temps = sess.execute(select(Report)).scalars().all() eq_(set(t.temperature for t in temps), {80.0, 75.0, 85.0}) sess.execute( @@ -635,7 +633,7 @@ class ShardTest(object): eq_( set( row.temperature - for row in sess.execute(future_select(Report.temperature)) + for row in sess.execute(select(Report.temperature)) ), {75.0}, ) |