]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
8 years agoMerge "Consider version_id_prop when emitting bulk UPDATE"
mike bayer [Thu, 10 Nov 2016 22:22:41 +0000 (17:22 -0500)] 
Merge "Consider version_id_prop when emitting bulk UPDATE"

8 years agoConsider version_id_prop when emitting bulk UPDATE
Mike Bayer [Wed, 5 Oct 2016 20:55:43 +0000 (16:55 -0400)] 
Consider version_id_prop when emitting bulk UPDATE

The version id needs to be part of _changed_dict()
so that the value is present to send to
_emit_update_statements()

Change-Id: Ia85f0ef7714296a75cdc6c88674805afbbe752c8
Fixes: #3781
8 years agoAdd conditional import for pysqlcipher3
Kevin Jurczyk [Thu, 10 Nov 2016 16:21:14 +0000 (11:21 -0500)] 
Add conditional import for pysqlcipher3

This is a Py3K supporting DBAPI for pysqlcipher.

Change-Id: I2a625274a371908f4de9d37f33e05408894b334b
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/320

8 years agoMerge "Remove non-working Connection.default_schema_name() method"
mike bayer [Thu, 10 Nov 2016 20:30:04 +0000 (15:30 -0500)] 
Merge "Remove non-working Connection.default_schema_name() method"

8 years agoAdd support for server side cursors to mysqldb and pymysql
Roman Podoliaka [Thu, 3 Nov 2016 22:31:05 +0000 (00:31 +0200)] 
Add support for server side cursors to mysqldb and pymysql

This allows to skip buffering of the results on the client side, e.g.
the following snippet:

    table = sa.Table(
        'testtbl', sa.MetaData(),
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('a', sa.Integer),
        sa.Column('b', sa.String(512))
    )
    table.create(eng, checkfirst=True)

    with eng.connect() as conn:
        result = conn.execute(table.select().limit(1)).fetchone()
        if result is None:
            for _ in range(1000):
                conn.execute(
                    table.insert(),
                    [{'a': random.randint(1, 100000),
                      'b': ''.join(random.choice(string.ascii_letters) for _ in range(100))}
                      for _ in range(1000)]
                )

    with eng.connect() as conn:
        for row in conn.execution_options(stream_results=True).execute(table.select()):
            pass

now uses ~23 MB of memory instead of ~327 MB on CPython 3.5.2 and
PyMySQL 0.7.9.

psycopg2 implementation and execution options (stream_results,
server_side_cursors) are reused.

Change-Id: I4dc23ce3094f027bdff51b896b050361991c62e2

8 years agoRemove non-working Connection.default_schema_name() method
Benjamin Dopplinger [Thu, 10 Nov 2016 16:15:37 +0000 (11:15 -0500)] 
Remove non-working Connection.default_schema_name() method

The method `engine.base.Connection.default_schema_name` is broken since
4b532e2 (this was when `engine.dialect.get_default_schema_name` was
replaced with `engine.dialect.default_schema_name`).  The method is
unused and also is not functional for end-user use, so remove it
for now.

Change-Id: I6ffbd9ce1b9b54ff6df63ed45d7d33591f183933
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/321

8 years agoEnsure attribute keys used for bulk update pk set
Mike Bayer [Thu, 10 Nov 2016 16:08:52 +0000 (11:08 -0500)] 
Ensure attribute keys used for bulk update pk set

Fixed bug in :meth:`.Session.bulk_update_mappings` where an alternate-named
primary key attribute would not track properly into the UPDATE statement.

Change-Id: I33e9140f45827772768fa548adcfeb4dbfc2208d
Fixes: #3849
8 years agoAdd quotes around PRAGMA values in pysqlcipher connect.
Kevin Jurczyk [Tue, 8 Nov 2016 17:12:16 +0000 (12:12 -0500)] 
Add quotes around PRAGMA values in pysqlcipher connect.

Arguments such as cipher, kdf_iter, cipher_page_size and
cipher_use_hmac may (always?) require quotes within the
PRAGMA directive.

Change-Id: I2c808f34e1c44f0593b72b304e170e4af0a6035a
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/319

8 years agoPut include_table=True for DO UPDATE..WHERE, but not ON CONFLICT
Mike Bayer [Tue, 8 Nov 2016 02:41:11 +0000 (21:41 -0500)] 
Put include_table=True for DO UPDATE..WHERE, but not ON CONFLICT

Fixed regression caused by the fix in :ticket:`3807` (version 1.1.0)
where we ensured that the tablename was qualified in the WHERE clause
of the DO UPDATE portion of PostgreSQL's ON CONFLICT, however you
*cannot* put the table name in the  WHERE clause in the actual ON
CONFLICT itself.   This was an incorrect assumption, so that portion
of the change in :ticket:`3807` is rolled back.

Change-Id: I442d8629496a8e405b54711cfcf487761810ae8a
Fixes: #3846
Fixes: #3807
8 years agoMove setup functionality into _register_attribute
Mike Bayer [Sun, 6 Nov 2016 17:46:28 +0000 (12:46 -0500)] 
Move setup functionality into _register_attribute

Options like uselist and backref can be determined from
within _register_attribute based on parent_property
given; move this logic inside so that individual strategies
have less responsibility.  Also don't require that
_register_attribute consider the "strategy" itself
at all; it would be better if we could no longer require
that Joined/Subquery/etc loaders call upon the "lazy" strategy
in order to initialize attribute instrumentation and
this could be done more generically.

Fixes long-standing bug where the "noload" relationship loading
strategy would cause backrefs and/or back_populates options to be
ignored.   There is concern that some application that uses
"noload" might be surprised at a back-populating attribute
appearing suddenly, which may have side effects.  However,
"noload" itself must be extremely seldom used since as a
strategy, it already disables loading, population of attributes
is the only behavior that is even supported, so that this issue has existed
for at least through 0.7 four years ago without ever being
reported indicates extremely low use of this option.

Change-Id: Icffb9c83ac5782b76ce882ed1df4361a1efbfba3
Fixes: #3845
8 years agoAdd check for blank string coming from MySQL's enum
Mike Bayer [Fri, 28 Oct 2016 18:13:31 +0000 (14:13 -0400)] 
Add check for blank string coming from MySQL's enum

MySQL's native ENUM type supports any non-valid value being sent, and
in response will return a blank string.  A hardcoded rule to check for
"is returning the blank string" has been added to the  MySQL
implementation for ENUM so that this blank string is returned to the
application rather than being rejected as a non-valid value.  Note that
if your MySQL enum is linking values to objects, you still get the
blank string back.

Change-Id: I61f85c20293a48b0c11a31f2a19f6756c206bd20
Fixes: #3841
8 years ago- 1.1.4 versioning
Mike Bayer [Fri, 28 Oct 2016 18:14:32 +0000 (14:14 -0400)] 
- 1.1.4 versioning

Change-Id: I6545ebfeeee103cac133d0b8270a860cba2d2996

8 years ago- 1.1.3 rel_1_1_3
Mike Bayer [Thu, 27 Oct 2016 14:47:26 +0000 (10:47 -0400)] 
- 1.1.3

8 years agoMerge "Restore object to the identity_map upon delete() unconditionally"
mike bayer [Thu, 27 Oct 2016 14:46:15 +0000 (10:46 -0400)] 
Merge "Restore object to the identity_map upon delete() unconditionally"

8 years agoRestore object to the identity_map upon delete() unconditionally
Mike Bayer [Thu, 27 Oct 2016 13:51:50 +0000 (09:51 -0400)] 
Restore object to the identity_map upon delete() unconditionally

Fixed regression caused by :ticket:`2677` whereby calling
:meth:`.Session.delete` on an object that was already flushed as
deleted in that session would fail to set up the object in the
identity map (or reject the object), causing flush errors as the
object were in a state not accommodated by the unit of work.
The pre-1.1 behavior in this case has been restored, which is that
the object is put back into the identity map so that the DELETE
statement will be attempted again, which emits a warning that the number
of expected rows was not matched (unless the row were restored outside
of the session).

Change-Id: I9a8871f82cb1ebe67a7ad54d888d5ee835a9a40a
Fixes: #3839
8 years agoMinor fixes in the ext.hybrid documentation.
Randy Barlow [Sun, 23 Oct 2016 14:34:25 +0000 (10:34 -0400)] 
Minor fixes in the ext.hybrid documentation.

8 years agoEnsure .mapper is set on _ColumnEntity
Mike Bayer [Fri, 21 Oct 2016 13:34:32 +0000 (09:34 -0400)] 
Ensure .mapper is set on _ColumnEntity

_ColumnEntity didn't seem to have .mapper present, which
due to the way _mapper_zero() worked didn't tend to come
across it.   With :ticket:`3608` _mapper_zero() has
been simplified so make sure this is now present.
Also ensure that _select_from_entity is an entity and
not a mapped class, though this does not seem to matter
at the moment.

Fixes: #3836
Change-Id: Id6dae8e700269b97de3b01562edee95ac1e01f80

8 years agoDon't set pg autoincrement if type affinity is not Integer
Mike Bayer [Thu, 20 Oct 2016 21:36:59 +0000 (17:36 -0400)] 
Don't set pg autoincrement if type affinity is not Integer

Postgresql table reflection will ensure that the
:paramref:`.Column.autoincrement` flag is set to False when reflecting
a primary key column that is not of an :class:`.Integer` datatype,
even if the default is related to an integer-generating sequence.
This can happen if a column is created as SERIAL and the datatype
is changed.  The autoincrement flag can only be True if the datatype
is of integer affinity in the 1.1 series.

This bug is related to a test failure in downstream sqlalchemy_migrate.

Change-Id: I40260e47e1927a1ac940538408983c943bbdba28
Fixes: #3835
8 years agoMerge "Convert expression type for concat + Enum"
mike bayer [Thu, 20 Oct 2016 20:37:00 +0000 (16:37 -0400)] 
Merge "Convert expression type for concat + Enum"

8 years agoDocument Enum.enums is now a list
Mike Bayer [Thu, 20 Oct 2016 20:29:30 +0000 (16:29 -0400)] 
Document Enum.enums is now a list

Change-Id: I27251c262f919df1b084cbb08759f672f05cd3f7
Fixes: #3834
8 years agoConvert expression type for concat + Enum
Mike Bayer [Thu, 20 Oct 2016 19:59:46 +0000 (15:59 -0400)] 
Convert expression type for concat + Enum

Fixed bug involving new value translation and validation feature
in :class:`.Enum` whereby using the enum object in a string
concatenation would maintain the :class:`.Enum` type as the type
of the expression overall, producing missing lookups.  A string
concatenation against an :class:`.Enum`-typed column now uses
:class:`.String` as the datatype of the expression itself.

Change-Id: Id402054e3ef008e0250c740dbb7e1c80f339fe78
Fixes: #3833
8 years agoEnsure TypeDecorator delegates _set_parent_with_dispatch
Mike Bayer [Thu, 20 Oct 2016 14:24:40 +0000 (10:24 -0400)] 
Ensure TypeDecorator delegates _set_parent_with_dispatch

Ensure TypeDecorator delegates _set_parent_with_dispatch as well as
_set_parent to itself as well as its impl, as the TypeDecorator
class itself may have an active SchemaType implementation as well.

Fixed regression which occurred as a side effect of :ticket:`2919`,
which in the less typical case of a user-defined
:class:`.TypeDecorator` that was also itself an instance of
:class:`.SchemaType` (rather than the implementation being such)
would cause the column attachment events to be skipped for the
type itself.

Change-Id: I0afb498fd91ab7d948e4439e7323a89eafcce0bc
Fixes: #3832
8 years ago- open for 1.1.3
Mike Bayer [Thu, 20 Oct 2016 15:46:41 +0000 (11:46 -0400)] 
- open for 1.1.3

Change-Id: I283e52a7a63ec4f7a285aba1b41627f11b7ad41b

8 years agoRewrite migration notes for [ticket:3514]
Mike Bayer [Wed, 19 Oct 2016 16:52:55 +0000 (12:52 -0400)] 
Rewrite migration notes for [ticket:3514]

The change to "evaluates none" datatypes in the ORM was
not fully described in the migration notes, missing the
key behavioral change that a column which is missing a default
entirely will not receive a value for a missing JSON column now.
The issue here touched upon a revisit of the assumptions
in [ticket:3514], but overall the old behavior "worked" mostly
because the ORM wants to explicitly render NULL into an INSERT
for column values that are missing, which itself is a legacy
behavior which should be considered for possible removal in
a future major release.  Given that "missing ORM value + no
column default set up == dont put it in the INSERT" would be
the most intuitive behavior, the move in [ticket:3514] represents
a step in this direction.

Change-Id: I454d5bb0773bd73d9864925dcc47f1f0810e33ba
Fixes: #3830
8 years ago- 1.1.2 rel_1_1_2
Mike Bayer [Mon, 17 Oct 2016 18:29:01 +0000 (14:29 -0400)] 
- 1.1.2

8 years ago- correct ticket link markup
Mike Bayer [Mon, 17 Oct 2016 18:27:53 +0000 (14:27 -0400)] 
- correct ticket link markup

Change-Id: I49df318c77f9f539541e7edea857bd256aca2844

8 years agoMerge "Add a qualifying character to multi INSERT..VALUES parameter names"
mike bayer [Mon, 17 Oct 2016 16:49:12 +0000 (12:49 -0400)] 
Merge "Add a qualifying character to multi INSERT..VALUES parameter names"

8 years agoRemove the use of the word "fundamental" to describe ColumnElements
Mike Bayer [Mon, 17 Oct 2016 16:35:26 +0000 (12:35 -0400)] 
Remove the use of the word "fundamental" to describe ColumnElements

The context is unclear if "fundamental" refers to the object's
role within a SELECT composition or within the class hierarchy
of ClauseElement classes.

Change-Id: I10bbf324fc09034cc27398867b7eca6b6f127abe
Fixes: #3793
8 years agoAdd a qualifying character to multi INSERT..VALUES parameter names
Mike Bayer [Mon, 17 Oct 2016 15:07:14 +0000 (11:07 -0400)] 
Add a qualifying character to multi INSERT..VALUES parameter names

Changed the naming convention used when generating bound parameters
for a multi-VALUES insert statement, so that the numbered parameter
names don't conflict with the anonymized parameters of a WHERE clause,
as is now common in a PostgreSQL ON CONFLICT construct.

Change-Id: I3188d100fe4d322a47d344d6a63d3e40b915f228
Fixes: #3828
8 years agoAdd explicit copy() to Enum
Mike Bayer [Mon, 17 Oct 2016 04:22:38 +0000 (00:22 -0400)] 
Add explicit copy() to Enum

The Boolean and Enum types both place SchemaType second in the
inheritance hierarchy.  In the case of Enum, this works
out that the copy() method is called from the base TypeEngine
which fails to transfer _create_events.   The test suite
doesn't seem to work with the inhertance hierarchy set up like
this as the event listeners don't work out, the _on_metadata_create
and _on_table_create hooks cause the production of an adapted type
which then adds event listeners that cause deque changed while
iteration.  It's not clear why Enum /Boolean don't have this problem.
But in any case it seems like the class mechanics for these types
remains fragile and would benefit from yet another refactor someday.

Change-Id: Ib641a5d2321b00f58bbe98dd0c5e789374db32b2
Fixes: #3827
8 years agoMemoize load_path in all cases, run quick populators for path change
Mike Bayer [Thu, 13 Oct 2016 16:27:18 +0000 (12:27 -0400)] 
Memoize load_path in all cases, run quick populators for path change

Adds a new variant to the "isnew" state within entity loading
for isnew=False, but the load path is new.  This is to address
the use case of an entity appearing in multiple places in
the row in a more generalized way than the fixes in [ticket:3431],
[ticket:3811] in that loading.py will be able to tell the
populator that this row is not "isnew" but is a "new" path
for the entity.   For the moment, the new information is only
being applied to the use of "quick" populators so that
simple column loads can take place on top of a deferred loader
from elsewhere in the row.

As part of this change, state.load_path() will now always
be populated with the "path" that was in effect when this state
was originally loaded, which for multi-path loads of the
same entity is still non-deterministic.  Ideally there'd be some
kind of "here's all the paths that loaded this state and how"
type of data structure though it's not clear if that could be
done while maintaining performance.

Fixes: #3822
Change-Id: Ib915365353dfcca09e15c24001a8581113b97d5e

8 years agoAssemble "don't joinedload other side" rule using query._current_path
Mike Bayer [Fri, 14 Oct 2016 21:06:07 +0000 (17:06 -0400)] 
Assemble "don't joinedload other side" rule using query._current_path

Discovered during testing for [ticket:3822], the rule added
for [ticket:1495] will fail if the source object has propagated
options set up, which add elements to query._current_path.

Fixes: #3824
Change-Id: I3d96c96fee5f9b247f739d2136d18681ac61f2fe

8 years agoMerge "Check for __module__ not present in util.wrap_callable()"
mike bayer [Mon, 17 Oct 2016 15:28:43 +0000 (11:28 -0400)] 
Merge "Check for __module__ not present in util.wrap_callable()"

8 years agoRemove some legacy dead code from the declared_attr logic
Pierre Jaury [Sun, 16 Oct 2016 14:45:54 +0000 (16:45 +0200)] 
Remove some legacy dead code from the declared_attr logic

The second 'if' condition was never called because the original
condition always returns.

8 years agoCheck for __module__ not present in util.wrap_callable()
Mike Bayer [Fri, 14 Oct 2016 17:26:35 +0000 (13:26 -0400)] 
Check for __module__ not present in util.wrap_callable()

The newly added wrap_callable() function assumes __module__
is present when this is not the case for objects such as
functools.partial.

Change-Id: Ia226260e9a65419e26d5c1f7187512f7fd4bb7c1
Fixes: #3823
8 years agoFix a minor grammatical error in the ORM tutorial.
Randy Barlow [Thu, 13 Oct 2016 16:58:14 +0000 (12:58 -0400)] 
Fix a minor grammatical error in the ORM tutorial.

Change-Id: I50daaee2645dd8aa2ee7217f4065589492ed0b7d

8 years ago- setup for next version
Mike Bayer [Thu, 13 Oct 2016 16:27:51 +0000 (12:27 -0400)] 
- setup for next version

Change-Id: I4a7ef54bec3891821954061a9b4ed19d398989f3

8 years agoUpdate the Column.nullable docstring for the primary_key=True case
Matt Riedemann [Mon, 10 Oct 2016 15:43:07 +0000 (11:43 -0400)] 
Update the Column.nullable docstring for the primary_key=True case

While reviewing a change that created a new table, the
primary_key column value was set to True but nullable was not
explicitly set, which led to some confusion over the default
behavior for the nullable column value when setting a primary_key.

Looking at the docs it's not clear, but the code shows that if
nullable is not specified, then nullable = not primary_key, so
nullable defaults to False when primary_key is True.

This patch adds a simple clarification to the docs so people
don't have to check the code.

Change-Id: I8553339d56fbae11370c7c6af6d8d4723163be1c
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/312

8 years agospelling: Mysql -> MySQL
Ville Skyttä [Fri, 7 Oct 2016 10:21:30 +0000 (13:21 +0300)] 
spelling: Mysql -> MySQL

8 years agospelling: Postgis -> PostGIS
Ville Skyttä [Fri, 7 Oct 2016 10:20:24 +0000 (13:20 +0300)] 
spelling: Postgis -> PostGIS

8 years agospelling: Postgresql -> PostgreSQL
Ville Skyttä [Fri, 7 Oct 2016 10:18:58 +0000 (13:18 +0300)] 
spelling: Postgresql -> PostgreSQL

8 years agoSpelling fixes
Ville Skyttä [Fri, 7 Oct 2016 10:06:09 +0000 (13:06 +0300)] 
Spelling fixes

8 years ago- 1.1.1 rel_1_1_1
Mike Bayer [Fri, 7 Oct 2016 15:04:37 +0000 (11:04 -0400)] 
- 1.1.1

8 years agoChange autoincrement compileerror to a warning
Mike Bayer [Fri, 7 Oct 2016 13:05:34 +0000 (09:05 -0400)] 
Change autoincrement compileerror to a warning

Users are complaining that IntegrityError is no longer
raised.

Change-Id: I0855d5b7a98d4338f0910501b6e6d404ba33634d
Fixes: #3216
8 years agoCatch DBAPIError instead of ProgrammingError for pyodbc fail
Mike Bayer [Fri, 7 Oct 2016 13:16:22 +0000 (09:16 -0400)] 
Catch DBAPIError instead of ProgrammingError for pyodbc fail

Change-Id: Ide9e916d02fbbef549aa2838d1402c2b091e701d
Fixes: #3820
8 years ago- set up for 1.1.1
Mike Bayer [Thu, 6 Oct 2016 02:31:31 +0000 (22:31 -0400)] 
- set up for 1.1.1

Change-Id: I569a03a6e86aa096be6744ecb479fe8485f7def6

8 years ago- 1.1.0 rel_1_1_0
Mike Bayer [Wed, 5 Oct 2016 20:59:00 +0000 (16:59 -0400)] 
- 1.1.0

8 years agoMerge "Propagate execution_options at compile stage"
mike bayer [Wed, 5 Oct 2016 20:52:15 +0000 (16:52 -0400)] 
Merge "Propagate execution_options at compile stage"

8 years agoPropagate execution_options at compile stage
Mike Bayer [Wed, 5 Oct 2016 17:59:58 +0000 (13:59 -0400)] 
Propagate execution_options at compile stage

Compiler can now set up execution options and additionally
will propagate autocommit from embedded CTEs.

Change-Id: I19db7b8fe4d84549ea95342e8d2040189fed1bbe
Fixes: #3805
8 years agoMinor grammatical improvements in doc/build/intro.rst.
Randy Barlow [Wed, 5 Oct 2016 19:07:57 +0000 (15:07 -0400)] 
Minor grammatical improvements in doc/build/intro.rst.

8 years agoCheck for __clause_element__() in ORM insert/update
Mike Bayer [Wed, 5 Oct 2016 14:57:30 +0000 (10:57 -0400)] 
Check for __clause_element__() in ORM insert/update

ORM attributes can now be assigned any object that is has a
``__clause_element__()`` attribute, which will result in inline
SQL the way any :class:`.ClauseElement` class does.  This covers other
mapped attributes not otherwise transformed by further expression
constructs.

As part of this, it was considered that we could add
__clause_element__() to ClauseElement, however this causes endless loops
in a "while" pattern and this pattern has been identified in third
party libraries.  Add a test to ensure we never make that change.

Change-Id: I9e15b3f1c4883fd3909acbf7dc81d034c6e3ce1d
Fixes: #3802
8 years agoCheck row for None with implicit returning PK to accommodate ON CONFLICT
Mike Bayer [Tue, 4 Oct 2016 20:46:08 +0000 (16:46 -0400)] 
Check row for None with implicit returning PK to accommodate ON CONFLICT

An adjustment to ON CONFLICT such that the "inserted_primary_key"
logic is able to accommodate the case where there's no INSERT or
UPDATE and there's no net change.  The value comes out as None
in this case, rather than failing on an exception.

Change-Id: I0794e95c3ca262cb1ab2387167d96b8984225fce
Fixes: #3813
8 years agoMerge "Enhance "raise" strategy to include "raise_on_sql" option"
mike bayer [Tue, 4 Oct 2016 20:48:08 +0000 (16:48 -0400)] 
Merge "Enhance "raise" strategy to include "raise_on_sql" option"

8 years agoMerge "Honor additional row coming in with value of None"
mike bayer [Tue, 4 Oct 2016 18:41:43 +0000 (14:41 -0400)] 
Merge "Honor additional row coming in with value of None"

8 years ago- add a few more changes and try to break some out into
Mike Bayer [Tue, 4 Oct 2016 16:33:37 +0000 (12:33 -0400)] 
- add a few more changes and try to break some out into
ORM behavioral changes

Change-Id: I633ff10907b60111d3d0de0970fd384be7931d00

8 years agoEnhance "raise" strategy to include "raise_on_sql" option
Mike Bayer [Mon, 3 Oct 2016 19:55:04 +0000 (15:55 -0400)] 
Enhance "raise" strategy to include "raise_on_sql" option

The "raise_on_sql" option differentiates from "raise" in that
firing a lazy loader is OK as long as it does a simple
get from identity map.   Whereas "raise" is more useful
for the case that objects are to be detached.

As part of this, refactors the strategy initiation logic
a bit so that a LoaderStrategy itself knows what "key" was used
to create it, thus allowing variants of a single strategy
based on what the "lazy" argument is.  To achieve this we
have to also get rid of _get_strategy_by_cls().

Everything here is internal with the one exception of an apparently
undocumented, but not underscored, "strategy_class" key
on relationship().   Though it's not clear what
"strategy_class" accomplishes; at this point the strategy
system is extensible using Property.strategy_for().

Fixes: #3812
Change-Id: I812ad878ea5cf764e15f6f71cb39eee78a645d88

8 years agoHonor additional row coming in with value of None
Mike Bayer [Mon, 3 Oct 2016 20:55:54 +0000 (16:55 -0400)] 
Honor additional row coming in with value of None

The change in #3431 still checks that the instance() is
non-None, deferring to other loading schemes if it is.
These columns are dedicated towards the entity however, so if the value
is None, we should set it.  If it conflicts, we are detecting that
in any case.

Change-Id: I223768e2898e843f953e910da1f9564b137d95e4
Fixes: #3811
8 years ago- add a note to baked documentation indicating it is not
Mike Bayer [Tue, 4 Oct 2016 16:01:12 +0000 (12:01 -0400)] 
- add a note to baked documentation indicating it is not
really of general use.  This extension is there only
for those who really want it based on observed performance
characteristics.

Change-Id: I2f612f26fdef4ddbeb1158ab1b344fad7083b11c

8 years agoUse schema_name() for SQL Server default schema
Mike Bayer [Tue, 4 Oct 2016 15:32:20 +0000 (11:32 -0400)] 
Use schema_name() for SQL Server default schema

Changed the query used to get "default schema name", from one that
queries the database principals table to using the
"schema_name()" function, as issues have been reported that the
former system was unavailable on the Azure Data Warehouse edition.
It is hoped that this will finally work across all SQL Server
versions and authentication styles.

Change-Id: Ic11bd4162c0d6a60432ae44876e86512703c1f81
Fixes: #3810
8 years agoUse SQL Server SERVERPROPERTY for version info w/ pyodbc
Mike Bayer [Tue, 4 Oct 2016 15:17:26 +0000 (11:17 -0400)] 
Use SQL Server SERVERPROPERTY for version info w/ pyodbc

Updated the server version info scheme for pyodbc to use SQL Server
SERVERPROPERTY(), rather than relying upon pyodbc.SQL_DBMS_VER, which
continues to be unreliable particularly with FreeTDS.

Change-Id: I4ff49ae13c8ff51bd764980131d41c18d73d87ce
Fixes: #3814
8 years agoEnsure strong ref to obj before calling persistent_to_deleted, others
Mike Bayer [Mon, 3 Oct 2016 16:25:42 +0000 (12:25 -0400)] 
Ensure strong ref to obj before calling persistent_to_deleted, others

Add checks in spots where state.obj() might be late-GC'ed before
we get a chance to call the event.   There may be more cases
of these which we should address as they come up.  The Session
should always be maintaining strong refs to objects that have
pending operations left on them, so for these cases we need
to ensure that ref remains long enough for the event to be called.

Change-Id: I1a7c7bc57130acc11f54ad55924af2e36ac75101
Fixes: #3808
8 years agoAdd "eager_parenthesis" late-compilation rule, use w/ PG JSON/HSTORE
Mike Bayer [Fri, 30 Sep 2016 14:09:56 +0000 (10:09 -0400)] 
Add "eager_parenthesis" late-compilation rule, use w/ PG JSON/HSTORE

Added compiler-level flags used by Postgresql to place additional
parenthesis than would normally be generated by precedence rules
around operations involving JSON, HSTORE indexing operators as well as
within their operands since it has been observed that Postgresql's
precedence rules for at least the HSTORE indexing operator is not
consistent between 9.4 and 9.5.

Fixes: #3806
Change-Id: I5899677b330595264543b055abd54f3c76bfabf2

8 years ago- some documentation hits
Mike Bayer [Sat, 1 Oct 2016 13:42:21 +0000 (09:42 -0400)] 
- some documentation hits

Change-Id: I468fe70168804b08cf0d5e8b57e235bca904b1ff

8 years agoRemove extra "return" statement in orm.ext.declared_attr.cascading examples
Dmitry Bogun [Sat, 1 Oct 2016 13:22:06 +0000 (09:22 -0400)] 
Remove extra "return" statement in orm.ext.declared_attr.cascading examples

Also improves some naming in the examples.

Change-Id: I51e5b1d9a730885aed10e5e6ade2123f5e736359
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/306

8 years agoEscape literal string values passed to server_default
Mike Bayer [Fri, 30 Sep 2016 13:23:50 +0000 (09:23 -0400)] 
Escape literal string values passed to server_default

A string sent as a column default via the
:paramref:`.Column.server_default` parameter is now escaped for quotes.

This change is backwards compatible with code that may have been
working around this previously.

Change-Id: I341298a76cc67bc0a53df4ab51ab9379f2294cdd
Fixes: #3809
8 years agoEnable include_table for ON CONFLICT whereclauses
Mike Bayer [Wed, 28 Sep 2016 22:01:57 +0000 (18:01 -0400)] 
Enable include_table for ON CONFLICT whereclauses

Fixed issue in new PG "on conflict" construct where columns including
those of the "excluded" namespace would not be table-qualified
in the WHERE clauses in the statement.

Change-Id: Idfefc93e7e7b0d84805e23d5436d822d606f6a0a
Fixes: #3807
8 years agoMerge "Handle BaseException in all _handle_dbapi_error"
mike bayer [Mon, 26 Sep 2016 18:16:32 +0000 (14:16 -0400)] 
Merge "Handle BaseException in all _handle_dbapi_error"

8 years ago- improve documentation for SessionTransaction re: parent
Mike Bayer [Sat, 24 Sep 2016 04:49:22 +0000 (00:49 -0400)] 
- improve documentation for SessionTransaction re: parent
and nested attributes and what these mean
- improve linking for after_transaction_create() / after_transaction_end()
events
- add public .parent attribute to detect top-level transaction within
these events

Change-Id: Ie7382bc8fe5de226160dcb6a5019e19fcc5af38e

8 years ago- clarify documentation on timezone flag, since Oracle has both
Mike Bayer [Thu, 22 Sep 2016 15:08:09 +0000 (11:08 -0400)] 
- clarify documentation on timezone flag, since Oracle has both
DATE / TIMESTAMP separately the timezone flag will not bump the
type to TIMESTAMP WITH TIMEZONE on that backend.

Change-Id: I185992093472e1620b8cf84872631a4d48f8edc3

8 years agoHandle BaseException in all _handle_dbapi_error
Mike Bayer [Wed, 21 Sep 2016 19:37:20 +0000 (15:37 -0400)] 
Handle BaseException in all _handle_dbapi_error

Tests illustrate that exceptions like GreenletExit and
even KeyboardInterrupt can corrupt the state of a DBAPI
connection like that of pymysql and mysqlclient.   Intercept
BaseException errors within the handle_error scheme and
invalidate just the connection alone in this case, but not
the whole pool.

The change is backwards-incompatible with a program that
currently intercepts ctrl-C within a database transaction
and wants to continue working on that transaction.  Ensure
the event hook can be used to reverse this behavior.

Change-Id: Ifaa013c13826d123eef34e32b7e79fff74f1b21b
Fixes: #3803
8 years agoEnsure mapper.polymorphic_on is polymorphic_prop.columns[0]
Mike Bayer [Wed, 21 Sep 2016 21:55:39 +0000 (17:55 -0400)] 
Ensure mapper.polymorphic_on is polymorphic_prop.columns[0]

Fixed bug where joined eager loading would fail for a polymorphically-
loaded mapper, where the polymorphic_on was set to an un-mapped
expression such as a CASE expression.

Change-Id: Iffe68196aaac592165c89684f09f4c06cd78ce54
Fixes: #3800
8 years agoMerge "Add exclude_tablespaces argument to Oracle"
mike bayer [Tue, 20 Sep 2016 23:36:00 +0000 (19:36 -0400)] 
Merge "Add exclude_tablespaces argument to Oracle"

8 years agoMerge "Add the "triggering mapper" to the configure_mappers error message."
mike bayer [Tue, 20 Sep 2016 17:58:55 +0000 (13:58 -0400)] 
Merge "Add the "triggering mapper" to the configure_mappers error message."

8 years agoAdd exclude_tablespaces argument to Oracle
David Fraser [Wed, 14 Sep 2016 19:10:42 +0000 (15:10 -0400)] 
Add exclude_tablespaces argument to Oracle

Allows the SYSTEM and SYSAUX tablespaces to be only
conditionally omitted when doing get_table_names()
and get_temp_table_names().

Change-Id: Ie6995873f05163f2ce473a6a9c2d958a30681b44
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/292

8 years ago- disable two phase testing for mysql entirely, build servers
Mike Bayer [Tue, 20 Sep 2016 17:56:17 +0000 (13:56 -0400)] 
- disable two phase testing for mysql entirely, build servers
have no time to deal with MySQL 5.7's issues

Change-Id: Ic5f4e5b0aff1b4b5210bc7b5da203f536561e585

8 years agoAdd the "triggering mapper" to the configure_mappers error message.
John Perkins [Fri, 5 Aug 2016 17:45:49 +0000 (13:45 -0400)] 
Add the "triggering mapper" to the configure_mappers error message.

There are cases where the originating mapper name is not
present in the exception message, such as relationship initialization
against an unmapped class.   Ensure the originating mapper is named
in the string output.

Pull-request: https://github.com/zzzeek/sqlalchemy/pull/298
Change-Id: I9f23bfa90b26dde9229ab7ec812eec9ceae48153

8 years agoMerge "Allow SQL expressions to be set on PK columns"
mike bayer [Tue, 20 Sep 2016 15:56:05 +0000 (11:56 -0400)] 
Merge "Allow SQL expressions to be set on PK columns"

8 years agoMerge "Exclude eq and ne from associative operators"
mike bayer [Tue, 20 Sep 2016 15:55:19 +0000 (11:55 -0400)] 
Merge "Exclude eq and ne from associative operators"

8 years agoMerge "Support bindparam() with callable for primaryjoin"
mike bayer [Tue, 20 Sep 2016 15:54:47 +0000 (11:54 -0400)] 
Merge "Support bindparam() with callable for primaryjoin"

8 years agoAllow SQL expressions to be set on PK columns
Mike Bayer [Tue, 20 Sep 2016 15:33:16 +0000 (11:33 -0400)] 
Allow SQL expressions to be set on PK columns

Removes an unnecessary transfer of modified PK column
value to the params dictionary, so that if the modified PK column
is already present in value_params, this remains in effect.  Also
propagate a new flag through to _emit_update_statements() that will
trip "return_defaults()" across the board if a PK col w/ SQL expression
change is present, and pull this PK value in _postfetch as well assuming
we're an UPDATE.

Change-Id: I9ae87f964df9ba8faea8e25e96b8327f968e5d1b
Fixes: #3801
8 years agoMerge "Fix ArgumentError access in Session._add_bind"
mike bayer [Mon, 19 Sep 2016 22:15:02 +0000 (18:15 -0400)] 
Merge "Fix ArgumentError access in Session._add_bind"

8 years agoExclude eq and ne from associative operators
John Passaro [Mon, 19 Sep 2016 19:43:46 +0000 (15:43 -0400)] 
Exclude eq and ne from associative operators

The "eq" and "ne" operators are no longer part of the list of
"associative" operators, while they remain considered to be
"commutative".  This allows an expression like ``(x == y) == z``
to be maintained at the SQL level with parenthesis.  Pull request
courtesy John Passaro.

Fixes: #3799
Change-Id: I3759d8987b35649d7418b6524316c9e70c857e68
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/308

8 years agoMerge "Additions to support HAAlchemy plugin"
mike bayer [Mon, 19 Sep 2016 20:25:51 +0000 (16:25 -0400)] 
Merge "Additions to support HAAlchemy plugin"

8 years agoSupport bindparam() with callable for primaryjoin
Mike Bayer [Mon, 19 Sep 2016 20:22:08 +0000 (16:22 -0400)] 
Support bindparam() with callable for primaryjoin

Fixes the comparison of bindparam() objects based on
the "callable" parameter being present which helps to correctly
detect use_get, and also checks for "callable" when detecting
parameters for value substitution and will not impact the
object if present.

Change-Id: I4c93ee5d404d2648dd9835beeae0c5fb67e37d19
Fixes: #3767
8 years agoFix ArgumentError access in Session._add_bind
Mike Bayer [Wed, 14 Sep 2016 19:11:13 +0000 (15:11 -0400)] 
Fix ArgumentError access in Session._add_bind

Fixes: #3798
Change-Id: Ib4e6344b599e871f9d46d36a5aeb7ba3104dc99b
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/293

8 years agoAdd "message 20017" (unexpected EOF from the server) to mssql.
Ken Robbins [Wed, 14 Sep 2016 19:13:30 +0000 (15:13 -0400)] 
Add "message 20017" (unexpected EOF from the server) to mssql.

Fixes: #3791
Change-Id: I0dade4fe0ecbb53b4a66881594f362986ba73ae8
Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/89

8 years agoAdditions to support HAAlchemy plugin
Mike Bayer [Fri, 2 Sep 2016 19:10:32 +0000 (15:10 -0400)] 
Additions to support HAAlchemy plugin

- add a connect=True key to connection record to support
  pre-loading of _ConnectionRecord objects
- ensure _ConnectionRecord.close() leaves the record in a good
  state for reopening
- add _ConnectionRecord.record_info for persistent storage
- add "in_use" accessor based on fairy_ref being present or not
- allow for the exclusions system and SuiteRequirements to be
  usable without the full plugin_base setup.
- move some Python-env requirements to the importable
  requirements.py module.
- allow starttime to be queried
- add additional events for engine plugins
- have "dialect" be a first-class parameter to the pool,
  ensure the engine strategy supplies it up front

Change-Id: Ibf549f7a1766e49d335cd6f5e26bacfaef9a8229

8 years ago- latest mysql 5.7 also crashing on XA recovery, disable
Mike Bayer [Fri, 16 Sep 2016 16:55:33 +0000 (12:55 -0400)] 
- latest mysql 5.7 also crashing on XA recovery, disable
XA recovery for all MySQL

Change-Id: I4f77de521cd80c09fdf97e5bbe5dfd1c830dc3cb

8 years agoRepair foreign_keys population for Join._refresh_for_new_column
Mike Bayer [Thu, 15 Sep 2016 04:50:17 +0000 (00:50 -0400)] 
Repair foreign_keys population for Join._refresh_for_new_column

Fixed bug where setting up a single-table inh subclass of a joined-table
subclass which included an extra column would corrupt the foreign keys
collection of the mapped table, thereby interfering with the
initialization of relationships.

Change-Id: I04a0cf98fd456d12d5a5b9e77a46a01246969a63
Fixes: #3797
8 years ago- placeholder for 1.0.16 within 1.0 changelog
Mike Bayer [Thu, 15 Sep 2016 04:51:31 +0000 (00:51 -0400)] 
- placeholder for 1.0.16 within 1.0 changelog

Change-Id: I33405513dc216ad33c5ec4796bff73f75d5866c4
(cherry picked from commit 4017b2696498a1cb4804a3be32b522b542d5af90)

8 years agoMerge branch 'keeyipchan/fix-typo-in-comment-1473614966363' of https://bitbucket...
Mike Bayer [Tue, 13 Sep 2016 13:52:02 +0000 (09:52 -0400)] 
Merge branch 'keeyipchan/fix-typo-in-comment-1473614966363' of https://bitbucket.org/keeyipchan/sqlalchemy

8 years ago- also caveats for update() / delete() regarding single
Mike Bayer [Mon, 12 Sep 2016 22:36:01 +0000 (18:36 -0400)] 
- also caveats for update() / delete() regarding single
table inheritance

Change-Id: If1511812a22a53537409f902f73e2e52ae3e4a3d
(cherry picked from commit 992344334328dba385fe6aa7694cfe3c13adc9d6)

8 years ago- add caveat for bulk deletes that they are generally not feasible
Mike Bayer [Mon, 12 Sep 2016 22:17:18 +0000 (18:17 -0400)] 
- add caveat for bulk deletes that they are generally not feasible
for joined inheritance

Change-Id: I043a5842401d586aa3ff96d05e06b443ff03fa60

8 years agoFix typo in comment
keeyip chan [Sun, 11 Sep 2016 17:29:29 +0000 (17:29 +0000)] 
Fix typo in comment

8 years agoMerge "Allow stringify compiler to render unnamed column"
mike bayer [Fri, 2 Sep 2016 16:23:31 +0000 (12:23 -0400)] 
Merge "Allow stringify compiler to render unnamed column"

8 years agoRepair clauselist comparison to account for clause ordering
Mike Bayer [Fri, 2 Sep 2016 15:27:58 +0000 (11:27 -0400)] 
Repair clauselist comparison to account for clause ordering

Fixed bug where the "simple many-to-one" condition that allows  lazy
loading to use get() from identity map would fail to be  invoked if the
primaryjoin of the relationship had multiple clauses separated by AND
which were not in the same order as that of the primary key columns
being compared in each clause. This ordering
difference occurs for a composite foreign key where the table-bound
columns on the referencing side were not in the same order in the .c
collection as the primary key columns on the referenced side....which
in turn occurs a lot if one is using declarative mixins and/or
declared_attr to set up columns.

Change-Id: I66cce74f614c04ed693dc0d58ac8c952b2f8ae54
Fixes: #3788
8 years agoAllow stringify compiler to render unnamed column
Mike Bayer [Fri, 2 Sep 2016 15:48:15 +0000 (11:48 -0400)] 
Allow stringify compiler to render unnamed column

Stringify of expression with unnamed :class:`.Column` objects, as
occurs in lots of situations including ORM error reporting,
will now render the name in string context as "<name unknown>"
rather than raising a compile error.

Change-Id: I76f637c5eb4cfdb1b526964cb001565b97e296da
Fixes: #3789
8 years ago- add 1.0.15 release date
Mike Bayer [Thu, 1 Sep 2016 17:20:31 +0000 (13:20 -0400)] 
- add 1.0.15 release date

Change-Id: I5d3f74c002f9d4593940ab4d68a3b35f3f227597

8 years agoSupport all MySQL/Connector int/bool arguments
Mike Bayer [Thu, 1 Sep 2016 13:34:33 +0000 (09:34 -0400)] 
Support all MySQL/Connector int/bool arguments

Added support for parsing MySQL/Connector boolean and integer
arguments within the URL query string: connection_timeout,
connect_timeout, pool_size, get_warnings,
raise_on_warnings, raw, consume_results, ssl_verify_cert, force_ipv6,
pool_reset_session, compress, allow_local_infile, use_pure.

Change-Id: I2a1a17d13d47d56871bff32e94fdbed8bc003ad7
Fixes: #3787
8 years agoCheck for supports_execution at ClauseElement base
Mike Bayer [Wed, 31 Aug 2016 18:34:54 +0000 (14:34 -0400)] 
Check for supports_execution at ClauseElement base

Raise a more descriptive exception / message when ClauseElement
or non-SQLAlchemy objects that are not "executable" are erroneously
passed to ``.execute()``; a new exception ObjectNotExecutableError
is raised consistently in all cases.

Change-Id: I2dd393121e2c7e5b6b9e40286a2f25670876e8e4
Fixes: #3786