summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine
Commit message (Collapse)AuthorAgeFilesLines
* - The "auto close" for :class:`.ResultProxy` is now a "soft" close.Mike Bayer2015-03-173-40/+143
| | | | | | | | | | | That is, after exhausing all rows using the fetch methods, the DBAPI cursor is released as before and the object may be safely discarded, but the fetch methods may continue to be called for which they will return an end-of-result object (None for fetchone, empty list for fetchmany and fetchall). Only if :meth:`.ResultProxy.close` is called explicitly will these methods raise the "result is closed" error. fixes #3330 fixes #3329
* - copyright 2015Mike Bayer2015-03-1010-10/+10
|
* - fix a potential race condition where the per-mapper LRUCache used byMike Bayer2015-03-091-3/+2
| | | | | | | | | | | | | persistence.py could theoretically hit the limit of the cache (100 items by default) and at some points fail to have a key that we check for, due to the cleanup. This has never been observed so its likely that so far, the total number of INSERT, UPDATE and DELETE statement structures in real apps has not exceeded 100 on a per-mapper basis; this could happen for apps that run a very wide variety of attribute modified combinations into the unit of work, *and* which have very high concurrency going on. This change will be a lot more significant when we open up use of LRUCache + compiled cache with the baked query extension.
* fooMike Bayer2015-03-082-20/+31
|
* - the change for #918 was of course not nearly that simple.Mike Bayer2015-03-071-1/+1
| | | | | | | | | | | | | | | | | | The "wrapping" employed by the mssql and oracle dialects using the "iswrapper" argument was not being used intelligently by the compiler, and the result map was being written incorrectly, using *more* columns in the result map than were actually returned by the statement, due to "row number" columns that are inside the subquery. The compiler now writes out result map on the "top level" select in all cases fully, and for the mssql/oracle wrapping case extracts out the "proxied" columns in a second step, which only includes those columns that are proxied outwards to the top level. This change might have implications for 3rd party dialects that might be imitating oracle's approach. They can safely continue to use the "iswrapper" kw which is now ignored, but they may need to also add the _select_wraps argument as well.
* - The SQL compiler now generates the mapping of expected columnspositional_targetingMike Bayer2015-03-072-76/+139
| | | | | | | | | | | | | | | | | such that they are matched to the received result set positionally, rather than by name. Originally, this was seen as a way to handle cases where we had columns returned with difficult-to-predict names, though in modern use that issue has been overcome by anonymous labeling. In this version, the approach basically reduces function call count per-result by a few dozen calls, or more for larger sets of result columns. The approach still degrades into a modern version of the old approach if textual elements modify the result map, or if any discrepancy in size exists between the compiled set of columns versus what was received, so there's no issue for partially or fully textual compilation scenarios where these lists might not line up. fixes #918 - callcounts still need to be adjusted down for this so zoomark tests won't pass at the moment
* - Fixed bug in :class:`.Connection` and pool where theMike Bayer2015-02-041-0/+7
| | | | | | | | | :meth:`.Connection.invalidate` method, or an invalidation due to a database disconnect, would fail if the ``isolation_level`` parameter had been used with :meth:`.Connection.execution_options`; the "finalizer" that resets the isolation level would be called on the no longer opened connection. fixes #3302
* - A warning is emitted if the ``isolation_level`` parameter is usedMike Bayer2015-02-043-0/+22
| | | | | | | | | | | | | | | | with :meth:`.Connection.execution_options` when a :class:`.Transaction` is in play; DBAPIs and/or SQLAlchemy dialects such as psycopg2, MySQLdb may implicitly rollback or commit the transaction, or not change the setting til next transaction, so this is never safe. - Added new parameter :paramref:`.Session.connection.execution_options` which may be used to set up execution options on a :class:`.Connection` when it is first checked out, before the transaction has begun. This is used to set up options such as isolation level on the connection before the transaction starts. - added new documentation section detailing best practices for setting transaction isolation with sessions. fixes #3296
* - remove the clever approach w/ dialect events, and remove the needMike Bayer2015-01-251-17/+20
| | | | | | for a for-loop through an empty tuple. we add one more local flag to handle the logic without repetition of dialect.do_execute() calls.
* - remove context-specific post-crud logic from Connection and inline post-crudMike Bayer2015-01-252-75/+81
| | | | | | | | | | logic to some degree in DefaultExecutionContext. In particular we are removing post_insert() which doesn't appear to be used based on a survey of prominent third party dialects. Callcounts aren't added to existing execute profiling tests and inserts might be a little better. - simplify the execution_options join in DEC. Callcounts don't appear affected.
* - Added new user-space accessors for viewing transaction isolationMike Bayer2015-01-203-15/+186
| | | | | | | | | levels; :meth:`.Connection.get_isolation_level`, :attr:`.Connection.default_isolation_level`. - enhance documentation inter-linkage between new accessors, existing isolation_level parameters, as well as in the dialect-level methods which should be fully covered by Engine/Connection level APIs now.
* - The multi-values version of :meth:`.Insert.values` has beenMike Bayer2015-01-131-4/+5
| | | | | | | | | | | | repaired to work more usefully with tables that have Python- side default values and/or functions, as well as server-side defaults. The feature will now work with a dialect that uses "positional" parameters; a Python callable will also be invoked individually for each row just as is the case with an "executemany" style invocation; a server- side default column will no longer implicitly receive the value explicitly specified for the first row, instead refusing to invoke without an explicit value. fixes #3288
* - restate sort_tables in terms of a more fine grainedMike Bayer2015-01-011-1/+68
| | | | | | | | | | | | | sort_tables_and_constraints function. - The DDL generation system of :meth:`.MetaData.create_all` and :meth:`.Metadata.drop_all` has been enhanced to in most cases automatically handle the case of mutually dependent foreign key constraints; the need for the :paramref:`.ForeignKeyConstraint.use_alter` flag is greatly reduced. The system also works for constraints which aren't given a name up front; only in the case of DROP is a name required for at least one of the constraints involved in the cycle. fixes #3282
* correctionsMike Bayer2014-12-272-1/+2
|
* - keep working on fixing #3266, more cases, more testsMike Bayer2014-12-101-4/+5
|
* - identify another spot where _handle_dbapi_error() needs to do somethingMike Bayer2014-12-081-3/+4
| | | | | differently for the case where it is called in an already-invalidated state; don't call upon self.connection
* - simplify the "noconnection" error handling, settingMike Bayer2014-12-082-18/+20
| | | | | | | _handle_dbapi_exception_noconnection() to only invoke in the case of raw_connection() in the constructor of Connection. in all other cases the Connection proceeds with _handle_dbapi_exception() including revalidate.
* - adjust _revalidate_connection() again such that we pass a _wrap=FalseMike Bayer2014-12-052-21/+30
| | | | | | | | | | to it, so that we say we will do the wrapping just once right here in _execute_context() / _execute_default(). An adjustment is made to _handle_dbapi_error() to not assume self.__connection in case we are already in an invalidated state further adjustment to 0639c199a547343d62134d2f233225fd2862ec45, 41e7253dee168b8c26c49, #3266
* - move inner calls to _revalidate_connection() outside of existingMike Bayer2014-12-051-8/+9
| | | | | _handle_dbapi_error(); these are now handled already and the reentrant call is not needed / breaks things. Adjustment to 41e7253dee168b8c26c49 /
* - document / work around that dialect_options isn't necessarily thereMike Bayer2014-12-051-1/+4
|
* - The engine-level error handling and wrapping routines will nowMike Bayer2014-12-054-18/+87
| | | | | | | | | take effect in all engine connection use cases, including when user-custom connect routines are used via the :paramref:`.create_engine.creator` parameter, as well as when the :class:`.Connection` encounters a connection error on revalidation. fixes #3266
* - New Oracle DDL features for tables, indexes: COMPRESS, BITMAP.Mike Bayer2014-12-041-1/+9
| | | | | Patch courtesy Gabor Gombas. fixes #3127
* - in lieu of adding a new system of translating bound parameter namesMike Bayer2014-11-101-0/+11
| | | | | | | for psycopg2 and others, encourage users to take advantage of positional styles by documenting "paramstyle". A section is added to psycopg2 specifically as this is a pretty common spot for named parameters that may be unusually named. fixes #3246.
* Merge remote-tracking branch 'origin/pr/140' into pr140Mike Bayer2014-10-111-2/+0
|\
| * cleanup exception handling - use new exception hierarchy (since python 2.5)pr/140ndparker2014-10-021-4/+0
| |
| * improve exception vs. exit handlingndparker2014-09-231-0/+2
| |
* | - adjustment for ref #3200 as we need an immutabledict() here soMike Bayer2014-10-071-1/+1
| | | | | | | | | | that union() can be called, in the case of a dialect that uses execution options inside of initialize() (e.g. oursql)
* | - The execution options passed to an :class:`.Engine` either viaMike Bayer2014-10-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | :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
* | - use provide_metadata for new unique constraint / index testsMike Bayer2014-10-041-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - add a test for PG reflection of unique index without any unique constraint - for PG, don't include 'duplicates_constraint' in the entry if the index does not actually mirror a constraint - use a distinct method for unique constraint reflection within table - catch unique constraint not implemented condition; this may be within some dialects and also is expected to be supported by Alembic tests - migration + changelogs for #3184 - add individual doc notes as well to MySQL, Postgreql fixes #3184
* | Merge branch 'reflect-unique-constraints' of ↵Mike Bayer2014-10-041-0/+34
|\ \ | | | | | | | | | https://bitbucket.org/jerdfelt/sqlalchemy into pr30
| * | Reflect unique constraints when reflecting a Table objectJohannes Erdfelt2014-09-171-0/+34
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calls to reflect a table did not create any UniqueConstraint objects. The reflection core made no calls to get_unique_constraints and as a result, the sqlite dialect would never reflect any unique constraints. MySQL transparently converts unique constraints into unique indexes, but SQLAlchemy would reflect those as an Index object and as a UniqueConstraint. The reflection core will now deduplicate the unique constraints. PostgreSQL would reflect unique constraints as an Index object and as a UniqueConstraint object. The reflection core will now deduplicate the unique indexes.
* | - cyclomatic complexity; break up reflecttable(), goes from E to BMike Bayer2014-09-271-39/+74
| |
* | - repair autorollback for branchesMike Bayer2014-09-261-2/+2
| |
* | - Fixed bug where a "branched" connection, that is the kind you getMike Bayer2014-09-261-37/+87
| | | | | | | | | | | | | | | | 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
* | - Fixed bug where a "branched" connection, that is the kind you getMike Bayer2014-09-261-11/+32
|/ | | | | | | | when you call :meth:`.Connection.connect`, would not share invalidation status with the parent. The architecture of branching has been tweaked a bit so that the branched connection defers to the parent for all invalidation status and operations. fixes #3215
* - Added :meth:`.Inspector.get_temp_table_names` andMike Bayer2014-09-172-1/+41
| | | | | | | | | | | | :meth:`.Inspector.get_temp_view_names`; currently, only the SQLite dialect supports these methods. The return of temporary table and view names has been **removed** from SQLite's version of :meth:`.Inspector.get_table_names` and :meth:`.Inspector.get_view_names`; other database backends cannot support this information (such as MySQL), and the scope of operation is different in that the tables can be local to a session and typically aren't supported in remote schemas. fixes #3204
* - tiny refactors #1-#5Mike Bayer2014-09-051-96/+115
|
* - An adjustment to table/index reflection such that if an indexMike Bayer2014-09-021-8/+17
| | | | | | | reports a column that isn't found to be present in the table, a warning is emitted and the column is skipped. This can occur for some special system column situations as has been observed with Oracle. fixes #3180
* - major refactoring/inlining to loader.instances(), though not reallyMike Bayer2014-08-281-3/+25
| | | | | | | | | | | any speed improvements :(. code is in a much better place to be run into C, however - The ``proc()`` callable passed to the ``create_row_processor()`` method of custom :class:`.Bundle` classes now accepts only a single "row" argument. - Deprecated event hooks removed: ``populate_instance``, ``create_instance``, ``translate_row``, ``append_result`` - the getter() idea is somewhat restored; see ref #3175
* - TIL that dict.keys() in py3K is not an iterator, it is an iterableMike Bayer2014-08-151-2/+2
| | | | | | | | view. So copy collections.OrderedDict and use MutableMapping to set up keys, items, values on our own OrderedDict. Conflicts: lib/sqlalchemy/engine/base.py
* - other test fixesMike Bayer2014-08-151-1/+1
|
* - The string keys that are used to determine the columns impactedMike Bayer2014-08-141-1/+1
| | | | | | | | | 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
* - rewrite all the sqlite/pysqlite transaction isolation docsMike Bayer2014-08-091-0/+16
|
* - rework the exclusions system to have much better support for compoundMike Bayer2014-07-261-0/+12
| | | | rules, better message formatting
* - more pg8000 tests passingMike Bayer2014-07-251-1/+0
|
* - The MySQL dialect will now disable :meth:`.ConnectionEvents.handle_error`Mike Bayer2014-07-251-1/+3
| | | | | | | | | | 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.
* PEP8 style fixesBrian Jarrett2014-07-1310-303/+318
|
* - break up the <authors> copyright comment as part of a passMike Bayer2014-07-0910-10/+20
| | | | to get all flake8 passing
* - rework the entire approach to #3076. As we need to catch all exceptionsMike Bayer2014-07-043-29/+165
| | | | | | | | | | | 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.
* - Added new attributes :attr:`.ExecutionContext.exception` andMike Bayer2014-07-032-1/+42
| | | | | | | :attr:`.ExecutionContext.is_disconnect` which are meaningful within the :meth:`.ConnectionEvents.dbapi_error` handler to see both the original DBAPI error as well as whether or not it represents a disconnect.