Commit Graph

11809 Commits

Author SHA1 Message Date
Mike Bayer 55f930ef3d cherry-pick changelog update for 1.2.17 2019-01-11 10:15:39 -05:00
Mike Bayer b4a8c1fbcf cherry-pick changelog from 1.2.16 2019-01-11 10:15:38 -05:00
Mike Bayer 6f270fb0e3 happy new year
Change-Id: I6a71f4924d046cf306961c58dffccf21e9c03911
2019-01-11 10:06:10 -05:00
Mike Bayer 2db54ee92e 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
2019-01-10 18:02:00 -05:00
mike bayer f1706ae317 Merge "Skip expression-based index reflection for SQLite" 2019-01-10 02:07:24 +00:00
Mike Bayer 08994cb97c 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
2019-01-09 21:06:57 -05:00
Mike Bayer 2a840c147e 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
2019-01-09 11:18:02 -05:00
Charles S. Givre 86f243a874 Update index.rst - Added link to Drill dialect.
Added link to Apache Drill dialect.
2019-01-08 14:45:19 -05:00
Mike Bayer 1e278de4cc 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 18:23:11 -05:00
Mike Bayer 1e1a38e780 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 17:34:50 +00:00
Mike Bayer 404e69426b 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
2019-01-05 23:51:34 -05:00
Mike Bayer d229360a8d 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
2019-01-03 22:28:09 -05:00
Mike Bayer 1eaf9dc777 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
2018-12-31 00:20:08 -05:00
Lele Gaifax c0f9708fde 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
2018-12-30 21:16:52 -05:00
mike bayer cfc49b4571 Merge "Check collection less than two items remaining before firing scalar backref remove" 2018-12-29 07:59:58 +00:00
mike bayer 010dd34e7c Merge "Call __del() before remove()" 2018-12-29 07:58:21 +00:00
Mike Bayer 16f08cbed5 Add missing disambiguation to non-primary mapper example
The mapping to B over a join defines an alternate primary key
based on all the primary key columns in the join unless we
re-define it explicitly.   Similarly, people expect that
``.id`` looks the same.  make sure these line up with the
old mapping.

Change-Id: I1ab064c57019e79c34293f6588d1e033f7083974
2018-12-28 09:36:24 -05:00
Mike Bayer 847d135942 Check collection less than two items remaining before firing scalar backref remove
Fixed long-standing issue where duplicate collection members would cause a
backref to delete the association between the member and its parent object
when one of the duplicates were removed, as occurs as a side effect of
swapping two objects in one statement.

Fixes: #1103
Change-Id: Ic12877f7bd5a4eb688091725a78410748e7fdf16
2018-12-28 08:40:44 -05:00
Mike Bayer 07cea66ccb Call __del() before remove()
The "remove" event for collections is now called before the item is removed
in the case of the ``collection.remove()`` method, as is consistent with the
behavior for most other forms of collection item removal (such as
``__delitem__``, replacement under ``__setitem__``).  The ``pop()`` methods
are now the only exception as the target item is not available until after
the pop operation proceeds.

This allows ``remove()`` to be consistent in its behavior with all
the other collection operations, allows the "before_delete" hook
to be local to "pop()" operations only, and removes some method overhead.

We are also looking here to gain some more predictability in terms
of the fix for #1103.

Change-Id: I4fdea911517d65cc300fae0e9c351a471e52e4ab
2018-12-28 08:37:03 -05:00
Mike Bayer ec5c9ebe6e Implement SynonymProperty.get_history()
Implemented the ``.get_history()`` method, which also implies availability
of :attr:`.AttributeState.history`, for :func:`.synonym` attributes.
Previously, trying to access attribute history via a synonym would raise an
``AttributeError``.

Fixes: #3777
Change-Id: I20810a8b1a1bf630dbcb6622193c13cf4236b94a
2018-12-27 12:39:15 -05:00
Mike Bayer eae62d0004 - remove non-working dialects some of which are 404's
- put the five major dialect names on the front page
- remove old change messages

Change-Id: Ibf1dc2c499f10f98efb6c97d6c53e442e7746200
2018-12-24 00:07:22 -05:00
mike bayer d27023a30d Merge "Add before_mapper_configured event" 2018-12-23 15:44:37 +00:00
mike bayer 504432ed57 Merge "Maintain compiled_params / replacement_expressions within expanding IN" 2018-12-22 13:54:11 +00:00
Mike Bayer c495769751 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
2018-12-21 21:50:55 -05:00
mike bayer 1ae613f4e4 Merge "Handle PostgreSQL enums in remote schemas" 2018-12-21 22:23:07 +00:00
Mike Bayer 41f47fb72c add pull request template
Change-Id: I850c246e4f0feb62dca083909e5d010ce8288a3d
2018-12-21 14:13:41 -05:00
Mike Bayer 0b0a4c8ba2 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
2018-12-21 13:53:16 -05:00
Mike Bayer 7f12f63c3a 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
2018-12-21 12:13:13 -05:00
mike bayer b5592de30e Merge "Fix the "greatest" example." 2018-12-20 15:32:12 +00:00
mike bayer f834238d44 Merge "Omit include of no longer existing files" 2018-12-20 15:29:34 +00:00
Michael Howitz 69273bef0a Omit include of no longer existing files
Warnings are generated during setup.py install such as:

```
Getting distribution for 'SQLAlchemy==1.2.15'.
warning: no files found matching '*.jpg' under directory 'doc'
warning: no files found matching '*.mako' under directory 'doc'
warning: no files found matching 'distribute_setup.py'
warning: no files found matching 'sa2to3.py'
warning: no files found matching 'ez_setup.py'
```

This change removes those expressions from MANIFEST.in.

Closes: #4408
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4408
Pull-request-sha: 448b3a9dc8

Change-Id: Id6373611fb384e230427f87b9e75672d78483000
2018-12-20 14:55:32 +00:00
Konstantin Tretyakov 8722fb84a6 Fix the "greatest" example.
The current example code does not pass `**kw` down to the `compiler.process` calls, thus the example does not work when invoked with, `literal_binds=True`.

Besides, the calls to `process` each argument twice are wasteful, and reusing the built-in `case` expression instead of hard-coding the SQL statements is slightly nicer overall, isn't it?

Closes: #4402
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4402
Pull-request-sha: 24ee93f63e

Change-Id: I02424d9eb2b35abd5cdec5c2cd5d464a56e7fae6
2018-12-17 17:21:03 -05:00
mike bayer 3b6ff1b9f9 Merge "Add missing parameter to docstring" 2018-12-17 21:22:58 +00:00
Agam Rafaeli b1e4b59781 Add missing parameter to docstring
Closes: #4410
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4410
Pull-request-sha: 070a0f44f3

Change-Id: I7a026bf6a2041e7686d90d5f155b88d8001f2ba8
2018-12-17 12:58:19 -05:00
Agam Rafaeli 99fc012d72 Set a reading order to the compatibility import file
The order is as follows:
1. Imports, in the same format of "import X"
2. Members denoting versions of python
3. Members of imports that are shadowed for usage across the system
4. Global variables
5. If conditions of imports. (internally organized by this order)
6. Function definitions

Closes: #4409
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4409
Pull-request-sha: a7eb52d39f

Change-Id: I2fa44d1aebd7575df968f2e3f3fc7d474fa3c6d7
2018-12-17 11:20:09 -05:00
Mike Bayer d4a130bb1b 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
2018-12-12 12:54:20 -05:00
Mike Bayer 7206308e7f cherry-pick changelog update for 1.2.16 2018-12-11 16:56:37 -05:00
Mike Bayer 9e98a2c864 cherry-pick changelog from 1.2.15 2018-12-11 16:56:37 -05:00
Chris Wilson 65ea042302 Add before_mapper_configured event
This event is intended to allow a specific mapper to be skipped during the
configure step, by returning a value of `.orm.interfaces.EXT_SKIP` which means
the mapper will be skipped within this configure run. The "new mappers" flag
will remain set in this case and the configure operation will occur again.

This event, and its return value, make it possible to query one base while a
different one still needs configuration, which cannot be completed at this
time.

Fixes: #4397

Change-Id: I122e556f6a4ff842ad15315dcf39e19bb7f9a744
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4403
2018-12-10 22:31:21 -05:00
mike bayer 0d4c0c1a27 Merge "Refer to existing of_type when resolving string attribute name" 2018-12-08 14:19:28 +00:00
mike bayer bfd3a685d6 Merge "Take instance into account when determining AssociationProxyInstance" 2018-12-08 14:18:53 +00:00
Mike Bayer d6f406e633 Take instance into account when determining AssociationProxyInstance
Fixed a regression in 1.3.0b1 caused by 🎫`3423` where association
proxy objects that access an attribute that's only present on a polymorphic
subclass would raise an ``AttributeError`` even though the actual instance
being accessed was an instance of that subclass.

Fixes: #4401
Change-Id: Ie62c48aa9142adff45cbf9a297184987c72f30f3
2018-12-07 22:40:50 -05:00
Mike Bayer 099f3fd812 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
2018-12-07 16:03:17 -05:00
Mike Bayer 5851bf1138 Add versioned_update_old_row example
A modification to the "turn UPDATE into INSERT" recipe that
also UPDATEs the previous row.  The example is using timestamps
to maintain a relationship between two objects.

Change-Id: Ifdb8ee73616190384263bbe88c71d9278d616f6b
2018-12-07 14:01:23 -05:00
Mike Bayer c89729cf67 - fix formatting on examples to list the description first, some flake8
Change-Id: I57144a559f20abab02e745d052be5ff84edec7f8
2018-12-07 12:17:59 -05:00
adriennefranke 09856b911b Fixed typo in docs
Fixes: #4166
Fixes: #4399
Change-Id: I49494209463089114e77dfc737c811837d49ea20
2018-12-05 20:31:31 -05:00
Agam Rafaeli 23224f6e99 Removed the leading underscore for visitor_iterator property
A leading underscore usually denotes a private member. Since this
is a property and it is used in Query I removed the leading underscore

Change-Id: I8a35c09fd6d20ee0a13568ed7257a08b7bee2a08
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4398
2018-12-05 16:12:59 -05:00
mike bayer e0200cf6f0 Merge "Move CRUDTest, InlineDefaultTest from test_compiler" 2018-12-04 14:28:10 +00:00
Mike Bayer 89f95e9bad All sphinx dependencies move under the github sqlalchemy organization
Change-Id: I7a0dc1ef320b6abad0eeac8b24c20f821e5b8c81
2018-12-03 17:02:23 -05:00
mike bayer 656c5f3113 Merge "Fix PostgreSQL reflection of domains expressed as arrays" 2018-12-03 02:35:11 +00:00