summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine/default.py
Commit message (Collapse)AuthorAgeFilesLines
* - The SQL compiler now generates the mapping of expected columnspositional_targetingMike Bayer2015-03-071-2/+9
| | | | | | | | | | | | | | | | | 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
* - A warning is emitted if the ``isolation_level`` parameter is usedMike Bayer2015-02-041-0/+6
| | | | | | | | | | | | | | | | 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 context-specific post-crud logic from Connection and inline post-crudMike Bayer2015-01-251-51/+76
| | | | | | | | | | 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.
* - 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
* - tiny refactors #1-#5Mike Bayer2014-09-051-96/+115
|
* PEP8 style fixesBrian Jarrett2014-07-131-58/+58
|
* - break up the <authors> copyright comment as part of a passMike Bayer2014-07-091-1/+2
| | | | to get all flake8 passing
* revert inadvertent pdbMike Bayer2014-03-281-2/+0
|
* - Fixed ORM bug where changing the primary key of an object, then markingMike Bayer2014-03-281-0/+2
| | | | | | | | | | | | | it for DELETE would fail to target the correct row for DELETE. Then to compound matters, basic "number of rows matched" checks were not being performed. Both issues are fixed, however note that the "rows matched" check requires so-called "sane multi-row count" functionality; the DBAPI's executemany() method must count up the rows matched by individual statements and SQLAlchemy's dialect must mark this feature as supported, currently applies to some mysql dialects, psycopg2, sqlite only. fixes #3006 - Enabled "sane multi-row count" checking for the psycopg2 DBAPI, as this seems to be supported as of psycopg2 2.0.9.
* docsMike Bayer2014-02-251-10/+20
|
* - Fixed the multiple-table "UPDATE..FROM" construct, only usable onMike Bayer2014-01-201-3/+5
| | | | | | | | | | | MySQL, to correctly render the SET clause among multiple columns with the same name across tables. This also changes the name used for the bound parameter in the SET clause to "<tablename>_<colname>" for the non-primary table only; as this parameter is typically specified using the :class:`.Column` object directly this should not have an impact on applications. The fix takes effect for both :meth:`.Table.update` as well as :meth:`.Query.update` in the ORM. [ticket:2912]
* - implement kwarg validation and type system for dialect-specificMike Bayer2014-01-181-0/+28
| | | | | arguments; [ticket:2866] - add dialect specific kwarg functionality to ForeignKeyConstraint, ForeignKey
* - _cursor_execute() will close the cursor on error; oracle doesn't allow ↵Mike Bayer2014-01-131-12/+12
| | | | | | double close - ensure no iterator changed size issues in testing.engines
* - The MySQL CAST compilation now takes into account aspects of a stringMike Bayer2014-01-131-21/+30
| | | | | | | | | | | | | | | | | | | | | 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]
* revert r2775c95b1ee30831216cc5 which was mostly an inadvertent commit, ↵Mike Bayer2014-01-131-30/+21
| | | | except for the changelog part
* new changelogMike Bayer2014-01-111-21/+30
|
* - happy new yearMike Bayer2014-01-051-1/+1
|
* - The :func:`.engine_from_config` function has been improved so thatMike Bayer2013-12-071-0/+12
| | | | | | | | 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]
* An overhaul of expression handling for special symbols particularlyMike Bayer2013-10-231-1/+3
| | | | | | | | | | with conjunctions, e.g. ``None`` :func:`.expression.null` :func:`.expression.true` :func:`.expression.false`, including consistency in rendering NULL in conjunctions, "short-circuiting" of :func:`.and_` and :func:`.or_` expressions which contain boolean constants, and rendering of boolean constants and expressions as compared to "1" or "0" for backends that don't feature ``true``/``false`` constants. [ticket:2804]
* - The method signature of :meth:`.Dialect.reflecttable`, which inMike Bayer2013-10-111-2/+1
| | | | | | | all known cases is provided by :class:`.DefaultDialect`, has been tightened to expect ``include_columns`` and ``exclude_columns`` arguments without any kw option, reducing ambiguity - previously ``exclude_columns`` was missing. [ticket:2748]
* - A rework to the way that "quoted" identifiers are handled, in thatMike Bayer2013-08-271-0/+2
| | | | | | | | | | | | | | | | instead of relying upon various ``quote=True`` flags being passed around, these flags are converted into rich string objects with quoting information included at the point at which they are passed to common schema constructs like :class:`.Table`, :class:`.Column`, etc. This solves the issue of various methods that don't correctly honor the "quote" flag such as :meth:`.Engine.has_table` and related methods. The :class:`.quoted_name` object is a string subclass that can also be used explicitly if needed; the object will hold onto the quoting preferences passed and will also bypass the "name normalization" performed by dialects that standardize on uppercase symbols, such as Oracle, Firebird and DB2. The upshot is that the "uppercase" backends can now work with force-quoted names, such as lowercase-quoted names and new reserved words. [ticket:2812]
* - The ``version_id_generator`` parameter of ``Mapper`` can now be specifiedMike Bayer2013-08-251-0/+7
| | | | | | | | | | | | | | | | | | | | | to rely upon server generated version identifiers, using triggers or other database-provided versioning features, by passing the value ``False``. The ORM will use RETURNING when available to immediately load the new version identifier, else it will emit a second SELECT. [ticket:2793] - The ``eager_defaults`` flag of :class:`.Mapper` will now allow the newly generated default values to be fetched using an inline RETURNING clause, rather than a second SELECT statement, for backends that support RETURNING. - Added a new variant to :meth:`.ValuesBase.returning` called :meth:`.ValuesBase.return_defaults`; this allows arbitrary columns to be added to the RETURNING clause of the statement without interfering with the compilers usual "implicit returning" feature, which is used to efficiently fetch newly generated primary key values. For supporting backends, a dictionary of all fetched values is present at :attr:`.ResultProxy.returned_defaults`. - add a glossary entry for RETURNING - add documentation for version id generation, [ticket:867]
* - A large refactoring of the ``sqlalchemy.sql`` package has reorganizedMike Bayer2013-08-121-1/+2
| | | | | | | | | | | | | | | | | | | | | | 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.
* a missing cursor.close() here caused a *huge* amount of weird locking ↵Mike Bayer2013-08-021-7/+10
| | | | | | | | issues with pypy, what is strange is how it only occurred in some very specific places under very particular conditions, perhaps it has to do with whether or not this cursor gets gc'ed or not.
* - assorted fixes raised by pypy 2.1beta2, but all of which are goodMike Bayer2013-08-011-0/+24
| | | | | | | | | | | | | | | ideas in general: - pypy2.1 w/ sqlite3 is the first DBAPI we're seeing returning unicode in cursor.description without being py3k. add a new on-connect check for this, if we get back a u"", just don't do description decoding, should be OK for now. - the set tests in test_collection were assuming the two sets would be ordered the same when it tested pop(), can't really assume that. - test_serializer gets worse and worse, pickle is just not really viable here, ding out pypy - pypy2.1b2 seems to allow cursor.lastrowid to work (or we changed something?) - pool._threadconns.current() is a weakref, it can be None - another one of those logging.handlers imports
* - refactor pool a bit so that intent between ↵Mike Bayer2013-07-021-0/+19
| | | | | | | | | | | | | | 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()
* Merge branch 'ticket_2587'Mike Bayer2013-06-041-0/+5
|\ | | | | | | | | | | Conflicts: test/profiles.txt test/sql/test_selectable.py
| * - add a flag to DefaultDialect for this so that people will have someMike Bayer2013-06-041-0/+3
| | | | | | | | workaround
| * working through tests....Mike Bayer2013-06-021-0/+2
| |
* | Merge branch 'master' into ticket_1068Mike Bayer2013-06-031-30/+25
|\ \ | |/
| * a pass where we try to squash down as many list()/keys() combinationsMike Bayer2013-05-261-1/+1
| | | | | | | | as possible
| * - OK we have -w sql passing for: sqlite, postgresql, oursql 2.7 + 3.3, ↵Mike Bayer2013-05-041-1/+1
| | | | | | | | mysqldb 2.7
| * plugging awayMike Bayer2013-04-271-30/+23
| |
| * - the raw 2to3 runMike Bayer2013-04-271-29/+31
| | | | | | | | - went through examples/ and cleaned out excess list() calls
* | attempt number one, doesn't detect though if the label in the order by is ↵Mike Bayer2013-05-271-0/+2
|/ | | | not directly present there.
* Reworked internal exception raises that emitMike Bayer2013-04-181-2/+0
| | | | | | | | | a rollback() before re-raising, so that the stack trace is preserved from sys.exc_info() before entering the rollback. This so that the traceback is preserved when using coroutine frameworks which may have switched contexts before the rollback function returns. [ticket:2703]
* - add an event to testing so that other dialects can intercept ↵Mike Bayer2013-03-241-0/+4
| | | | | | "test_needs_autoincrement" - get the assumption of "1" for "first sequence item" to be dialect configured
* Fixed bug whereby a DBAPI that can return "0"Mike Bayer2013-03-231-1/+1
| | | | | for cursor.lastrowid would not function correctly in conjunction with :attr:`.ResultProxy.inserted_primary_key`.
* The cx_oracle dialect will no longer run the bind parameter namesMike Bayer2013-02-081-1/+3
| | | | | | | through ``encode()``, as this is not valid on Python 3, and prevented statements from functioning correctly on Python 3. We now encode only if ``supports_unicode_binds`` is False, which is not the case for cx_oracle when at least version 5 of cx_oracle is used.
* happy new year (see #2645)Diana Clarke2013-01-011-1/+1
|
* internally at least refer to multirow as "multivalues", to distinguish betweenMike Bayer2012-12-081-1/+1
| | | | | an INSERT that's used in executemany() as opposed to one which has a VALUES clause with multiple entries.
* compiler: add support for multirow insertsIdan Kamara2012-12-061-0/+1
| | | | | | | | | | | | | | | | | | | | | Some databases support this syntax for inserts: INSERT INTO table (id, name) VALUES ('v1', 'v2'), ('v3', 'v4'); which greatly increases INSERT speed. It is now possible to pass a list of lists/tuples/dictionaries as the values param to the Insert construct. We convert it to a flat dictionary so we can continue using bind params. The above query will be converted to: INSERT INTO table (id, name) VALUES (:id, :name), (:id0, :name0); Currently only supported on postgresql, mysql and sqlite.
* - recognize that do_rollback() and do_commit() work with a DBAPI connection,Mike Bayer2012-11-221-16/+7
| | | | | | | | | | | | | | | | | | whereas the other do_rollback_twophase(), savepoint etc. work with :class:`.Connection`. the context on these are different as twophase/savepoint are available at the :class:`.Connection` level, whereas commit/rollback are needed at a lower level as well. Rename the argument to "dbapi_connection" when the conneciton is in fact the DBAPI interface. - start thinking about being able to track "autocommit" vs. "commit", but not sure we have a need for this yet. - have Pool call out to a Dialect for all rollback/commit/close operations now. Pool no longer calls DBAPI methods directly. May use this for a workaround for [ticket:2611] - add a new Pool event reset() to allow the pool's reset of the connection to be intercepted. - remove methods in Informix dialect which appear to be hardcoding some isolation settings on new Transaction only; the isolation API should be implemented for Informix. also removed "flag" for transaction commit/rollback being not available; this should be based on server/DBAPI version and we will need someone with test access in order to help determine how this should work
* just a pep8 pass of lib/sqlalchemy/engine/Diana Clarke2012-11-191-2/+1
|
* improve some autodoc linksMike Bayer2012-10-311-2/+2
|
* The long-deprecated and non-functional ``assert_unicode`` flag onMike Bayer2012-10-251-11/+1
| | | | :func:`.create_engine` as well as :class:`.String` is removed.
* - [feature] Various API tweaks to the "dialect"Mike Bayer2012-10-081-0/+10
| | | | | | | API to better support highly specialized systems such as the Akiban database, including more hooks to allow an execution context to access type processors.
* - add back __engine_options__Mike Bayer2012-10-041-3/+3
| | | | | - break test_insert tests into explicitly get_lastrowid() vs. implicit_returning tests, fix up requirements to split them out
* - don't call get_lastrowid() on explicit returningMike Bayer2012-10-041-0/+1
| | | | | | - don't hardwire "subqueries" requirement in the base, mysql < 4.1 isn't working anyway - don't need explicit FB/PG exclusions in test_returning - hit db.connect() for the returning requirement
* small tweaks to make insert() behavior more consistent, mostly tests, ↵Mike Bayer2012-08-231-1/+1
| | | | [ticket:2461]