Commit Graph

12371 Commits

Author SHA1 Message Date
mike bayer e418d75853 Merge "Fix distinct_from test for Firebird et al." into rel_1_3 2020-04-10 20:54:10 +00:00
Mike Bayer 9a32c848a6 Evaluate fixes for cx_Oracle 8 API changes
in [1] we have reported some behavioral changes in cx_Oracle
symbols.   As it is unclear if these are intended changes in
cx_Oracle, test workarounds for these changes against
cx_Oracle master.

[1] https://github.com/oracle/python-cx_Oracle/issues/415

Fixes: #5246
Change-Id: If63f92553c46484bf2b61b53a9e6d85cb08e800a
(cherry picked from commit 24137da80d)
2020-04-10 16:48:53 -04:00
Mike Bayer 6d45f8b522 Repair CTE a in b tests
In I27cac9bd265c86ff2a3381ff9f844f60ef991cfc we modernized
the default tests and converted the "a in b" CTE tests to combinations,
however apparently the existing tests were not testing all
combinations and had repeats instead.   The combinations
decorator has made this much easier to spot, so use
the correct combinations that were originally intended.

Change-Id: Icd904887bff00c31525497d0b1508fabaf052dc9
(cherry picked from commit 046934083b)
2020-04-10 14:30:12 -04:00
Mike Bayer acc1b0614e Modernize test_defaults
Use modern execution patterns, goal is so that these same tests
can work for the future engine

break sequence tests into test_sequences suite

sequence tests that are testing implicit execution patterns
at least move into their own suite that will go into test_deprecations
eventually.

Change-Id: I27cac9bd265c86ff2a3381ff9f844f60ef991cfc
(cherry picked from commit 4cadeaf6e68d71c2cb36219f72cc4d337e31df88)
2020-04-10 10:49:05 -04:00
Gord Thompson 785b0fc35b Fix distinct_from test for Firebird et al.
Firebird (and perhaps others) allow us to CREATE TABLE inside a transaction but we can't INSERT INTO that table unless we COMMIT first.

Change-Id: Ie8127ef29f1ec91e7afb88e1429538c27a321784
(cherry picked from commit 10fb4d4d2f)
2020-04-09 12:27:47 -06:00
Federico Caselli 8750eb6ef1 Add github action workflow to run tests on master and on pr to master
Trying the pr to check if it works right away

<!-- Describe your changes in detail -->

<!-- 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: #5222
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5222
Pull-request-sha: afbb856752

Change-Id: I4981b02f900e76e446cf42e6cc6495ffc0883951
(cherry picked from commit c658540b9a)
2020-04-08 10:14:17 -04:00
Mike Bayer 240bd339da Version 1.3.17 placeholder 2020-04-07 22:47:20 -04:00
Mike Bayer 06ba82a9c7 - 1.3.16 rel_1_3_16 2020-04-07 22:41:36 -04:00
mike bayer ebd5cc08a4 Merge "Use dot-separated name resolution for relationship target" into rel_1_3 2020-04-08 01:48:33 +00:00
Mike Bayer 53591fc18d Use dot-separated name resolution for relationship target
The string argument accepted as the first positional argument by the
:func:`.relationship` function when using the Declarative API is no longer
interpreted using the Python ``eval()`` function; instead, the name is dot
separated and the names are looked up directly in the name resolution
dictionary without treating the value as a Python expression.  However,
passing a string argument to the other :func:`.relationship` parameters
that necessarily must accept Python expressions will still use ``eval()``;
the documentation has been clarified to ensure that there is no ambiguity
that this is in use.

Fixes: #5238
Change-Id: Id802f403190adfab0ca034afe2214ba10fd9cfbb
(cherry picked from commit 17e31604ae)
2020-04-07 19:37:47 -04:00
Mike Bayer 44cdd490b2 Gracefully skip isolation level if no row returned
Fixed issue in MySQL dialect when connecting to a psuedo-MySQL database
such as that provided by ProxySQL, the up front check for isolation level
when it returns no row will not prevent the dialect from continuing to
connect. A warning is emitted that the isolation level could not be
detected.

Fixes: #5239
Change-Id: I4a240386a0d38bd90733819495ce50e37fe2234c
(cherry picked from commit 978755e851)
2020-04-07 19:22:15 -04:00
Gord Thompson 0b8b4bcdd5 Broaden is[not]_distinct_from support
Added support for .is[not]_distinct_from to SQL Server, MySQL, and Oracle.

Fixes: #5137
Change-Id: I3b4d3b199821a55687f83c9a5b63a95d07a64cd5
(cherry picked from commit 207e0b2fc0)
2020-04-06 18:00:40 -04:00
mike bayer 3d739186c0 Merge "Replace engine.execute w/ context manager (step1)" into rel_1_3 2020-04-06 21:57:11 +00:00
Mike Bayer 3637b8a822 Ensure length parameter of Enum is adapted to new objects
Ensure length parameter added to Enum in
Iea05dc8cd9e33959bb968b394fb10a7dd068c873 is correctly propagated
to new enum objects adapted from this one.

Fixes: #5183

`

Change-Id: I7f20d926f73ec8260938963df87e29894c7e55e2
(cherry picked from commit 9243f6feea)
2020-04-06 16:20:22 -04:00
mike bayer 5ff5abc97f Merge "Add length parameter in Enum" into rel_1_3 2020-04-06 20:10:51 +00:00
Gord Thompson 4a03d2100e Replace engine.execute w/ context manager (step1)
First (baby) step at replacing engine.execute
calls in test code with the new preferred way
of executing. MSSQL was targeted because it was
the easiest for me to test locally.

Change-Id: Id2e02f0e39007cbfd28ca6a535115f53c6407015
(cherry picked from commit 60f627cbd0)
2020-04-06 16:08:42 -04:00
Federico Caselli 040bbc9e88 Add length parameter in Enum
The `Enum` type now supports the parameter `Enum.length`
to specify the length of the VARCHAR column to create when using
non native enums by setting `Enum.native_enum` to `False`

Fixes: #5183
Change-Id: Iea05dc8cd9e33959bb968b394fb10a7dd068c873
(cherry picked from commit 3e2af98adfdcbf33ff5d8c2da15962c001344d64)
2020-04-06 20:03:22 +02:00
Gord Thompson 05492890e0 Apply fix to ComputedReflectionFixtureTest
Avoid errors for dialects without schema support.
Also fix typo in test name.

Fixes: #5230
Change-Id: Id0f759b591a6119069b0fc5fc3b02addb85b0597
(cherry picked from commit 50f1e1392a)
2020-04-05 06:43:38 -06:00
Mike Bayer ef5481e18e Ensure context.attrbutes dictionary is reset each time
A memory growth issue was identified in this test which
caused the profiling results to be inaccurate.

Change-Id: I248dcce5833feada947bc91bdf09a8f925d31d65
(cherry picked from commit 139aac4aba)
2020-04-04 17:21:03 -04:00
Mike Bayer b83c1d97a3 Key subqueryloaders on the property object, not string key
Fixed bug in :func:`.orm.selectinload` loading option where two or more
loaders that represent different relationships with the same string key
name as referenced from a single :func:`.orm.with_polymorphic` construct
with multiple subclass mappers would fail to invoke each subqueryload
separately, instead making use of a single string-based slot that would
prevent the other loaders from being invoked.

Fixes: #5228
Change-Id: Id0d1db8029ca88c13c0068115fe673adb7a68407
(cherry picked from commit a32c528c54)
2020-04-03 16:02:26 -04:00
Mike Bayer 4227ef3d10 Fix sqlite memory req
this is only used by test/requirements.py right now for the
profiling tests but it was not returning the correct answer
during a regenerate operation.

Change-Id: Id9747b4fe562b8bea9b21c465b626b1b19e6956b
(cherry picked from commit 379e878c58)
2020-03-30 15:05:35 -04:00
Mike Bayer 3e22b7655a Remove ORDER BY pk from subqueryload, selectinload
Modified the queries used by subqueryload and selectinload to no longer
ORDER BY the primary key of the parent entity;  this ordering was there to
allow the rows as they come in to be copied into lists directly with a
minimal level of Python-side collation.   However, these ORDER BY clauses
can negatively impact the performance of the query as in many scenarios
these columns are derived from a subquery or are otherwise not actual
primary key columns such that SQL planners cannot make use of indexes. The
Python-side collation uses the native itertools.group_by() to collate the
incoming rows, and has been modified to allow multiple
row-groups-per-parent to be assembled together using list.extend(), which
should still allow for relatively fast Python-side performance.  There will
still be an ORDER BY present for a relationship that includes an explicit
order_by parameter, however this is the only ORDER BY that will be added to
the query for both kinds of loading.

Fixes: #5162
Change-Id: I8befd1303c1af7cc24cbf005f39bc01c8b2745f3
(cherry picked from commit f86ee556add28afd4de31c10fce56b00a0014a4e)
2020-03-30 11:44:07 -04:00
Federico Caselli fea89ef470 String compiler can now literal compile datetime objects
Add ability to literal compile a :class:`DateTime`, :class:`Date`
or :class:"Time" when using the string dialect for debugging purposes.
This change does not impact real dialect implementation that retain
their current behavior.

Fixes: #5052
Change-Id: Ia3fad2be905c6d35b0106b9a2388c7508f067e90
(cherry picked from commit 83eb1b23cb)
2020-03-29 21:57:53 -04:00
michitaro.koike 46b4eedb1b typo: missing comma
(cherry picked from commit 2d4171ec8c)
2020-03-26 09:52:06 -04:00
Gord Thompson 9ebbf8614a Implement autocommit isolation level for pysqlite
Fixes: #5164
Change-Id: I190b9de552dfed9f2a33babf82e42465ef09c82a
(cherry picked from commit 64e8303deb)
2020-03-24 15:56:38 -04:00
Mike Bayer 1dcc807e82 Reword changelog for issue #5207
SQLAlchemy can remain using setuptools even when pep-517 is
the standard installation process.   We are omitting the file
for now because it leads to new pip installation issues that need
to be worked out in the greater pip community before SQLAlchemy
opts into this system.

Change-Id: I40b196100c6f16ae1291fcb7f8b5196bba14a300
(cherry picked from commit e127072637)
2020-03-24 12:54:19 -04:00
Gord Thompson 24e87a74eb Implement autocommit isolation level for cx_oracle
As part of this change Oracle also gets the concept of a
default isolation level, however since Oracle does not provide a
fixed method of knowing what the isolation level would be without a
server side transaction actually in progress, for now we hardcode
just to "READ COMMITTED".

Enhanced the test suite for isolation level testing in the dialect
test suite and added features to requirements so that the supported
isolation levels can be reported generically for dialects.

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Fixes: #5200
Change-Id: I2c4d49da9ff80ccc228c21e196ec9a961de53478
(cherry picked from commit 1afca5823efe22c0f8cbc01455bafc573254ab55)
2020-03-23 11:56:53 -04:00
Mike Bayer 84c89f781a Test instance for matching class hierarchy on get_from_identity
Fixed issue where a lazyload that uses session-local "get" against a target
many-to-one relationship where an object with the correct primary key is
present, however it's an instance of a sibling class, does not correctly
return None as is the case when the lazy loader actually emits a load for
that row.

Fixes: #5210
Change-Id: I89f9946cfeba61d89a272435f76a5a082b1da30c
(cherry picked from commit 900402b9aa901bc9b1ae3f6b525f076076c52529)
2020-03-22 11:47:04 -04:00
Mike Bayer fcb22fa8e2 Remove pyproject.toml from distribution
SQLAlchemy does not want to opt-in to pep-517 at this time
as this would require a custom build backend interface
which we have not built yet, and the standard is not
widely adopted at this time in any case.  Per
[1] [2], the presence of this file indicates a positive opt-in
to pep-517, so it must be omitted from source distributions.

[1] https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support
[2] https://www.python.org/dev/peps/pep-0517/#id5

Fixes: #5207
Change-Id: If8d26a9edf942047920d273d8be778df7a018b3e
(cherry picked from commit f2a817dd7c)
2020-03-21 10:20:14 -04:00
Mike Bayer c7e0f3d3aa Clarify Alembic vs. Migrate
Migrate is fully legacy at this point so continue to mention
it to provide clarity, but ensure it isn't suggested
as a real alternative.  It's unclear if Migrate will be able
to support SQLAlchemy 2.0.

Change-Id: Ia81aaccbd18f197ab533b083e87cc4d04ea05839
(cherry picked from commit a25e2e02e1)
2020-03-20 16:42:06 -04:00
Mike Bayer 2ebbdfa405 Emphasize context managers when working with Core
Prep the main documentation for the changes coming up in 1.4
by first removing references to engine.execute() outside
of the "connectionless" section, and using context managers
in all cases.  For features that have always been confusing
and are going away, add a note that this feature will
be going away.

Change-Id: I94583444734e36f5432c32cb37f88a9fad15634a
(cherry picked from commit 376708f4a4)
2020-03-20 15:22:23 -04:00
Mike Bayer 6aad46f9f8 Correct misleading guidance on multiprocessing
Link the connections intro to the dedicated section
on multiprocessing rather than stating that a separate
engine per process is needed, since this is inaccurate
and vague.

Change-Id: I48c66f88a90db918e864cd198c6aed335e28c7e6
(cherry picked from commit 491333858c)
2020-03-20 11:18:50 -04:00
mike bayer 0147e3c364 Don't include PG INCLUDE columns as regular index columns
Fixed issue where a "covering" index, e.g. those which have an  INCLUDE
clause, would be reflected including all the columns in INCLUDE clause as
regular columns.  A warning is now emitted if these additional columns are
detected indicating that they are currently ignored.  Note that full
support for "covering" indexes is part of 🎫`4458`.  Pull request
courtesy Marat Sharafutdinov.

Fixes: #5205
Closes: #5206
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5206
Pull-request-sha: 512a3817bb

Change-Id: I3196a2bf77dc5a6abd85b2fbf0ebff1b30d4fb00
(cherry picked from commit ee9bd719b7)
2020-03-18 19:29:05 -04:00
Mike Bayer 3a9b6fdb06 Fix "special_key" attribute name in association proxy documentation
Fixes: #5204
Change-Id: I1366be823d753bdcd92c98b948bdfa7960a27eb7
(cherry picked from commit 1768dd2a08)
2020-03-16 22:06:44 -04:00
Federico Caselli 5d963ae620 Support inspection of computed column
Added support for reflection of "computed" columns, which are now returned
as part of the structure returned by :meth:`.Inspector.get_columns`.
When reflecting full :class:`.Table` objects, computed columns will
be represented using the :class:`.Computed` construct.

Also improve the documentation in :meth:`Inspector.get_columns`, correctly
listing all the returned keys.

Fixes: #5063
Fixes: #4051

Closes: #5064
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5064
Pull-request-sha: ba00fc321ce468f8885aad23b3dd33c789e50fbe

Change-Id: I789986554fc8ac7f084270474d0b2c12046b1cc2
(cherry picked from commit 62b7dace0c)
2020-03-16 09:46:03 -04:00
Gord Thompson d5956e3f33 Fix tests failing for SQLite file databases; repair provisioning
1. ensure provision.py loads dialect implementations when running
reap_dbs.py.   Reapers haven't been working since
598f2f7e55 .

2. add some exclusion rules to allow the sqlite_file target to work;
add to tox.

3. add reap dbs target for SQLite, repair SQLite drop_db routine
which also wasn't doing the right thing for memory databases
etc.

4. Fix logging in provision files, as the main provision logger
is the one that's enabled by reap_dbs and maybe others, have all
the provision files use the provision logger.

Fixes: #5180
Fixes: #5168

Change-Id: Ibc1b0106394d20f5bcf847f37b09d185f26ac9b5
(cherry picked from commit 08fdf6da228aab54263abe043c21bcebf3513e72)
2020-03-13 15:48:08 -04:00
Mike Bayer bdd289668f Disable sqlite_file tests by default, take two
We need no tests to run for sqlite_file until we merge
a full fix for it.   We'd like Jenkins to include this target.

Change-Id: I2737fa462572f08e2925b232a8f24d1ecd26b3ac
(cherry picked from commit 67e51ea5dc)
2020-03-13 12:16:03 -04:00
Mike Bayer 19b248c14c Include schema in all_tab_comments query
Fixed regression / incorrect fix caused by fix for 🎫`5146` where the
Oracle dialect reads from the "all_tab_comments" view to get table comments
but fails to accommodate for the current owner of the table being
requested, causing it to read the wrong comment if multiple tables of the
same name exist in multiple schemas.

Fixes: #5146
Change-Id: Id79fbaa81b0e36cd4af60c48e4ab35c593ace057
(cherry picked from commit f1429823d3)
2020-03-12 23:13:35 -04:00
Mike Bayer 82ab7c825d Dont raise on pytest deprecation warnings
py.test 5.4.0 emits deprecation warnings for pytest.Class.
make sure we don't raise for these, and log the code that will
be used for 5.4.0 when we bump requirements.

Fixes: #5201
Change-Id: I83e0402c4a6b2365a63b58d052c6989df3a37328
(cherry picked from commit be26fd13c124d5d53496cca98ce371c45c07c205)
2020-03-12 19:50:56 -04:00
Mike Bayer f2132e2d8b Remove trailing slashes in pre-commit config
See https://github.com/sqlalchemy/dogpile.cache/pull/176

Change-Id: Id9a75546d4d0eae93ad837a77c6ffa9249efff5c
(cherry picked from commit f8a037aa82)
2020-03-11 20:48:19 -04:00
Federico Caselli 7002045e34 Fix link in docs of query_expression and with_expression
Ref #5198

Change-Id: I566c2f7bbe08e9017e09e133079bef1c38469595
(cherry picked from commit 4cf10e7deb)
2020-03-11 14:39:32 -04:00
Mike Bayer 601c233ce0 Version 1.3.16 placeholder 2020-03-11 12:36:59 -04:00
Mike Bayer b2a20b1f5f - 1.3.15 rel_1_3_15 2020-03-11 12:29:27 -04:00
Mike Bayer 2855d2a047 Repair broken call to sys.exc_info()
Fixed regression in 1.3.14 due to 🎫`4849` where a sys.exc_info()
call failed to be invoked correctly when a flush error would occur. Test
coverage has been added for this exception case.

Fixes: #5196
Change-Id: Ib59a58a3a9d4c9c6f4b751201b794816a9f70225
(cherry picked from commit ceba13d4be)
2020-03-11 10:44:56 -04:00
Mike Bayer 5361cfb8d3 Reword implicit left join error; ensure deterministic FROM for columns
Adjusted the error message emitted by :meth:`.Query.join` when a left hand
side can't be located that the :meth:`.Query.select_from` method is the
best way to resolve the issue.  Also, within the 1.3 series, used a
deterministic ordering when determining the FROM clause from a given column
entity passed to :class:`.Query` so that the same expression is determined
each time.

Fixes: #5194
Change-Id: I2e4065fd31e98c57edf2f11d5e831be44d2c1ea2
(cherry picked from commit 7d8c64f908)
2020-03-10 18:53:21 -04:00
Mike Bayer 1d36fccccd Version 1.3.15 placeholder 2020-03-10 11:57:23 -04:00
Mike Bayer cf3b2a1640 - 1.3.14 rel_1_3_14 2020-03-10 11:40:08 -04:00
Gord Thompson 3c353ec9e3 Reflect comments from any table accessible by the current user
Fixed a reflection bug where table comments could only be retrieved for
tables actually owned by the user but not for tables visible to the user
but owned by someone else.  Pull request courtesy Dave Hirschfeld.

Fixes: #5146
Closes: #5147
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5147
Pull-request-sha: 0651e3bed0

Change-Id: If970fda10d6adf04d926d38df1a567df1de9f7b9
(cherry picked from commit 0c294d356f)
2020-03-10 10:42:38 -04:00
Gord Thompson 262eeb4b50 Fix comment re: ODBC driver name on Windows.
(cherry picked from commit 57fa3c0670)
2020-03-09 11:09:56 -04:00
Gord Thompson e14a17f338 Clean up list of external dialects
Fixes: #5190
Change-Id: I3636eeda08bfaa882477397a4cd8064820d25356
(cherry picked from commit 07e1d473c0)
2020-03-08 12:28:22 -04:00