summaryrefslogtreecommitdiff
path: root/test/sql/test_query.py
Commit message (Collapse)AuthorAgeFilesLines
* Add SQL Server CI coverageMike Bayer2017-08-311-3/+1
| | | | Change-Id: Ida0d01ae9bcc0573b86e24fddea620a38c962822
* Add new "expanding" feature to bindparam()Mike Bayer2017-04-071-2/+72
| | | | | | | | | | | | | | | | Added a new kind of :func:`.bindparam` called "expanding". This is for use in ``IN`` expressions where the list of elements is rendered into individual bound parameters at statement execution time, rather than at statement compilation time. This allows both a single bound parameter name to be linked to an IN expression of multiple elements, as well as allows query caching to be used with IN expressions. The new feature allows the related features of "select in" loading and "polymorphic in" loading to make use of the baked query extension to reduce call overhead. This feature should be considered to be **experimental** for 1.2. Fixes: #3953 Change-Id: Ie708414a3ab9c0af29998a2c7f239ff7633b1f6e
* Add "empty in" strategies; default to "static"Mike Bayer2017-03-141-18/+54
| | | | | | | | | | | | | | | The longstanding behavior of the :meth:`.Operators.in_` and :meth:`.Operators.not_in_` operators emitting a warning when the right-hand condition is an empty sequence has been revised; a new flag :paramref:`.create_engine.empty_in_strategy` allows an empty "IN" expression to generate a simple boolean expression, or to invoke the previous behavior of dis-equating the expression to itself, with or without a warning. The default behavior is now to emit the simple boolean expression, allowing an empty IN to be evaulated without any performance penalty. Change-Id: I65cc37f2d7cf65a59bf217136c42fee446929352 Fixes: #3907
* Make all tests to be PEP8 compliantKhairi Hafsham2017-02-071-2/+5
| | | | | | | | tested using pycodestyle version 2.2.0 Fixes: #3885 Change-Id: I5df43adc3aefe318f9eeab72a078247a548ec566 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/343
* Support python3.6Mike Bayer2017-01-131-1/+1
| | | | | | | | | | | Corrects some warnings and adds tox config. Adds DeprecationWarning to the error category. Large sweep for string literals w/ backslashes as this is common in docstrings Co-authored-by: Andrii Soldatenko Fixes: #3886 Change-Id: Ia7c838dfbbe70b262622ed0803d581edc736e085 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/337
* - break out critical aspects of test_query into their own testsMike Bayer2015-09-271-1416/+4
| | | | | finally, test_resultset and test_insert_exec. Update all idioms within these.
* - Fixed regression where new methods on :class:`.ResultProxy` usedMike Bayer2015-07-191-2/+10
| | | | | | | | | by the ORM :class:`.Query` object (part of the performance enhancements of :ticket:`3175`) would not raise the "this result does not return rows" exception in the case where the driver (typically MySQL) fails to generate cursor.description correctly; an AttributeError against NoneType would be raised instead. fixes #3481
* - pg8000 very annoyingly complaining here, use total literalMike Bayer2015-07-191-1/+2
|
* - Fixed regression where :meth:`.ResultProxy.keys` would returnMike Bayer2015-07-191-5/+94
| | | | | | | | un-adjusted internal symbol names for "anonymous" labels, which are the "foo_1" types of labels we see generated for SQL functions without labels and similar. This was a side effect of the performance enhancements implemented as part of references #918. fixes #3483
* - ensure that the keys we put into the parameters dictionaryMike Bayer2015-04-081-1/+8
| | | | | | | for an insert from select are the string names, and not the Column objects. The MSSQL dialect in particular relies upon checking for these keys in params to know if identity insert should be on. references #3360
* - The "auto close" for :class:`.ResultProxy` is now a "soft" close.Mike Bayer2015-03-171-0/+3
| | | | | | | | | | | 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
* - The SQL compiler now generates the mapping of expected columnspositional_targetingMike Bayer2015-03-071-0/+42
| | | | | | | | | | | | | | | | | 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
* - Exception messages have been spiffed up a bit. The SQL statementMike Bayer2014-10-171-4/+3
| | | | | | | | | | | 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
* - additional issues fixed in mysqlconnector 2.0.1Mike Bayer2014-10-131-15/+0
|
* - Mysqlconnector as of version 2.0, probably as a side effect ofMike Bayer2014-10-121-6/+0
| | | | | | | | | | | | | | | | the python 3 merge, now does not expect percent signs (e.g. as used as the modulus operator and others) to be doubled, even when using the "pyformat" bound parameter format (this change is not documented by Mysqlconnector). The dialect now checks for py2k and for mysqlconnector less than version 2.0 when detecting if the modulus operator should be rendered as ``%%`` or ``%``. - Unicode SQL is now passed for MySQLconnector version 2.0 and above; for Py2k and MySQL < 2.0, strings are encoded. Note that mysqlconnector as of 2.0.1 appears to have a bug with unicode DDL on py2k, so the tests here are skipping until we observe it's fixed. - take out profiling on mysqlconnector, callcounts vary too much with its current development speed
* - The :func:`~.expression.column` and :func:`~.expression.table`Mike Bayer2014-09-011-4/+6
| | | | | | | | | | | | | | | | | | | | | constructs are now importable from the "from sqlalchemy" namespace, just like every other Core construct. - The implicit conversion of strings to :func:`.text` constructs when passed to most builder methods of :func:`.select` as well as :class:`.Query` now emits a warning with just the plain string sent. The textual conversion still proceeds normally, however. The only method that accepts a string without a warning are the "label reference" methods like order_by(), group_by(); these functions will now at compile time attempt to resolve a single string argument to a column or label expression present in the selectable; if none is located, the expression still renders, but you get the warning again. The rationale here is that the implicit conversion from string to text is more unexpected than not these days, and it is better that the user send more direction to the Core / ORM when passing a raw string as to what direction should be taken. Core/ORM tutorials have been updated to go more in depth as to how text is handled. fixes #2992
* - The INSERT...FROM SELECT construct now implies ``inline=True``Mike Bayer2014-08-201-0/+7
| | | | | | | | | | | | | | | | | | | | | | | on :class:`.Insert`. This helps to fix a bug where an INSERT...FROM SELECT construct would inadvertently be compiled as "implicit returning" on supporting backends, which would cause breakage in the case of an INSERT that inserts zero rows (as implicit returning expects a row), as well as arbitrary return data in the case of an INSERT that inserts multiple rows (e.g. only the first row of many). A similar change is also applied to an INSERT..VALUES with multiple parameter sets; implicit RETURNING will no longer emit for this statement either. As both of these constructs deal with varible numbers of rows, the :attr:`.ResultProxy.inserted_primary_key` accessor does not apply. Previously, there was a documentation note that one may prefer ``inline=True`` with INSERT..FROM SELECT as some databases don't support returning and therefore can't do "implicit" returning, but there's no reason an INSERT...FROM SELECT needs implicit returning in any case. Regular explicit :meth:`.Insert.returning` should be used to return variable numbers of result rows if inserted data is needed. fixes #3169
* - find the remaining not cleaning up correctly testMike Bayer2014-07-281-1/+2
|
* - scale up for mysql, sqliteMike Bayer2014-07-261-3/+3
|
* - update the flake8 rules againMike Bayer2014-07-181-2/+7
| | | | - apply autopep8 + manual fixes to most of test/sql/
* PEP8 tidy of subset of test/sql/*.pypr/103Tony Locke2014-07-071-436/+513
|
* pg8000 passing test/sqlTony Locke2014-07-061-2/+2
|
* mark failing tests for buggy mysqlconnectorMike Bayer2014-03-281-0/+21
|
* - rename __multiple__ to __backend__, and apply __backend__ to a large ↵Mike Bayer2014-03-241-0/+10
| | | | | | number of tests. - move out logging tests from test_execute to test_logging
* - add more support for suite tests, moving some tests from test_query out to ↵Mike Bayer2014-03-131-153/+24
| | | | | | suite and adding some more requirements
* - Support has been added for pytest to run tests. This runnerMike Bayer2014-03-031-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | is currently being supported in addition to nose, and will likely be preferred to nose going forward. The nose plugin system used by SQLAlchemy has been split out so that it works under pytest as well. There are no plans to drop support for nose at the moment and we hope that the test suite itself can continue to remain as agnostic of testing platform as possible. See the file README.unittests.rst for updated information on running tests with pytest. The test plugin system has also been enhanced to support running tests against mutiple database URLs at once, by specifying the ``--db`` and/or ``--dburi`` flags multiple times. This does not run the entire test suite for each database, but instead allows test cases that are specific to certain backends make use of that backend as the test is run. When using pytest as the test runner, the system will also run specific test suites multiple times, once for each database, particularly those tests within the "dialect suite". The plan is that the enhanced system will also be used by Alembic, and allow Alembic to run migration operation tests against multiple backends in one run, including third-party backends not included within Alembic itself. Third party dialects and extensions are also encouraged to standardize on SQLAlchemy's test suite as a basis; see the file README.dialects.rst for background on building out from SQLAlchemy's test platform.
* - More issues with [ticket:2932] first resolved in 0.9.2 whereMike Bayer2014-02-051-0/+30
| | | | | | | | | | using a column key of the form ``<tablename>_<columnname>`` matching that of an aliased column in the text would still not match at the ORM level, which is ultimately due to a core column-matching issue. Additional rules have been added so that the column ``_label`` is taken into account when working with a :class:`.TextAsFrom` construct or with literal columns. [ticket:2932]
* - Fixed bug in new :class:`.TextAsFrom` construct where :class:`.Column`-Mike Bayer2014-02-021-0/+45
| | | | | | | | | | oriented row lookups were not matching up to the ad-hoc :class:`.ColumnClause` objects that :class:`.TextAsFrom` generates, thereby making it not usable as a target in :meth:`.Query.from_statement`. Also fixed :meth:`.Query.from_statement` mechanics to not mistake a :class:`.TextAsFrom` for a :class:`.Select` construct. This bug is also an 0.9 regression as the :meth:`.Text.columns` method is called to accommodate the :paramref:`.text.typemap` argument. [ticket:2932]
* - better way to do itMike Bayer2014-01-291-2/+4
|
* - add TypeError handling to the tests here, ensure TypeErrorMike Bayer2014-01-291-8/+15
| | | | | for the control is a TypeError for the row, as is raised on py3k when less/greater operators are used on incompatible types
* - Fixed 0.9 regression where the new sortable support for :class:`.RowProxy`Mike Bayer2014-01-281-1/+25
| | | | | | | | | would lead to ``TypeError`` when compared to non-tuple types as it attempted to apply tuple() to the "other" object unconditionally. The full range of Python comparison operators have now been implemented on :class:`.RowProxy`, using an approach that guarantees a comparison system that is equivalent to that of a tuple, and the "other" object is only coerced if it's an instance of RowProxy. [ticket:2924]
* - Fixed bug where SQL statement would be improperly ASCII-encodedMike Bayer2013-11-221-1/+1
| | | | | | | 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]
* - The :class:`.RowProxy` object is now sortable in Python as a regularMike Bayer2013-11-191-0/+13
| | | | | | tuple is; this is accomplished via ensuring tuple() conversion on both sides within the ``__eq__()`` method as well as the addition of a ``__lt__()`` method. [ticket:2848]
* - remove informix dialect, moved out to ↵Mike Bayer2013-11-171-3/+0
| | | | | | https://bitbucket.org/zzzeek/sqlalchemy_informixdb - remove informix, maxdb, access symbols from tests etc.
* - we dont actually need this unicode cast, on py3k + linux it seems theMike Bayer2013-07-091-0/+2
| | | | | has_table issues are OK. On OSX forget it. - still some issues with PY3k + pyodbc + decimal values it doesn't expect, not sure
* add an ORDER BY hereMike Bayer2013-06-261-2/+2
|
* - some tweaks to try to help out mssql+pyodbc support a bit, py3k is reallyMike Bayer2013-06-031-2/+0
| | | | not happening too well (I need to stick with linux + freetds 0.91, I know)
* - the raw 2to3 runMike Bayer2013-04-271-21/+21
| | | | - went through examples/ and cleaned out excess list() calls
* A major fix to the way in which a select() object producesMike Bayer2013-04-111-0/+16
| | | | | | | | | | | | | | | | | | | labeled columns when apply_labels() is used; this mode produces a SELECT where each column is labeled as in <tablename>_<columnname>, to remove column name collisions for a multiple table select. The fix is that if two labels collide when combined with the table name, i.e. "foo.bar_id" and "foo_bar.id", anonymous aliasing will be applied to one of the dupes. This allows the ORM to handle both columns independently; previously, 0.7 would in some cases silently emit a second SELECT for the column that was "duped", and in 0.8 an ambiguous column error would be emitted. The "keys" applied to the .c. collection of the select() will also be deduped, so that the "column being replaced" warning will no longer emit for any select() that specifies use_labels, though the dupe key will be given an anonymous label which isn't generally user-friendly. [ticket:2702]
* fix syntax errorMike Bayer2013-03-241-1/+1
|
* Fixed bug whereby a DBAPI that can return "0"Mike Bayer2013-03-231-1/+18
| | | | | for cursor.lastrowid would not function correctly in conjunction with :attr:`.ResultProxy.inserted_primary_key`.
* - add support for pulling in an external requirements fileMike Bayer2013-02-061-9/+14
| | | | - start filling in default versions of remaining requirements that are still only in test/
* - add an "empty_inserts" requirement target plus a suite testMike Bayer2013-02-061-3/+3
| | | | - add suite tests for basic explicit Sequence support, result-row column access (tests that name_normalize is set correctly among many other things)
* internally at least refer to multirow as "multivalues", to distinguish betweenMike Bayer2012-12-081-2/+2
| | | | | an INSERT that's used in executemany() as opposed to one which has a VALUES clause with multiple entries.
* - multivalued inserts, [ticket:2623]Mike Bayer2012-12-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - update "not supported" messages for empty inserts, mutlivalue inserts - rework the ValuesBase approach for multiple value sets so that stmt.parameters does store a list for multiple values; the _has_multiple_parameters flag now indicates which of the two modes the statement is within. it now raises exceptions if a subsequent call to values() attempts to call a ValuesBase with one mode in the style of the other mode; that is, you can't switch a single- or multi- valued ValuesBase to the other mode, and also if a multiple value is passed simultaneously with a kwargs set. Added tests for these error conditions - Calling values() multiple times in multivalue mode now extends the parameter list to include the new parameter sets. - add error/test if multiple *args were passed to ValuesBase.values() - rework the compiler approach for multivalue inserts, back to where _get_colparams() returns the same list of (column, value) as before, thereby maintaining the identical number of append() and other calls when multivalue is not enabled. In the case of multivalue, it makes a last-minute switch to return a list of lists instead of the single list. As it constructs the additional lists, the inline defaults and other calculated default parameters of the first parameter set are copied into the newly generated lists so that these features continue to function for a multivalue insert. Multivalue inserts now add no additional function calls to the compilation for regular insert constructs. - parameter lists for multivalue inserts now includes an integer index for all parameter sets. - add detailed documentation for ValuesBase.values(), including careful wording to describe the difference between multiple values and an executemany() call. - add a test for multivalue insert + returning - it works ! - remove the very old/never used "postgresql_returning"/"firebird_returning" flags.
* compiler: add support for multirow insertsIdan Kamara2012-12-061-0/+11
| | | | | | | | | | | | | | | | | | | | | 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.
* Fixed bug whereby using "key" with ColumnMike Bayer2012-11-131-0/+21
| | | | | | | | in conjunction with "schema" for the owning Table would fail to locate result rows due to the MSSQL dialect's "schema rendering" logic's failure to take .key into account. Also in 0.7.10. [ticket:2607]
* - [feature] The Query can now load entity/scalar-mixedMike Bayer2012-10-151-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | "tuple" rows that contain types which aren't hashable, by setting the flag "hashable=False" on the corresponding TypeEngine object in use. Custom types that return unhashable types (typically lists) can set this flag to False. [ticket:2592] - [bug] Applying a column expression to a select statement using a label with or without other modifying constructs will no longer "target" that expression to the underlying Column; this affects ORM operations that rely upon Column targeting in order to retrieve results. That is, a query like query(User.id, User.id.label('foo')) will now track the value of each "User.id" expression separately instead of munging them together. It is not expected that any users will be impacted by this; however, a usage that uses select() in conjunction with query.from_statement() and attempts to load fully composed ORM entities may not function as expected if the select() named Column objects with arbitrary .label() names, as these will no longer target to the Column objects mapped by that entity. [ticket:2591]
* - more tests, move some tests out of test_reflection, test_queryMike Bayer2012-09-271-78/+8
|
* trying different approaches to test layout. in this one, the testing modulesMike Bayer2012-09-271-4/+6
| | | | | | | 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.