Commit Graph

10240 Commits

Author SHA1 Message Date
Mike Bayer 525cc6fe02 - Fixed regression in the :mod:sqlalchemy.ext.mutable extension
as a result of the bugfix for 🎫`3167`,
where attribute and validation events are no longer
called within the flush process.  The mutable
extension was relying upon this behavior in the case where a column
level Python-side default were responsible for generating the new value
on INSERT or UPDATE, or when a value were fetched from the RETURNING
clause for "eager defaults" mode.  The new value would not be subject
to any event when populated and the mutable extension could not
establish proper coercion or history listening.  A new event
:meth:`.InstanceEvents.refresh_flush` is added which the mutable
extension now makes use of for this use case.
fixes #3427
- Added new event :meth:`.InstanceEvents.refresh_flush`, invoked
when an INSERT or UPDATE level default value fetched via RETURNING
or Python-side default is invoked within the flush process.  This
is to provide a hook that is no longer present as a result of
🎫`3167`, where attribute and validation events are no longer
called within the flush process.
- Added a new semi-public method to :class:`.MutableBase`
:meth:`.MutableBase._get_listen_keys`.  Overriding this method
is needed in the case where a :class:`.MutableBase` subclass needs
events to propagate for attribute keys other than the key to which
the mutable type is associated with, when intercepting the
:meth:`.InstanceEvents.refresh` or
:meth:`.InstanceEvents.refresh_flush` events.  The current example of
this is composites using :class:`.MutableComposite`.
2015-05-21 14:21:01 -04:00
Mike Bayer 164f2ad2f4 flake8 some tests 2015-05-21 13:43:37 -04:00
mike bayer cd8f25aa1a Merge pull request #173 from PierreRochard/patch-1
Correcting typo in introspection
2015-05-20 20:19:22 -04:00
Pierre Rochard 9434356da6 Correcting typo in introspection 2015-05-17 17:28:56 -04:00
Mike Bayer 5ca14954b8 - pg8000 wants to raise a ProgrammingError for a PK violation 2015-05-15 21:18:18 -04:00
Mike Bayer d178707eca - Added support for the case of the misbehaving DBAPI that has
pep-249 exception names linked to exception classes of an entirely
different name, preventing SQLAlchemy's own exception wrapping from
wrapping the error appropriately.
The SQLAlchemy dialect in use needs to implement a new
accessor :attr:`.DefaultDialect.dbapi_exception_translation_map`
to support this feature; this is implemented now for the py-postgresql
dialect.
fixes #3421
2015-05-15 12:38:28 -04:00
Mike Bayer 64c1f2e568 - The "lightweight named tuple" used when a :class:.Query returns
rows failed to implement ``__slots__`` correctly such that it still
had a ``__dict__``.    This is resolved, but in the extremely
unlikely case someone was assigning values to the returned tuples,
that will no longer work.
fixes #3420
2015-05-14 19:22:53 -04:00
Mike Bayer 4a0e51e7d2 - Fixed bug where in the case that a pool checkout event handler is used
and the database can no longer be connected towards, that the checkout
handler failure is caught, the attempt to re-acquire the connection
also raises an exception, but the underlying connection record
is not immediately re-checked in before the exception is propagated
outwards, having the effect that the checked-out record does not close
itself until the stack trace it's associated with is garbage collected,
preventing that record from being used for a new checkout until we
leave the scope of the stack trace.   This can lead to confusion
in the specific case of when the number of current stack traces
in memory exceeds the number of connections the pool can return,
as the pool will instead begin to raise errors about no more checkouts
available, rather than attempting a connection again.   The fix
applies a checkin of the record before re-raising.
fixes #3419
2015-05-14 13:59:04 -04:00
Mike Bayer eb1bb84fbc - Added official support for a CTE used by the SELECT present
inside of :meth:`.Insert.from_select`.  This behavior worked
accidentally up until 0.9.9, when it no longer worked due to
unrelated changes as part of 🎫`3248`.   Note that this
is the rendering of the WITH clause after the INSERT, before the
SELECT; the full functionality of CTEs rendered at the top
level of INSERT, UPDATE, DELETE is a new feature targeted for a
later release.
fixes #3418
2015-05-08 12:37:55 -04:00
Mike Bayer 5c897d9c6a - start 1.0.5 2015-05-08 12:18:07 -04:00
Mike Bayer 148924821b 1.0.4 rel_1_0_4 2015-05-07 20:51:09 -04:00
Mike Bayer 6d7901fa7d - plead with RTD to please please use the correct version 2015-05-07 16:19:08 -04:00
Mike Bayer ed73a95db6 RTD doesn't seem to want to refresh on a git tag so go back to using
release numbers

(cherry picked from commit 6b55842eef)
2015-05-07 16:06:11 -04:00
Mike Bayer 4f31db8210 - re-tag zzzeeksphinx w/ new version supporting sphinx 1.3 2015-05-07 13:47:38 -04:00
Mike Bayer ae4c2b6cbe - bump zs version due to not yet diagnosed error 2015-05-07 12:34:38 -04:00
Mike Bayer 633a61d978 - fix for py3k 2015-05-07 09:50:37 -04:00
Mike Bayer 1b12056390 - Fixed unexpected-use regression where in the odd case that the
primaryjoin of a relationship involved comparison to an unhashable
type such as an HSTORE, lazy loads would fail due to a hash-oriented
check on the statement parameters, modified in 1.0 as a result of
🎫`3061` to use hashing and modified in 🎫`3368`
to occur in cases more common than "load on pending".
The values are now checked for the ``__hash__`` attribute beforehand.
fixes #3416
2015-05-06 17:07:24 -04:00
Mike Bayer 5c85240921 - appease oracle's anger (no sequence defined for these PKs) 2015-05-05 17:01:13 -04:00
Mike Bayer be81cb200d - fix typo MANYTOONE -> MANYTOMANY, fixes #3415 2015-05-05 16:55:09 -04:00
Peter Hoffmann bcc8e6c02b Mark tests that they require OFFSET support in database
The sqlalchemy_exasol dialect needs to support Exasol 4.x which does not support 
the OFFSET feature. Mark test with testing.requires.offset so that they can be skipped
of in the exasol specific test suite.
2015-05-05 16:00:09 +02:00
Mike Bayer 8ac2bec029 - Liberalized an assertion that was added as part of 🎫3347
to protect against unknown conditions when splicing inner joins
together within joined eager loads with ``innerjoin=True``; if
some of the joins use a "secondary" table, the assertion needs to
unwrap further joins in order to pass.
fixes #3412
2015-05-02 11:33:54 -04:00
Mike Bayer 77db0ef6ac - Fixed bug in enhanced constraint-attachment logic introduced in
🎫`3341` where in the unusual case of a constraint that refers
to a mixture of :class:`.Column` objects and string column names
at the same time, the auto-attach-on-column-attach logic will be
skipped; for the constraint to be auto-attached in this case,
all columns must be assembled on the target table up front.
Added a new section to the migration document regarding the
original feature as well as this change.
fixes #3411
2015-05-02 10:27:03 -04:00
Mike Bayer b2196dd953 - start qualifying some regressions as "unexpected use"
regressions; regressions where we didn't know an API even worked
in a particular way or that anyone were using it in such a way
hence had no tests for such case.
2015-05-02 10:08:11 -04:00
Mike Bayer 5d8a608722 - update 3.4 callcounts 2015-05-01 17:59:11 -04:00
Mike Bayer 2ef1c56436 - move away from explicit raises of SkipTest, instead call a
function patched onto config.  nose/pytest backends now fill
in their exception class here only when loaded
- use more public seeming api to get at py.test Skipped
exception
2015-05-01 13:15:51 -04:00
Mike Bayer 95949db715 - Repair _reinstall_default_lookups to also flip the _extended flag
off again so that test fixtures setup/teardown instrumentation as
expected
- clean up test_extendedattr.py and fix it to no longer leak
itself outside by ensuring _reinstall_default_lookups is always called,
part of #3408
- Fixed bug where when using extended attribute instrumentation system,
the correct exception would not be raised when :func:`.class_mapper`
were called with an invalid input that also happened to not
be weak referencable, such as an integer.
fixes #3408
2015-05-01 12:33:45 -04:00
Mike Bayer 635f06c3eb - turn sessions in ResultTest to autocommit=True just to get them
to clean up automatically.  references #3407
2015-05-01 10:00:23 -04:00
Mike Bayer 088666e8f3 - Fixed an import that prevented "pypy setup.py test" from working
correctly.
fixes #3406
2015-05-01 09:38:21 -04:00
Mike Bayer 24d6ea362e - Repaired / added to tests yet more expressions that were reported
as failing with the new 'entity' key value added to
:attr:`.Query.column_descriptions`, the logic to discover the "from"
clause is again reworked to accommodate columns from aliased classes,
as well as to report the correct value for the "aliased" flag in these
cases.
fixes #3409
2015-05-01 09:20:10 -04:00
Mike Bayer 3cfda0a3c9 1.0.3 rel_1_0_3 2015-04-30 21:33:26 -04:00
Mike Bayer 681276b5b4 - Fixed regression from 0.9.10 prior to release due to 🎫3349
where the check for query state on :meth:`.Query.update` or
:meth:`.Query.delete` compared the empty tuple to itself using ``is``,
which fails on Pypy to produce ``True`` in this case; this would
erronously emit a warning in 0.9 and raise an exception in 1.0.
fixes #3405
2015-04-30 21:26:48 -04:00
Mike Bayer 4992aafecc - revise the last commit with a more traditional approach
using descriptors; ensure that mock.patch() honors descriptor setters
2015-04-30 20:20:02 -04:00
Mike Bayer e0f9b279f4 - work the wrapping of the "creator" to be as resilient to
old / new style, direct access, and ad-hoc patching and
unpatching as possible
2015-04-30 19:55:28 -04:00
Mike Bayer 0e98795ff2 - New features added to support engine/pool plugins with advanced
functionality.   Added a new "soft invalidate" feature to the
connection pool at the level of the checked out connection wrapper
as well as the :class:`._ConnectionRecord`.  This works similarly
to a modern pool invalidation in that connections aren't actively
closed, but are recycled only on next checkout; this is essentially
a per-connection version of that feature.  A new event
:class:`.PoolEvents.soft_invalidate` is added to complement it.
fixes #3379

- Added new flag
:attr:`.ExceptionContext.invalidate_pool_on_disconnect`.
Allows an error handler within :meth:`.ConnectionEvents.handle_error`
to maintain a "disconnect" condition, but to handle calling invalidate
on individual connections in a specific manner within the event.

- Added new event :class:`.DialectEvents.do_connect`, which allows
interception / replacement of when the :meth:`.Dialect.connect`
hook is called to create a DBAPI connection.  Also added
dialect plugin hooks :meth:`.Dialect.get_dialect_cls` and
:meth:`.Dialect.engine_created` which allow external plugins to
add events to existing dialects using entry points.
fixes #3355
2015-04-30 17:51:14 -04:00
Mike Bayer 20e3df6028 - Fixed regression from as yet unreleased 0.9.10 where the new addition
of ``entity`` to the :attr:`.Query.column_descriptions` accessor
would fail if the target entity was produced from a core selectable
such as a :class:`.Table` or :class:`.CTE` object.
fixes #3403  references #3320
2015-04-30 12:53:27 -04:00
Mike Bayer 606a9b02e5 - Added a placeholder method :meth:.TypeEngine.compare_against_backend
which is now consumed by Alembic migrations as of 0.7.6.  User-defined
types can implement this method to assist in the comparison of
a type against one reflected from the database.
2015-04-30 11:38:24 -04:00
Mike Bayer b0be9211c9 - Fixed regression within the flush process when an attribute were
set to a SQL expression for an UPDATE, and the SQL expression when
compared to the previous value of the attribute would produce a SQL
comparison other than ``==`` or ``!=``, the exception "Boolean value
of this clause is not defined" would raise.   The fix ensures that
the unit of work will not interpret the SQL expression in this way.
fixes #3402
2015-04-29 14:00:16 -04:00
Mike Bayer 93b5eae984 - add boldface for "viable" plus a note describing that this
refers to the table having a primary key.  fixes #3398
2015-04-29 00:05:25 -04:00
Mike Bayer 4f6e9ccae9 - Fixed bug in association proxy where an any()/has()
on an relationship->scalar non-object attribute comparison would fail,
e.g.
``filter(Parent.some_collection_to_attribute.any(Child.attr == 'foo'))``
fixes #3397
2015-04-28 19:20:01 -04:00
Mike Bayer ac52239b32 - Fixed bug where the truncation of long labels in SQL could produce
a label that overlapped another label that is not truncated; this
because the length threshhold for truncation was greater than
the portion of the label that remains after truncation.  These
two values have now been made the same; label_length - 6.
The effect here is that shorter column labels will be "truncated"
where they would not have been truncated before.
fixes #3396
2015-04-28 16:02:59 -04:00
mike bayer 0783cb9337 Merge pull request #170 from eronisko/fix_typo
Fix typo in 'Relationships API' docs
2015-04-28 10:10:40 -04:00
Ernest Walzel da327d0349 Fix typo in 'Relationships API' docs
exprssed -> expressed
2015-04-28 12:27:00 +01:00
Mike Bayer 34f98a63b5 - altered part of the use contract first set up in #2992; we
now skip textual label references when copying ORDER BY elements
to the joined-eager-load subquery, as we can't know that these
expressions are compatible with this placement;  either because
they are meant for text(), or because they refer to label names
already stated and aren't bound to a table. fixes #3392
2015-04-27 17:40:41 -04:00
Mike Bayer e5c20fce93 - replace old crufty ddl event test fixture with mock 2015-04-27 15:21:18 -04:00
Mike Bayer e25ef01fbb - Fixed regression due to 🎫3282 where the `tables` collection
passed as a keyword argument to the :meth:`.DDLEvents.before_create`,
:meth:`.DDLEvents.after_create`, :meth:`.DDLEvents.before_drop`, and
:meth:`.DDLEvents.after_drop` events would no longer be a list
of tables, but instead a list of tuples which contained a second
entry with foreign keys to be added or dropped.  As the ``tables``
collection, while documented as not necessarily stable, has come
to be relied upon, this change is considered a regression.
Additionally, in some cases for "drop", this collection would
be an iterator that would cause the operation to fail if
prematurely iterated.   The collection is now a list of table
objects in all cases and test coverage for the format of this
collection is now added.
fixes #3391
2015-04-27 15:05:41 -04:00
Mike Bayer 6c0f30db81 - Fixed a regression regarding the :meth:.MapperEvents.instrument_class
event where its invocation was moved to be after the class manager's
instrumentation of the class, which is the opposite of what the
documentation for the event explicitly states.  The rationale for the
switch was due to Declarative taking the step of setting up
the full "instrumentation manager" for a class before it was mapped
for the purpose of the new ``@declared_attr`` features
described in :ref:`feature_3150`, but the change was also made
against the classical use of :func:`.mapper` for consistency.
However, SQLSoup relies upon the instrumentation event happening
before any instrumentation under classical mapping.
The behavior is reverted in the case of classical and declarative
mapping, the latter implemented by using a simple memoization
without using class manager.
fixes #3388
2015-04-26 18:22:41 -04:00
Mike Bayer d48acff23b - Fixed issue in new :meth:.QueryEvents.before_compile event where
changes made to the :class:`.Query` object's collection of entities
to load within the event would render in the SQL, but would not
be reflected during the loading process.
fixes #3387
2015-04-26 12:33:17 -04:00
Mike Bayer 6833669469 - try pinning a tag here to for RTD to please build correctly 2015-04-25 10:48:54 -04:00
Mike Bayer 42c9fe1d1d 1.0.2 rel_1_0_2 2015-04-24 18:03:01 -04:00
Mike Bayer 723e07a374 - reword the notes here 2015-04-24 18:02:57 -04:00