Commit Graph

8523 Commits

Author SHA1 Message Date
Gord Thompson 901587e1ee Enable loading of external Firebird dialect, if available
Fixes: #5278
Change-Id: I1660abb11c02656fbf388f2f9c4257075111be58
(cherry picked from commit 8c5aa7d3e0)
2020-04-30 11:34:13 -06:00
Mike Bayer b72c14cde2 Alias the onclause if ORM join is to same polymorphic selectable
Fixed bug where using :func:`.with_polymorphic` as the target of a join via
:meth:`.RelationshipComparator.of_type` on a mapper that already has a
subquery-based with_polymorphic setting that's equivalent to the one
requested would not correctly alias the ON clause in the join.

Fixes: #5288
Change-Id: I0212a990ee67a344c87fe21833bf47fdb72ca0cc
(cherry picked from commit 483a644959)
2020-04-27 18:39:11 -04:00
Federico Caselli 62edc4023e Fix regression when reflecting tables in MSSQL
Fix a regression introduced by the reflection of computed column in
MSSQL when using SQL server versions before 2012, which does not support
the ``concat`` function and when using the legacy TDS version 4.2.
The dialect will try to detect the protocol version of first connect
and run in compatibility mode if it cannot detect it.

Fixes: #5255
Fixes: #5271
Change-Id: I7b33f7889ac0784cd8ae5385cbd50bc8c862398a
(cherry picked from commit 50d283af1a)
2020-04-22 11:08:36 -04:00
mike bayer a89a409e8b Merge "Add ColumnProperty.Comparator.expressions" into rel_1_3 2020-04-21 13:40:23 +00:00
Gord Thompson f9499e5f36 Fix typo in pymssql documentation; minor clarification
Change-Id: I4aaf0627d2f1ccae82c2eb41db9ec219d73ce4ea
(cherry picked from commit 469e786c9d)
2020-04-20 15:53:11 -06:00
Mike Bayer d784d8208a Add ColumnProperty.Comparator.expressions
Added an accessor :attr:`.ColumnProperty.Comparator.expressions` which
provides access to the group of columns mapped under a multi-column
:class:`.ColumnProperty` attribute.

Fixes: #5262
Change-Id: I44cf53ff0e6cf76a0c90eee4638ca96da3df8088
(cherry picked from commit d9d724267afe867984a23abaa87f62e15786005f)
2020-04-20 16:00:00 -04:00
Federico Caselli 896da59aa4 Support ARRAY of Enum, JSON or JSONB
Added support for columns or type :class:`.ARRAY` of :class:`.Enum`,
:class:`.JSON` or :class:`_postgresql.JSONB` in PostgreSQL.
Previously a workaround was required in these use cases.
Raise an explicit :class:`.exc.CompileError` when adding a table with a
column of type :class:`.ARRAY` of :class:`.Enum` configured with
:paramref:`.Enum.native_enum` set to ``False`` when
:paramref:`.Enum.create_constraint` is not set to ``False``

Fixes: #5265
Fixes: #5266
Change-Id: I83a2d20a599232b7066d0839f3e55ff8b78cd8fc
(cherry picked from commit aaec1bdedf)
2020-04-20 11:54:31 -04:00
mike bayer 242c987d82 Merge "Raise informative error when non-object m2o comparison used" into rel_1_3 2020-04-20 15:31:27 +00:00
Gord Thompson 40f07675e3 Rename py.test to pytest
Change-Id: I431e1ef41e26d490343204a75a5c097768749768
(cherry picked from commit 405fc97170)
2020-04-20 09:08:18 -04:00
Gord Thompson 899c866824 Add @requirements.schemas to test_create_table_schema
Prevent test_create_table_schema from failing for databases that do not support schemas.

Change-Id: I0f5f129c313ee6023be2e6d84610355afc48c05c
(cherry picked from commit 6e208823a6)
2020-04-20 09:05:03 -04:00
Mike Bayer 63c94343a3 Raise informative error when non-object m2o comparison used
An informative error message is raised when an ORM many-to-one comparison
is attempted against an object that is not an actual mapped instance.
Comparisons such as those to scalar subqueries aren't supported;
generalized comparison with subqueries is better achieved using
:meth:`~.RelationshipProperty.Comparator.has`.

Fixes: #5269
Change-Id: I2e23178eb59728c39241a46bfa7411239a87492e
(cherry picked from commit 430ce5eab2)
2020-04-19 16:55:03 -04:00
mike bayer 362d0036cf Merge "Pass connection to TablesTest.insert_data()" into rel_1_3 2020-04-15 18:31:55 +00:00
Mike Bayer 3294998c64 Pass connection to TablesTest.insert_data()
towards the goal of reducing verbosity and repetition
in test fixtures as well as that we are moving to
connection only for execution, move the insert_data()
classmethod to accept a connection and adjust all
fixtures to use it.

Change-Id: I3bf534acca0d5f4cda1d4da8ae91f1155b829b09
(cherry picked from commit 5c010c097352c783729e210018b95130ef94a926)
2020-04-15 11:16:12 -04:00
Mike Bayer f9d6702b80 Set up absolute references for create_engine and related
includes more replacements for create_engine(), Connection

Change-Id: I680c02e90b9ece53e52ab1d66fd7d20b47c7df16
2020-04-14 16:45:15 -04:00
Mike Bayer 6c30dc88a5 Run search and replace of symbolic module names
Replaces a wide array of Sphinx-relative doc references
with an abbreviated absolute form now supported by
zzzeeksphinx.

Change-Id: I94bffcc3f37885ffdde6238767224296339698a2
2020-04-14 13:21:22 -04:00
Mike Bayer cd156b3ca5 Enable zzzeeksphinx module prefixes
zzzeeksphinx 1.1.2 in git can now convert short
prefix names in a configured lookup to fully qualified module
names, so that
we can have succinct and portable pyrefs
that still resolve absolutely.
It also includes a formatter that will format all pyrefs
in a fully consistent way regardless of the package path,
by unconditionally removing all package tokens but always
leaving class names in place including for methods, which
means we no longer have to deal with tildes in pyrefs.

The most immediate goal of the absolute prefixes is
that we have lots of
"ambiguous" names that appear in muliple places, like select(),
ARRAY, ENUM etc.   With the incoming future packages there
is going to be lots of name overlap so it is necessary
that all names eventually use absolute package paths
when Sphinx receives them.

In multiple stages, pyrefs will be converted using the
zzzeeksphinx tools/fix_xrefs.py tool so that doclinks can
be made absolute using symbolic prefixes.

For this review, the actual search and replace of symbols
is not performed, instead some general cleanup to prepare
the docs as well as a lookup file used by the tool
to do the conversion.   this relatively small patch will
be backported
with appropriate changes to 1.3, 1.2, 1.1 and the tool
can then be run on each branch individually.  We are shooting
for almost no warnings at all for master (still a handful
I can't figure out which don't seem to have any impact)
, very few for 1.3,
and for 1.2 / 1.1 we hope for a significant reduction
in warnings.

Overall for all versions pyrefs should
always point to the correct target, if they are in fact
hyperlinked.  it's better for a ref to go nowhere and
be plain text than go to the wrong thing.  Right now,
hundreds of API links are pointing to the wrong thing
as they are ambiguous names such as refresh(), insert(),
update(), select(), join(), JSON etc. and Sphinx sends these all
to essesntially random destinations among as many as five
or six possible choices per symbol.  A shorthand system
that allows us to use absolute refs without having
to type out a full blown absoulte module is the only
way this is going to work, and we should ultimately
seek to abandon any use of prefix dot for lookups.  Everything
should be on an underscore token so at the very least the module
spaces can be reorganized without having to search and replace
the entire documentation every time.

Change-Id: I484a7329034af275fcdb322b62b6255dfeea9151
(cherry picked from commit d8d755ad619e2ee78f2c7cb60ae9a1feee4c6d76)
2020-04-14 13:01:26 -04:00
mike bayer 1ee64d48d0 Merge "Add `comment attribute to :class:.Column __repr__` method." into rel_1_3 2020-04-13 15:28:19 +00:00
mike bayer 15a294f213 Merge "Use define_tables for IsOrIsNotDistinctFromTest" into rel_1_3 2020-04-13 01:34:04 +00:00
Federico Caselli c01fa5fc24 Add `comment attribute to :class:.Column __repr__` method.
Fixes #4138

Change-Id: Iad3604ce054aaac36fc93d623ae5058852875d97
2020-04-11 20:52:12 +02:00
Mike Bayer d56887bcb6 Fix almost all read-level sphinx warnings
Partial backport of 43bcb0de1e.

Also enables sphinx multiprocess.

Change-Id: I49b1959b9a5fe84fb4c74366da2724284a804936
2020-04-11 13:53:41 -04:00
Mike Bayer f21d404ea9 Use define_tables for IsOrIsNotDistinctFromTest
In Ie8127ef29f1ec91e7afb88e1429538c27a321784 Mike
failed to notice that this test is build on TablesTest and
has just the one test function, which means the table is
built up by the fixture.

Change-Id: I855431bc976fe8ec96559ec1a22bb294aecf3c40
(cherry picked from commit e228b41432)
2020-04-10 16:59:45 -04:00
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 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
Mike Bayer 240bd339da Version 1.3.17 placeholder 2020-04-07 22:47:20 -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 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 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
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
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 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
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 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
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 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