Commit Graph

7991 Commits

Author SHA1 Message Date
Mike Bayer bb6eaeed9e - pep8 fix
Change-Id: I5e2e013c3460c035ad80dae7fd08efe5d1676a5d
(cherry picked from commit 313be7c78d)
2019-01-16 20:21:12 -05:00
Mike Bayer 3ad2966da2 Convert most "See also" phrases into .. seealso::
Change-Id: Ie32598b895c1c5f5bce7c8e1573abbcfe9d434a8
(cherry picked from commit e81d3815abb36c52b0019dee6e4f67990e3d1c7d)
2019-01-15 16:13:12 -05:00
Mike Bayer 996eb2d4bf Remove version directives for 0.6, 0.7, 0.8
- fix a few "seealso"s
- ComparableProprerty's "superseded in 0.7" becomes deprecated in 0.7

Backport to currently maintained doc versions 1.2, 1.1

Change-Id: Ib1fcb2df8673dbe5c4ffc47f3896a60d1dfcb4b2
(cherry picked from commit 885f15a306)
2019-01-15 10:52:18 -05:00
Mike Bayer 1bfdaf307c correct paramref to property links to refer to creation function
Change-Id: I2c528bd4639863aa7b8a592beed776d53bab3e5c
(cherry picked from commit b229a50c77)
2019-01-13 12:37:14 -05:00
Mike Bayer 9db219665a use ..deprecated directive w/ version in all cases
These changes should be ported from 1.3 back to 1.0 or
possibly 0.9 to the extent they are relevant in each
version. In 1.3 we hope to turn all deprecation documentation
into warnings.

(cherry picked from commit 77e9534673d58f2f4c33d16c0ed4e8671cea48b6)
Change-Id: I205186cde161af9389af513a425c62ce90dd54d8
2019-01-12 18:11:51 -05:00
Mike Bayer 4171d1cae7 Version 1.2.17 placeholder 2019-01-11 10:15:39 -05:00
Mike Bayer 3cfc3c2faa happy new year
Change-Id: I6a71f4924d046cf306961c58dffccf21e9c03911
(cherry picked from commit 6f270fb0e3)
2019-01-11 10:07:20 -05:00
Mike Bayer b5b28733c6 Leave bytestring exception messages as bytestrings
Fixed a regression introduced in version 1.2 where a refactor
of the :class:`.SQLAlchemyError` base exception class introduced an
inappropriate coercion of a plain string message into Unicode under
python 2k, which is not handled by the Python interpreter for characters
outside of the platform's encoding (typically ascii).  The
:class:`.SQLAlchemyError` class now passes a bytestring through under
Py2K for ``__str__()`` as is the behavior of exception objects in general
under Py2K, does a safe coercion to unicode utf-8 with
backslash fallback for ``__unicode__()``.  For Py3K the message is
typically unicode already, but if not is again safe-coerced with utf-8
with backslash fallback for the ``__str__()`` method.

Fixes: #4429
Change-Id: I2289da3f2c45c7d0041fa43d838958f7614defc3
(cherry picked from commit 2db54ee92e)
2019-01-10 19:49:47 -05:00
Mike Bayer b5083e5fdc Skip expression-based index reflection for SQLite
Reflection of an index based on SQL expressions are now skipped with a
warning, in the same way as that of the Postgresql dialect, where we currently
do not support reflecting indexes that have SQL expressions within them.
Previously, an index with columns of None were produced which would break
tools like Alembic.

Fixes: #4431
Change-Id: I1363ade912d206b42669331e2be2bb6f444b65a2
(cherry picked from commit 08994cb97c)
2019-01-09 21:07:05 -05:00
Mike Bayer 017bf8365f Render correct DDL for unsetting table comments
Fixed issue where the DDL emitted for :class:`.DropTableComment`, which
will be used by an upcoming version of Alembic, was incorrect for the MySQL
and Oracle databases.

Fixes: #4436
Change-Id: I196de09495a37adface4caa9dcbc29a6d0ad159a
(cherry picked from commit 2a840c147e)
2019-01-09 11:19:21 -05:00
Mike Bayer 18abd47af3 Post black reformatting
Applied on top of a pure run of black -l 79 in
I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9,  this set of changes
resolves all remaining flake8 conditions for those codes
we have enabled in setup.cfg.

Included are resolutions for all remaining flake8 issues
including shadowed builtins, long lines, import order, unused
imports, duplicate imports, and docstring issues.

Change-Id: I4f72d3ba1380dd601610ff80b8fb06a2aff8b0fe
2019-01-06 11:51:20 -05:00
Mike Bayer 580139598f Run black -l 79 against all source files
This is a straight reformat run using black as is, with no edits
applied at all.

The black run will format code consistently, however in
some cases that are prevalent in SQLAlchemy code it produces
too-long lines.   The too-long lines will be resolved in the
following commit that will resolve all remaining flake8 issues
including shadowed builtins, long lines, import order, unused
imports, duplicate imports, and docstring issues.

Change-Id: I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9
2019-01-06 01:31:01 -05:00
Mike Bayer 7b788c445f Assorted pre-Black fixes
Fixes to the test suite, a few errant imports, and setup.py:

- mysql and postgresql have unused 'json' imports; remove
- postgresql is exporting the 'json' symbol, remove
- make sure setup.py can find __version__ using " or '
- retry logic in provision create database for postgresql fixed
- refactor test_magazine to use cls.tables rather than globals
- remove unused class in test_scoping
- add a comment to test_deprecations that this test suite itself
  is deprecated
- don't use mapper() and orm_mapper() in test_unitofwork, just
  use mapper()
- remove dupe test_scalar_set_None test in test_attributes
- Python 2.7 and above includes unittest.SkipTest, remove pre-2.7
  fallback
- use imported SkipTest in profiling
- declarative test_reflection tests with "reflectable_autoincrement"
  already don't run on oracle or firebird; remove conditional logic
  for these, which also removes an "id" symbol
- clean up test in test_functions, remove print statement
- remove dupe test_literal_processor_coercion_native_int_out_of_range
  in test/sql/test_types.py
- fix psycopg2_hstore ref

Change-Id: I7b3444f8546aac82be81cd1e7b6d8b2ad6834fe6
(cherry picked from commit 404e69426b)
2019-01-05 23:52:15 -05:00
Mike Bayer 69970cf2f4 Prep for flake8 refactoring
a few code changes ahead of time to handle some __all__
issues better.  also include new flake8 rules, since the
existing flake8 doesn't pass in any case.

Change-Id: I1efdf75124ae7bcac719c22e505bb5b13db06c04
(cherry picked from commit d229360a8d)
2019-01-03 22:29:04 -05:00
Mike Bayer 5244e31e23 rework the exclusions spec expression
The expression was expecting spaces which means we were skipping
Postgresql window function tests and possibly other things.

Change-Id: I57c4aed558f4011f2f7b882a2d9b1fee210f9eaf
(cherry picked from commit 1eaf9dc777)
2018-12-31 10:10:31 -05:00
Lele Gaifax 7ec092063a commit 1b774808c926665047bf353222ecd191679a95d1
Author: Lele Gaifax <lele@metapensiero.it>
Date:   Tue Dec 25 12:35:41 2018 +0100

    Consistently use "PostgreSQL", fixing also a few doc glitches

commit 0e382aaee4427193926f0dc10ad29056bc12c85e
Author: Lele Gaifax <lele@metapensiero.it>
Date:   Tue Dec 25 12:08:49 2018 +0100

    Remove duplicated words

Change-Id: Iaa586b9412f46a50fe6ff3bbb92e07d6cb1905c8
(cherry picked from commit c0f9708fde)
2018-12-30 21:20:20 -05:00
Mike Bayer e4ec7d2b22 Maintain compiled_params / replacement_expressions within expanding IN
Fixed issue in "expanding IN" feature where using the same bound parameter
name more than once in a query would lead to a KeyError within the process
of rewriting the parameters in the query.

Fixes: #4394
Change-Id: Ibcadce9fefbcb060266d9447c2044ee6efeccf5a
(cherry picked from commit c495769751)
2018-12-21 21:56:45 -05:00
Mike Bayer ae45db1bf8 Handle PostgreSQL enums in remote schemas
Fixed issue where a :class:`.postgresql.ENUM` or a custom domain present
in a remote schema would not be recognized within column reflection if
the name of the enum/domain or the name of the schema required quoting.
A new parsing scheme now fully parses out quoted or non-quoted tokens
including support for SQL-escaped quotes.

Fixed issue where multiple :class:`.postgresql.ENUM` objects referred to
by the same :class:`.MetaData` object would fail to be created if
multiple objects had the same name under different schema names.  The
internal memoization the Postgresql dialect uses to track if it has
created a particular :class:`.postgresql.ENUM` in the database during
a DDL creation sequence now takes schema name into account.

Fixes: #4416
Change-Id: I8cf03069e10b12f409e9b6796e24fc5850979955
(cherry picked from commit 0b0a4c8ba2)
2018-12-21 13:53:23 -05:00
Mike Bayer 2147d20ef4 Rewrite the convert_unicode docs and add tons of dragons
These flags will all be going away as Python 3 has solved
all of this.

Change-Id: I4f581d8dd7826dd823b671d0d8e72250284236c8
(cherry picked from commit 7f12f63c3a)
2018-12-21 12:14:04 -05:00
Agam Rafaeli e9d209c1d7 Add missing parameter to docstring
Closes: #4410
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4410
Pull-request-sha: 070a0f44f3

Change-Id: I7a026bf6a2041e7686d90d5f155b88d8001f2ba8
(cherry picked from commit b1e4b59781)
2018-12-17 16:24:00 -05:00
Mike Bayer eb73b1a1cd Document and support nested composites
Composites can behave in a "nested" fashion by defining the
class in that way.   To make the constructor more convenient,
a callable can be passed to :func:`.composite` instead of the
class itself.  This works now, so add a test to ensure this
pattern remains available.

Change-Id: Ia009f274fca7269f41d6d824e0f70b6fb0ada081
(cherry picked from commit d4a130bb1b)
2018-12-12 12:54:56 -05:00
Mike Bayer 560452acd2 Version 1.2.16 placeholder 2018-12-11 16:56:37 -05:00
Mike Bayer d00dce5cc9 Refer to existing of_type when resolving string attribute name
Fixed bug where chaining of mapper options using
:meth:`.RelationshipProperty.of_type` in conjunction with a chained option
that refers to an attribute name by string only would fail to locate the
attribute.

Fixes: #4400
Change-Id: I01bf449ec4d8f56bb8c34e25153c1c9b31ff8012
(cherry picked from commit 099f3fd812)
2018-12-07 16:04:24 -05:00
mike bayer acf03df445 Merge "Fix PostgreSQL reflection of domains expressed as arrays" into rel_1_2 2018-12-03 02:35:20 +00:00
Mike Bayer 5945da4e41 "left" -> "accidentally placed at"
since "left" is kind of ambiguous, use more explicit terminology
here.

Also update the test to use a positive assertion that the
warning is emitted; quote the attribute name.

Change-Id: Ic2284c200a26b32b2da063cfaf6d59547309d587
References: https://github.com/zzzeek/sqlalchemy/pull/488
(cherry picked from commit eacb31a89f)
2018-12-02 18:59:45 -05:00
Jakub Synowiec f9c476740f Fix PostgreSQL reflection of domains expressed as arrays
Fixed issue where reflection of a PostgreSQL domain that is expressed as an
array would fail to be recognized.  Pull request courtesy Jakub Synowiec.

Fixes: #4377
Change-Id: I252c79ca435b87d4d9172b1c84e0e74e789ef676
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4380
(cherry picked from commit 46f9c3c7d4)
2018-12-01 13:32:10 -05:00
mike bayer 039d8a31f5 Merge "Add the write_timeout option for mysql." into rel_1_2 2018-11-30 18:11:14 +00:00
Raphael f778b8a8e0 typo
typo

(cherry picked from commit 0a0b36686d)
2018-11-30 10:10:11 -05:00
jun923.gu d99e17a775 Add the write_timeout option for mysql.
As MySQLdb support read_timeout and write_timeout option, and
sqlalchemy just support read_timeout option. So sqlalchemy need to add
write_timeout option.

Fixes: #4381
Change-Id: I2bea80bdd6f20fafc72b48fa0e5d795626d9d9b9
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4385
(cherry picked from commit 6a8454ded3)
2018-11-30 00:32:05 -05:00
Mike Bayer 9e53163dbd Warn for lower-case column attribute on declarative
A warning is emitted in the case that a :func:`.column` object is applied to
a declarative class, as it seems likely this intended to be a
:class:`.Column` object.

Fixes: #4374
Change-Id: I2e617ef65547162e3ba6587c168548ad0cf6203d
(cherry picked from commit 6ec40eca1a)
2018-11-26 01:12:59 -05:00
Mike Bayer 253eda6698 Modernize cx_oracle connect documentation
in preparation for #4369, however the documentation was
also inaccurate in that it did not mention connect_args.

Change-Id: I992e5f53ce16cc9c72d2c893a3ca798a9c2b4d07
(cherry picked from commit 996727ed89)
2018-11-15 12:53:29 -05:00
Mike Bayer bdb7fd10e9 Add secondary selectable to FROM clauses for correlated exists
In continuing with a similar theme as that of very recent 🎫`4349`,
repaired issue with :meth:`.RelationshipProperty.Comparator.any` and
:meth:`.RelationshipProperty.Comparator.has` where the "secondary"
selectable needs to be explicitly part of the FROM clause in the
EXISTS subquery to suit the case where this "secondary" is a :class:`.Join`
object.

Fixes: #4366
Change-Id: Icd0d0c3871bbd0059f0c9256e2b980edc2c90551
(cherry picked from commit fdfd168060)
2018-11-14 17:37:55 -05:00
mike bayer 40e4fc3021 Merge "Deannotate "parententity" in primaryjoin/secondaryjoin" into rel_1_2 2018-11-14 19:22:36 +00:00
Mike Bayer d096e930f9 Deannotate "parententity" in primaryjoin/secondaryjoin
Fixed bug where the ORM annotations could be incorrect for the
primaryjoin/secondaryjoin a relationship if one used the pattern
``ForeignKey(SomeClass.id)`` in the declarative mappings.   This pattern
would leak undesired annotations into the join conditions which can break
aliasing operations done within :class:`.Query` that are not supposed to
impact elements in that join condition.  These annotations are now removed
up front if present.

Also add a test suite for has/any into test_query which will
form the basis for new tests to be added in 🎫`4366`.

Fixes: #4367
Change-Id: I929ef983981bb49bf975f346950ebb0e19c986b8
(cherry picked from commit 4ee5b2c4a9)
2018-11-14 11:37:20 -05:00
Mike Bayer 105d8d2fca Insert primary entity in dynamic "secondary"
Fixed regression caused by 🎫`4349` where adding the "secondary"
table to the FROM clause for a dynamic loader would affect the ability of
the :class:`.Query` to make a subsequent join to another entity.   The fix
adds the primary entity as the first element of the FROM list since
:meth:`.Query.join` wants to jump from that.   Version 1.3 will have
a more comprehensive solution to this problem as well (🎫`4365`).

Fixes: #4363
Change-Id: I1abbb6207722619dc5369e1fd96de43d60a1ee62
(cherry picked from commit 40c1a46e99)
2018-11-13 18:36:52 -05:00
Mike Bayer 6726c60e4c Version 1.2.15 placeholder 2018-11-10 15:59:12 -05:00
Mike Bayer 7f1294cbe5 Use case insensitive matching on lower_case_table_names=1,2
Fixed regression caused by 🎫`4344` released in 1.2.13, where the fix
for MySQL 8.0's case sensitivity problem with referenced column names when
reflecting foreign key referents is worked around using the
``information_schema.columns`` view.  The workaround was failing on OSX /
``lower_case_table_names=2`` which produces non-matching casing for the
``information_schema.columns`` vs. that of ``SHOW CREATE TABLE``, so in
case-insensitive SQL modes case-insensitive matching is now used.

Fixes: #4361
Change-Id: I748549bc4c27fad6394593f8ec93fc22bfd01f6c
(cherry picked from commit af159c5695)
2018-11-09 23:22:43 -05:00
Mike Bayer eb5d6f9da8 Improve documentation re: Session.binds and partitioning strategies
Update documentation to include background on arbitrary superclass
usage, add full cross-linking between all related methods and parameters.
De-emphasize "twophase" and document that it is not well-supported
in drivers.

Change-Id: Id99894bb62cc506e896c9aa7c256e9f6e602243e
(cherry picked from commit 1f13c8c833)
2018-11-06 15:14:44 -05:00
Lele Gaifax a43ed02778 Minor cosmetic tweaks to reST markup
(cherry picked from commit e0dd82f267)
2018-11-03 12:37:35 -04:00
Mike Bayer 8e9467b050 Deannotate ORM columns in ColumnEntity
Fixed a minor performance issue which could in some cases add unnecessary
overhead to result fetching, involving the use of ORM columns and entities
that include those same columns at the same time within a query.  The issue
has to do with hash / eq overhead when referring to the column in different
ways.

Fixes: #4347
Change-Id: I191d4d1b1623898060a9accdfd186de16f89a6b7
(cherry picked from commit 88bfa1b89c)
2018-11-02 19:24:59 -04:00
Mike Bayer 50170e62b3 Use attr keys when testing bulk update params for primary key
Fixed bug in :meth:`.Session.bulk_update_mappings` where alternate mapped
attribute names would result in the primary key column of the UPDATE
statement being included in the SET clause, as well as the WHERE clause;
while usually harmless, for SQL Server this can raise an error due to the
IDENTITY column.  This is a continuation of the same bug that was fixed in
🎫`.3849`, where testing was insufficient to catch this additional
flaw.

Fixes: #4357
Change-Id: Iead058c0465dfa31c5b8a8780769278b7000acc8
(cherry picked from commit e991684a39)
2018-11-01 21:54:37 -04:00
Mike Bayer 3ab8379d70 Version 1.2.14 placeholder 2018-10-31 16:49:14 -04:00
Chris Macklin 2c858260c4 Add missing index method to _AssociationList.
Added missing ``.index()`` method to list-based association collections
in the association proxy extension.

Change-Id: Ice81dc4bcccd520638c5bc9a0f8bb2027946c846
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/485
(cherry picked from commit 1c3b2d7186)
2018-10-31 11:30:10 -04:00
mike bayer 448db7ac4c Merge "Move pk on single-inh subclass check below conflict resolution check" into rel_1_2 2018-10-31 15:25:06 +00:00
Tom Manderson 6ec2246d04 Move pk on single-inh subclass check below conflict resolution check
The column conflict resolution technique discussed at
:ref:`declarative_column_conflicts` is now functional for a :class:`.Column`
that is also a primary key column.  Previously, a check for primary key
columns declared on a single-inheritance subclass would occur before the
column copy were allowed to pass.

Fixes: #4352
Change-Id: Id4c025da53c28e58db6b549fe398f25f8a90d355
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/483
(cherry picked from commit 3ed79a5c18)
2018-10-30 13:31:53 -04:00
Alex Hall 353d416341 Add reserved word 'function' for MySQL
Added word ``function`` to the list of reserved words for MySQL, which is
now a keyword in MySQL 8.0

Fixes: #4348
Change-Id: Idd30acda7e99076810f65d0ee860055a18dc9193
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/481
(cherry picked from commit 38c81328e9)
2018-10-30 13:13:03 -04:00
wodim 7a1c19833e Add missing space 2018-10-30 13:04:27 -04:00
David Poggi 170b26687e re-word recycle parameter documentation
Change-Id: I80cabcd9fa3f3b45e5355bf6c774a8eee02e7f1b
(cherry picked from commit 83864ffe63)
2018-10-30 13:03:14 -04:00
James Owen d98fbf1820 Add warning to hybrid property expression and fixup crosslinks
(cherry picked from commit 681bd7eb88)
2018-10-30 12:58:47 -04:00
Mike Bayer dc21de59ca Check more specifically for hybrid attr and not mapped property
Fixed regression caused by 🎫`4326` in version 1.2.12 where using
:class:`.declared_attr` with a mixin in conjunction with
:func:`.orm.synonym` would fail to map the synonym properly to an inherited
subclass.

Fixes: #4350
Change-Id: Ib2a9b6a125a2ac7c7ff80201746b7f10e5596226
(cherry picked from commit 9335c24d6c)
2018-10-20 12:15:34 -04:00