Commit Graph

542 Commits

Author SHA1 Message Date
Mike Bayer 49f1807f8f - simplify the mechanics of PrimaryKeyConstraint with regards to reflection;
reflection now updates the PKC in place.
- support the use case of the empty PrimaryKeyConstraint in order to specify
constraint options; the columns marked as primary_key=True will now be gathered
into the columns collection, rather than being ignored. [ticket:2910]
- add validation such that column specification should only take place
in the PrimaryKeyConstraint directly, or by using primary_key=True flags;
if both are present, they have to match exactly, otherwise the condition is
assumed to be ambiguous, and a warning is emitted; the old behavior of
using the PKC columns only is maintained.
2014-01-20 18:06:18 -05: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 bebf30e34d - continue with [ticket:2907] and further clean up how we set up
_reset_agent, so that it's local to the various begin_impl(),
rollback_impl(), etc.  this allows setting/resetting of the flag
to be symmetric.
- don't set _reset_agent if it's not None, don't unset it if it isn't
our own transaction.
- make sure we clean it out in close().
- basically, we're dealing here with pools using "threadlocal" that have a
counter, other various mismatches that the tests bring up
- test for recover() now has to invalidate() the previous connection,
because closing it actually rolls it back (e.g. this test was relying
on the broken behavior).
2014-01-13 03:22:11 -05:00
Mike Bayer 9c64607572 - :class:.Connection now associates a new
:class:`.RootTransaction` or :class:`.TwoPhaseTransaction`
with its immediate :class:`._ConnectionFairy` as a "reset handler"
for the span of that transaction, which takes over the task
of calling commit() or rollback() for the "reset on return" behavior
of :class:`.Pool` if the transaction was not otherwise completed.
This resolves the issue that a picky transaction
like that of MySQL two-phase will be
properly closed out when the connection is closed without an
explicit rollback or commit (e.g. no longer raises "XAER_RMFAIL"
in this case - note this only shows up in logging as the exception
is not propagated within pool reset).
This issue would arise e.g. when using an orm
:class:`.Session` with ``twophase`` set, and then
:meth:`.Session.close` is called without an explicit rollback or
commit.   The change also has the effect that you will now see
an explicit "ROLLBACK" in the logs when using a :class:`.Session`
object in non-autocommit mode regardless of how that session was
discarded.  Thanks to Jeff Dairiki and Laurence Rowe for isolating
the issue here. [ticket:2907]
2014-01-12 19:43:13 -05:00
Mike Bayer c91fd822bc - add new event PoolEvents.invalidate(). allows interception of invalidation
events including auto-invalidation, which is useful both for tests here as well as
detecting failure conditions within the "reset" or "close" cases.
- rename the argument for PoolEvents.reset() to dbapi_connection and connection_record
to be consistent with everything else.
- add new documentation sections on invalidation, including auto-invalidation
and the invalidation process within the pool.
- add _ConnectionFairy and _ConnectionRecord to the pool documentation.  Establish
docs for common _ConnectionFairy/_ConnectionRecord methods and accessors and
have PoolEvents docs refer to _ConnectionRecord,
since it is passed to all events.  Rename a few _ConnectionFairy methods that are actually
private to pool such as _checkout(), _checkin() and _checkout_existing(); there should not
be any external code calling these
2014-01-12 17:34:20 -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 ecb3865615 - The :paramref:.Table.extend_existing and :paramref:.Table.autoload_replace
parameters are now available on the :meth:`.MetaData.reflect`
method.
- starting to use paramref and need newer paramlinks version.
2014-01-04 21:12:31 -05:00
Mike Bayer 49d8026987 - The :func:.engine_from_config function has been improved so that
we will be able to parse dialect-specific arguments from string
configuration dictionaries.  Dialect classes can now provide their
own list of parameter types and string-conversion routines.
The feature is not yet used by the built-in dialects, however.
[ticket:2875]
2013-12-07 18:38:15 -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 d1cc78479d - The :class:.QueuePool has been enhanced to not block new connection
attempts when an existing connection attempt is blocking.  Previously,
the production of new connections was serialized within the block
that monitored overflow; the overflow counter is now altered within
it's own critical section outside of the connection process itself.
[ticket:2880]
2013-12-06 19:57:19 -05:00
Mike Bayer 003b288b76 - Made a slight adjustment to the logic which waits for a pooled
connection to be available, such that for a connection pool
with no timeout specified, it will every half a second break out of
the wait to check for the so-called "abort" flag, which allows the
waiter to break out in case the whole connection pool was dumped;
normally the waiter should break out due to a notify_all() but it's
possible this notify_all() is missed in very slim cases.
This is an extension of logic first introduced in 0.8.0, and the
issue has only been observed occasionally in stress tests.
2013-12-06 16:33:42 -05:00
Mike Bayer 604df86190 make sure thread.join() is used completely here 2013-11-30 16:54:44 -05:00
Mike Bayer 6029496bd3 - adjustment, the spec says: "Within the user and password field, any ":",
"@", or "/" must be encoded." - so re-apply encoding to both password
and username, don't encode spaces as plus signs, don't encode any chars
outside of :, @, / on stringification - but we still parse for any
%XX character (is that right?)
2013-11-25 14:46:58 -05:00
Mike Bayer 2800e34710 - The :func:.create_engine routine and the related
:func:`.make_url` function **no longer URL encode the password**.
Database passwords that include characters like spaces, plus signs
and anything else should now represent these characters directly,
without any URL escaping. [ticket:2873]
2013-11-24 18:11:37 -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 fcbaf666a9 something changed the name here, probably one of those doc pullreqs 2013-11-21 17:24:51 -05:00
Mike Bayer 1a809b300e - apply a timeout to all join() calls for test_pool
- use thread.join() for waiters_handled test
2013-11-17 14:35:11 -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 46ac022e57 - move this test to PG test_reflection
- don't use locals()
2013-10-25 17:19:03 -04:00
Mike Bayer e5a42a748b Merge branch 'master' of github.com:ijl/sqlalchemy into merge_2183 2013-10-25 17:01:38 -04:00
Mike Bayer 382cd56772 - The regexp used by the :func:.url.make_url function now parses
ipv6 addresses, e.g. surrounded by brackets. [ticket:2851]
2013-10-23 15:02:36 -04:00
Mike Bayer cdc9475b0b try to get this to pass on slow environmnets 2013-10-21 23:17:36 -04:00
ijl f17e8a4452 ForeignKeyConstraint reflection test respects MySQL limitations 2013-10-15 16:01:25 -04:00
ijl 52cfa74e09 #2183: Metadata.reflect() foreign keys include options when the dialect exposes it 2013-10-13 17:13:28 -04:00
mike bayer dda72ddcf0 Merge pull request #25 from gthb/ticket_2821
Hide password in URL and Engine __repr__
2013-09-29 14:03:46 -07:00
Mike Bayer 08a6a8b519 - Removed some now unneeded version checks [ticket:2829] courtesy alex gaynor 2013-09-22 20:35:40 -04:00
Gunnlaugur Þór Briem 610684bb08 Hide password in URL and Engine __repr__
Fixes #2821
2013-09-06 17:57:04 +00:00
Mike Bayer 21fac20884 use a different col here to keep oracle happy 2013-09-02 12:11:24 -04:00
Mike Bayer 97168dbf69 plus some more adjustments for mysql, or in general if an Index refers to
in-python only cols
2013-08-28 17:31:40 -04:00
Mike Bayer fe66951f5d Fixed bug where using the `column_reflect event to change the .key`
of the incoming :class:`.Column` would prevent primary key constraints,
indexes, and foreign key constraints from being correctly reflected.
Also in 0.8.3. [ticket:2811]
2013-08-28 17:25:44 -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 b83a1564f1 Improved support for the cymysql driver, supporting version 0.6.5,
courtesy Hajime Nakagami.
2013-08-17 00:31:57 -04:00
Mike Bayer f6198d9abf - A large refactoring of the `sqlalchemy.sql` package has reorganized
the import structure of many core modules.
``sqlalchemy.schema`` and ``sqlalchemy.types``
remain in the top-level package, but are now just lists of names
that pull from within ``sqlalchemy.sql``.  Their implementations
are now broken out among ``sqlalchemy.sql.type_api``, ``sqlalchemy.sql.sqltypes``,
``sqlalchemy.sql.schema`` and ``sqlalchemy.sql.ddl``, the last of which was
moved from ``sqlalchemy.engine``.  ``sqlalchemy.sql.expression`` is also
a namespace now which pulls implementations mostly from ``sqlalchemy.sql.elements``,
``sqlalchemy.sql.selectable``, and ``sqlalchemy.sql.dml``.
Most of the "factory" functions
used to create SQL expression objects have been moved to classmethods
or constructors, which are exposed in ``sqlalchemy.sql.expression``
using a programmatic system.  Care has been taken such that all the
original import namespaces remain intact and there should be no impact
on any existing applications.   The rationale here was to break out these
very large modules into smaller ones, provide more manageable lists
of function names, to greatly reduce "import cycles" and clarify the
up-front importing of names, and to remove the need for redundant
functions and documentation throughout the expression package.
2013-08-12 17:50:37 -04:00
Mike Bayer 59675be673 try seeing if just clearing this ahead of time helps 2013-07-27 18:32:38 -04:00
Mike Bayer 5dbe771922 further tweaking 2013-07-13 16:41:16 -04:00
Mike Bayer c896c75971 fix the scoping here 2013-07-13 16:37:10 -04:00
Mike Bayer fd55be01dd Dialect.initialize() is not called a second time if an :class:.Engine
is recreated, due to a disconnect error.   This fixes a particular
issue in the Oracle 8 dialect, but in general the dialect.initialize()
phase should only be once per dialect.  Also in 0.8.3. [ticket:2776]
2013-07-11 15:15:09 -04:00
Mike Bayer f390639bf1 Fixed bug where :class:.QueuePool would lose the correct
checked out count if an existing pooled connection failed to reconnect
after an invalidate or recycle event.  Also in 0.8.3.
[ticket:2772]
2013-07-04 13:18:00 -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 38c5e870a7 mark the tests that seem to be segfauling py3k+coverage so that we can exclude them
at the nose command line
2013-06-30 23:55:32 -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 278c243aa3 tweak the timings here to maximize chance of test success 2013-06-29 11:17:32 -04:00
Eevee 23ce1d8b12 Preserve reset_on_return when recreating a Pool. 2013-06-10 15:04:39 -07:00
Mike Bayer 258d2a8315 - get_unique_constraints() pull request
- version (0.9 for now)
- changelog
- move the test into the test suite so that all dialects can take advantage of it
2013-06-09 17:54:11 -04:00
Roman Podolyaka c69fe4acf8 Add basic support of unique constraints reflection
Inspection API already supports reflection of table
indexes information and those also include unique
constraints (at least for PostgreSQL and MySQL).
But it could be actually useful to distinguish between
indexes and plain unique constraints (though both are
implemented in the same way internally in RDBMS).

This change adds a new method to Inspection API - get_unique_constraints()
and implements it for SQLite, PostgreSQL and MySQL dialects.
2013-06-09 23:49:55 +03:00
Mike Bayer f1bdc3e999 - clean up some of the requires for cross-schema reflection
- add oracle profile counts
2013-06-03 18:11:32 -04:00
Mike Bayer ec04620f1f Fixed bug whereby using :meth:.MetaData.reflect across a remote
schema as well as a local schema could produce wrong results
in the case where both schemas had a table of the same name.
[ticket:2728]
2013-06-03 16:40:59 -04:00