Commit Graph

137 Commits

Author SHA1 Message Date
Mike Bayer dddb74bbd3 - control the module name of the exception here for py3k compat 2014-10-19 13:37:48 -04:00
Mike Bayer 6f40eb37cb - Exception messages have been spiffed up a bit. The SQL statement
and parameters are not displayed if None, reducing confusion for
error messages that weren't related to a statement.  The full
module and classname for the DBAPI-level exception is displayed,
making it clear that this is a wrapped DBAPI exception.  The
statement and parameters themselves are bounded within a bracketed
sections to better isolate them from the error message and from
each other.
fixes #3172
2014-10-17 19:37:45 -04:00
Mike Bayer 2885f78e4e - adjustment for ref #3200 as we need an immutabledict() here so
that union() can be called, in the case of a dialect that uses
execution options inside of initialize() (e.g. oursql)
2014-10-07 12:43:27 -04:00
Mike Bayer 119674dd25 - The execution options passed to an :class:.Engine either via
:paramref:`.create_engine.execution_options` or
:meth:`.Engine.update_execution_options` are not passed to the
special :class:`.Connection` used to initialize the dialect
within the "first connect" event; dialects will usually
perform their own queries in this phase, and none of the
current available  options should be applied here.  In
particular, the "autocommit" option was causing an attempt to
autocommit within this initial connect which would fail with
an AttributeError due to the non-standard state of the
:class:`.Connection`.
fixes #3200
2014-10-06 18:23:42 -04:00
Mike Bayer b89523f0b7 - Fixed bug where a "branched" connection, that is the kind you get
when you call :meth:`.Connection.connect`, would not share transaction
status with the parent.  The architecture of branching has been tweaked
a bit so that the branched connection defers to the parent for
all transactional status and operations.
fixes #3190
2014-09-26 16:25:26 -04:00
Mike Bayer b36cdefba2 - Fixed bug that affected generally the same classes of event
as that of 🎫`3199`, when the ``named=True`` parameter
would be used.  Some events would fail to register, and others
would not invoke the event arguments correctly, generally in the
case of when an event was "wrapped" for adaption in some other way.
The "named" mechanics have been rearranged to not interfere with
the argument signature expected by internal wrapper functions.
fixes #3197
2014-09-18 17:49:07 -04:00
Mike Bayer cea97d1fae - pep8 cleanup 2014-08-20 09:08:59 -04:00
Mike Bayer 6a21f9e328 - The string keys that are used to determine the columns impacted
for an INSERT or UPDATE are now sorted when they contribute towards
the "compiled cache" cache key.   These keys were previously not
deterministically ordered, meaning the same statement could be
cached multiple times on equivalent keys, costing both in terms of
memory as well as performance.
fixes #3165
2014-08-14 20:00:35 -04:00
Mike Bayer 5a86dba402 - workaround removal of nested() in py3k 2014-07-30 12:50:38 -04:00
Mike Bayer e5620993bf pep8 cleanup 2014-07-29 14:17:29 -04:00
Mike Bayer 83326bf44c - The exception wrapping system for DBAPI errors can now accommodate
non-standard DBAPI exceptions, such as the psycopg2
TransactionRollbackError.  These exceptions will now be raised
using the closest available subclass in ``sqlalchemy.exc``, in the
case of TransactionRollbackError, ``sqlalchemy.exc.OperationalError``.
fixes #3075
2014-07-29 14:06:43 -04:00
Mike Bayer 82965851fe fix paren here 2014-07-26 20:53:12 -04:00
Mike Bayer 6b60d3a9e6 - The MySQL dialect will now disable :meth:.ConnectionEvents.handle_error
events from firing for those statements which it uses internally
to detect if a table exists or not.   This is achieved using an
execution option ``skip_user_error_events`` that disables the handle
error event for the scope of that execution.   In this way, user code
that rewrites exceptions doesn't need to worry about the MySQL
dialect or other dialects that occasionally need to catch
SQLAlchemy specific exceptions.
2014-07-25 12:14:22 -04:00
Mike Bayer 9b03d6a0a8 - add test support for disconnect modification 2014-07-04 16:49:11 -04:00
Mike Bayer dfb5707dae - rework the entire approach to #3076. As we need to catch all exceptions
in all cases unconditionally, the number of use cases that go beyond what
dbapi_error() is expecting has gone too far for an 0.9 release.
Additionally, the number of things we'd like to track is really a lot
more than the five arguments here, and ExecutionContext is really not
suitable as totally public API for this.   So restore dbapi_error
to its old version, deprecate, and build out handle_error instead.
This is a lot more extensible and doesn't get in the way of anything
compatibility-wise.
2014-07-04 15:40:47 -04:00
Mike Bayer e0a9b94abb - The mechanics of the :meth:.ConnectionEvents.dbapi_error handler
have been enhanced such that the function handler is now capable
of raising or returning a new exception object, which will replace
the exception normally being thrown by SQLAlchemy.
fixes #3076
2014-07-03 17:30:49 -04:00
Alex Gaynor 1caa7fafbd Fix many typos throughout the codebase
Found using: https://github.com/intgr/topy
2014-04-26 13:13:13 -07:00
Mike Bayer a04fb82028 pickle of execption not supported on mysqlconnector 2014-03-28 16:37:43 -04:00
Mike Bayer 74f7509d66 add some more mock structure so tricky DBAPIs like pypy work 2014-03-24 19:30:44 -04:00
Mike Bayer 50d19f55d2 - add some more rules to make sure all tests run if DBs are available 2014-03-24 12:49:22 -04:00
Mike Bayer 2f150bee28 - rename __multiple__ to __backend__, and apply __backend__ to a large number of tests.
- move out logging tests from test_execute to test_logging
2014-03-24 11:33:53 -04:00
Mike Bayer 87d7076b49 - Added some new event mechanics for dialect-level events; the initial
implementation allows an event handler to redefine the specific mechanics
by which an arbitrary dialect invokes execute() or executemany() on a
DBAPI cursor.  The new events, at this point semi-public and experimental,
are in support of some upcoming transaction-related extensions.
2014-03-24 10:22:39 -04:00
Mike Bayer b00e15b50f - An event listener can now be associated with a :class:.Engine,
after one or more :class:`.Connection` objects have been created
(such as by an orm :class:`.Session` or via explicit connect)
and the listener will pick up events from those connections.
Previously, performance concerns pushed the event transfer from
:class:`.Engine` to  :class:`.Connection` at init-time only, but
we've inlined a bunch of conditional checks to make this possible
without any additional function calls. fixes #2978
2014-03-22 19:34:18 -04:00
Mike Bayer a7a6b43660 there's no "assert_call_count" on mock 2014-03-22 19:10:00 -04:00
Mike Bayer 8e10ab92df - restore the old behavior of the connection pool replacing itself just
within userland engine.dispose(); as some SQLA tests already failed when the replace step
was removed, due to those conns still being referenced, it's likely this will
create surprises for all those users that incorrectly use dispose()
and it's not really worth dealing with.  This doesn't affect the change
we made for ref: #2985.
2014-03-22 19:02:37 -04:00
Mike Bayer 2a1a79b6ce - The :meth:.ConnectionEvents.after_cursor_execute event is now
emitted for the "_cursor_execute()" method of :class:`.Connection`;
this is the "quick" executor that is used for things like
when a sequence is executed ahead of an INSERT statement, as well as
for dialect startup checks like unicode returns, charset, etc.
the :meth:`.ConnectionEvents.before_cursor_execute` event was already
invoked here.  The "executemany" flag is now always set to False
here, as this event always corresponds to a single execution.
Previously the flag could be True if we were acting on behalf of
an executemany INSERT statement.
2014-03-19 13:03:44 -04:00
Mike Bayer 1536bc4664 - The MySQL CAST compilation now takes into account aspects of a string
type such as "charset" and "collation".  While MySQL wants all character-
based CAST calls to use the CHAR type, we now create a real CHAR
object at CAST time and copy over all the parameters it has, so that
an expression like ``cast(x, mysql.TEXT(charset='utf8'))`` will
render ``CAST(t.col AS CHAR CHARACTER SET utf8)``.

- Added new "unicode returns" detection to the MySQL dialect and
to the default dialect system overall, such that any dialect
can add extra "tests" to the on-first-connect "does this DBAPI
return unicode directly?" detection. In this case, we are
adding a check specifically against the "utf8" encoding with
an explicit "utf8_bin" collation type (after checking that
this collation is available) to test for some buggy unicode
behavior observed with MySQLdb version 1.2.3.  While MySQLdb
has resolved this issue as of 1.2.4, the check here should
guard against regressions.  The change also allows the "unicode"
checks to log in the engine logs, which was not previously
the case. [ticket:2906]
2014-01-13 14:05:05 -05:00
Mike Bayer 232e3762b7 revert r2775c95b1ee30831216cc5 which was mostly an inadvertent commit, except for the changelog part 2014-01-13 10:37:15 -05:00
Mike Bayer 2775c95b1e new changelog 2014-01-11 13:12:40 -05:00
Mike Bayer fa5970c265 - these tests are really old but trying to make sure everything is closed out 2014-01-05 18:25:51 -05:00
Mike Bayer 6d5eae78a7 - A DBAPI that raises an error on `connect()` which is not a subclass
of dbapi.Error (such as ``TypeError``, ``NotImplementedError``, etc.)
will propagate the exception unchanged.  Previously,
the error handling specific to the ``connect()`` routine would both
inappropriately run the exception through the dialect's
:meth:`.Dialect.is_disconnect` routine as well as wrap it in
a :class:`sqlalchemy.exc.DBAPIError`.  It is now propagated unchanged
in the same way as occurs within the execute process. [ticket:2881]
- add tests for this in test_parseconnect, but also add tests in test_execute
to ensure the execute() behavior as well
2013-12-07 17:20:05 -05:00
Mike Bayer 54b8969be1 -be more agnostic of quotes here 2013-11-23 17:22:56 -05:00
Mike Bayer f112dc1d53 - Fixed bug where SQL statement would be improperly ASCII-encoded
when a pre-DBAPI :class:`.StatementError` were raised within
:meth:`.Connection.execute`, causing encoding errors for
non-ASCII statements.  The stringification now remains within
Python unicode thus avoiding encoding errors. [ticket:2871]
2013-11-22 18:35:36 -05:00
Mike Bayer 59ca4633ac - remove informix dialect, moved out to https://bitbucket.org/zzzeek/sqlalchemy_informixdb
- remove informix, maxdb, access symbols from tests etc.
2013-11-17 13:45:23 -05:00
Mike Bayer 08a6a8b519 - Removed some now unneeded version checks [ticket:2829] courtesy alex gaynor 2013-09-22 20:35:40 -04:00
Mike Bayer e9c748a7bf - ensure rowcount is returned for an UPDATE with no implicit returning
- modernize test for that
- use py3k compatible next() in test_returning/test_versioning
2013-08-25 17:37:59 -04:00
Mike Bayer d3d10c982c - refactor pool a bit so that intent between ConnectionRecord/ConnectionFairy is clear;
make sure that the DBAPI connection passed to the reset-on-return events/dialect hooks
is also a "fairy", so that dictionaries like "info" are available.  [ticket:2770]
- rework the execution_options system so that the dialect is given the job of making
any immediate adjustments based on a set event.  move the "isolation level" logic to use
this new system.   Also work things out so that even engine-level execution options
can be used for things like isolation level; the dialect attaches a connect-event
handler in this case to handle the task.
- to support this new system as well as further extensibiltiy of execution options
add events engine_connect(), set_connection_execution_options(), set_engine_execution_options()
2013-07-02 13:14:21 -04:00
Mike Bayer b38a76cd1d - replace most explicitly-named test objects called "Mock..." with
actual mock objects from the mock library.  I'd like to use mock
for new tests so we might as well use it in obvious places.
- use unittest.mock in py3.3
- changelog
- add a note to README.unittests
- add tests_require in setup.py
- have tests import from sqlalchemy.testing.mock
- apply usage of mock to one of the event tests.  we can be using
this approach all over the place.
2013-06-30 18:35:12 -04:00
Mike Bayer 4276049e49 fix test_execute w c extensions 2013-05-26 20:44:34 -04:00
Mike Bayer 920e134d53 test_execute up for sqlite, pg, oursql, mysql 2.7 + 3.3 2013-05-04 15:29:04 -04:00
Mike Bayer 4b614b9b35 - the raw 2to3 run
- went through examples/ and cleaned out excess list() calls
2013-04-27 19:53:57 -04:00
Mike Bayer a98bb5f0cd Merged in nakagami/sqlalchemy/cymysql (pull request #42)
cymysql support
2013-03-07 12:36:35 -05:00
Mike Bayer 133e8fd388 - Fixed an import of "logging" in test_execute which was not
working on some linux platforms.  Also in 0.7.11.
- only need "logging.handlers" here, "logging" comes in implicitly
2013-03-02 16:20:49 -05:00
Mike Gilbert 05eb72d431 test_execute: import logging.handlers to fix AttributeError
See also: https://bugs.gentoo.org/show_bug.cgi?id=458684
2013-02-27 15:01:37 -05:00
Hajime Nakagami 60028c3607 test for cymysql 2013-02-17 15:07:19 +09:00
Mike Bayer bac14cdf47 Added a new method :meth:.Engine.execution_options
to :class:`.Engine`.  This method works similarly to
      :class:`.Connection.execution_options` in that it creates
      a copy of the parent object which will refer to the new
      set of options.   The method can be used to build
      sharding schemes where each engine shares the same
      underlying pool of connections.   The method
      has been tested against the horizontal shard
      recipe in the ORM as well.
2012-10-23 12:08:20 -04:00
Mike Bayer 20cdc64588 trying different approaches to test layout. in this one, the testing modules
become an externally usable package but still remains within the main sqlalchemy parent package.
in this system, we use kind of an ugly hack to get the noseplugin imported outside of the
"sqlalchemy" package, while still making it available within sqlalchemy for usage by
third party libraries.
2012-09-27 02:37:33 -04:00
Mike Bayer 444abbe847 - got firebird running
- add some failure cases
- [bug] Firebird now uses strict "ansi bind rules"
so that bound parameters don't render in the
columns clause of a statement - they render
literally instead.

- [bug] Support for passing datetime as date when
using the DateTime type with Firebird; other
dialects support this.
2012-09-23 18:09:18 -04:00
Mike Bayer 7e815c67a9 finished fixes for mxodbc; need to use at least version 3.2.1 2012-09-21 17:43:22 -04:00
Mike Bayer 626ae5b7a1 - fixes for mxODBC, some pyodbc
- enhancements to test suite including ability to set up a testing engine
for a whole test class, fixes to how noseplugin sets up/tears
down per-class context
2012-09-02 15:14:09 -04:00