summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing
Commit message (Collapse)AuthorAgeFilesLines
* Refactor for cx_Oracle version 6oracle_numericMike Bayer2017-09-113-4/+2
| | | | | | | | | Drops support for cx_Oracle prior to version 5.x, reworks numeric and binary support. Fixes: #4064 Change-Id: Ib9ae9aba430c15cd2a6eeb4e5e3fd8e97b5fe480
* - skip oracle tests until we can merge refactorMike Bayer2017-09-081-0/+18
| | | | Change-Id: Ie9bec6e8f51d52349dcbd8009981818e459e88b8
* Add SQL Server CI coverageMike Bayer2017-08-313-38/+142
| | | | Change-Id: Ida0d01ae9bcc0573b86e24fddea620a38c962822
* Add new sane_rowcount_w_returning flagMike Bayer2017-08-311-0/+23
| | | | | | | | | | | | | | | | | Added a new class of "rowcount support" for dialects that is specific to when "RETURNING", which on SQL Server looks like "OUTPUT inserted", is in use, as the PyODBC backend isn't able to give us rowcount on an UPDATE or DELETE statement when OUTPUT is in effect. This primarily affects the ORM when a flush is updating a row that contains server-calcluated values, raising an error if the backend does not return the expected row count. PyODBC now states that it supports rowcount except if OUTPUT.inserted is present, which is taken into account by the ORM during a flush as to whether it will look for a rowcount. ORM tests are implicit in existing tests run against PyODBC Fixes: #4062 Change-Id: Iff17cbe4c7a5742971ed85a4d58660c18cc569c2
* Generalize autocommit testingMike Bayer2017-08-292-0/+48
| | | | | | | To support adding AUTOCOMMIT to more dialects, add a suite test Change-Id: I585dcce19fcdce70e8cf21aea4edaa97d7bf2bb9
* Apply percent sign escaping to literal binds, commentsMike Bayer2017-08-252-4/+13
| | | | | | | | | | | | | | Fixed bug in new percent-sign support (e.g. :ticket:`3740`) where a bound parameter rendered with literal_binds would fail to escape percent-signs for relevant dialects. In addition, ensured new table / column comment support feature also fully makes use of literal-rendered parameters so that this percent sign support takes place with table / column comment DDL as well, allowing percent sign support for the mysql / psycopg2 backends that require escaping of percent signs. Change-Id: Ia4136a300933e9bc6a01a7b9afd5c7b9a3fee4e3 Fixes: #4054 Fixes: #4052
* Deactivate transaction if rollback failsMike Bayer2017-08-221-2/+2
| | | | | | | | | | | | Fixed regression introduced in 1.2.0b1 due to :ticket:`3934` where the :class:`.Session` would fail to "deactivate" the transaction, if a rollback failed (the target issue is when MySQL loses track of a SAVEPOINT). This would cause a subsequent call to :meth:`.Session.rollback` to raise an error a second time, rather than completing and bringing the :class:`.Session` back to ACTIVE. Fixes: #4050 Change-Id: Id245e8dd3487cb006b2d6631c8bd513b5ce81abe
* - allow a separate template database to be used forMike Bayer2017-08-222-5/+11
| | | | | | | PG CREATE DATABASE. as nobody will connect to it that would solve the contention issue here Change-Id: I00a4d52091876e120faff4a8a5493c53280d96f1
* - repair --dbsMike Bayer2017-08-222-1/+21
| | | | | Change-Id: I69e39d2368f50b126c369ecc35e01799fd013254 (cherry picked from commit 3fc6f32ddc5fbbf439acff42c2fdae9e910154be)
* - simplify and see if it still worksMike Bayer2017-08-211-23/+6
| | | | Change-Id: Id0cf7ae2223507d413aaa22e5f8df066b7ac2b46
* - keep trying to get PG dbs to buildMike Bayer2017-08-211-0/+11
| | | | Change-Id: Ib36949da8f079594494a482423d96e7509673481
* - add missing quotesMike Bayer2017-08-211-1/+1
| | | | Change-Id: Ib6efc465cccd7c7661dd089856edfd4979b53517
* - try to get PG database create to be more reliableMike Bayer2017-08-211-1/+10
| | | | Change-Id: I9c9d101547f4484af447db924dc06afd0392a03e
* - sanitize class names for junit reportingMike Bayer2017-08-211-1/+8
| | | | Change-Id: I42821d8324208b708adc17a10b1a2758797cb9db
* - filter out non-oracle URLsMike Bayer2017-08-211-0/+2
| | | | Change-Id: I475f744f8801bc923d738e466d208d662e707413
* - a few mysql fixes, more to comeMike Bayer2017-08-201-3/+4
| | | | Change-Id: Icdcc8ed03374251b8d3815ae58e2726ea27c14b4
* - rework oracle de-provisioning to write URLs to the file as well,Mike Bayer2017-08-203-33/+47
| | | | | | supporting custom dburi etc. Change-Id: Ic0ab0b3b4223e40fd335ee3313fda4dfce942100
* - add some logging for the provisioningMike Bayer2017-08-191-0/+2
| | | | Change-Id: I1ac16bc77642f4f576195ac10443ed8e641e0d49
* - do ten attempts to create databaseMike Bayer2017-08-191-1/+1
| | | | Change-Id: I14a5dd920d14096aa4401cb8b9d71f47d3915879
* - correct server side cursor assertion for driver namesMike Bayer2017-08-191-5/+5
| | | | Change-Id: Id8156f6af15a36f7d5653dff56f68e81431692a6
* Merge "Ensure Oracle index w/ col DESC etc. is reflected"mike bayer2017-08-141-9/+57
|\
| * Ensure Oracle index w/ col DESC etc. is reflectedMike Bayer2017-08-141-9/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed bug where an index reflected under Oracle with an expression like "column DESC" would not be returned, if the table also had no primary key, as a result of logic that attempts to filter out the index implicitly added by Oracle onto the primary key columns. Reworked the "filter out the primary key index" logic in oracle get_indexes() to be clearer. This changeset also adds an internal check to ColumnCollection to accomodate for the case of a column being added twice, as well as adding a private _table argument to Index such that reflection can specify the Table explicitly. The _table argument can become part of public API in a later revision or release if needed. Change-Id: I745711e03b3e450b7f31185fc70e10d3823063fa Fixes: #4042
* | Isolate memory tests in forksMike Bayer2017-08-141-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | Swing the biggest hammer, run multiprocessing.Process() for each memusage test individually so that they are fully isolated from the parent process and any side effects of pytest-xdist Also add --nomemory as a shortcut to exclude_tags=memory-intensive and add this to the setup.py test runner as the memory tests should not be running for quick runs Change-Id: I3c16c781e21b33deb939a64e77a6e0e41fb86922
* | Restore original test namesMike Bayer2017-08-141-4/+3
|/ | | | | | | | | | | The change in de1f8f8345ecd6af0ec1177703465e9471cfe862 modified how test classes are named, breaking logic that extracts the class name for the profiling suite. Add a new variable _sa_orig_cls_name if we've modified the name so that the profiling logic doesn't need to guess the original class name. Change-Id: Ica15a97408b9e0749a78c87f62749c15c1627009
* Enable multi-level selectin polymorphic loadingMike Bayer2017-08-071-8/+5
| | | | | Change-Id: Icc742bbeecdb7448ce84caccd63e086af16e81c1 Fixes: #4026
* Allow multiple versions of single backendMike Bayer2017-08-043-9/+17
| | | | | | | | | | Improve screen output to illustrate which server version is running for a particular database config, and additionally allow full overriding for the backend-specific targets in tox.ini via environment variables, so that CI can inject multiple server urls for a particular database such as MySQL/MariaDB. Change-Id: Ibf443bb9fb82e4563efd1bb66058fa9989aa2fda
* Ensure we check for boolean condition when we inspect __exit__()Mike Bayer2017-07-241-1/+1
| | | | | | | | Fixed issue in testing fixtures which was incompatible with a change made as of Python 3.6.2 involving context managers. Change-Id: I0f12aa6cc15cba89153f7e4888ac347e7ce599c7 Fixes: #4034
* Coerce to float for Float with all native decimal backendsMike Bayer2017-06-261-1/+0
| | | | | | | | | | | | | The result processor for the :class:`.Float` type now unconditionally runs values through the ``float()`` processor if the dialect specifies that it also supports "native decimal" mode. While most backends will deliver Python ``float`` objects for a floating point datatype, the MySQL backends in some cases lack the typing information in order to provide this and return ``Decimal`` unless the float conversion is done. Change-Id: I638f1480fb00a507036efaf0e0080f26893d98ad Fixes: #4020
* Coerce float Python type to Float; ensure Python float coming backMike Bayer2017-06-261-0/+18
| | | | | | | | | | | Added some extra strictness to the handling of Python "float" values passed to SQL statements. A "float" value will be associated with the :class:`.Float` datatype and not the Decimal-coercing :class:`.Numeric` datatype as was the case before, eliminating a confusing warning emitted on SQLite as well as unecessary coercion to Decimal. Change-Id: I1bb1810ff1d198c0d929ccba5656e55401d74119 Fixes: #4017
* selectin polymorphic loadingMike Bayer2017-06-052-15/+38
| | | | | | | | | | | | | Added a new style of mapper-level inheritance loading "polymorphic selectin". This style of loading emits queries for each subclass in an inheritance hierarchy subsequent to the load of the base object type, using IN to specify the desired primary key values. Fixes: #3948 Change-Id: I59e071c6142354a3f95730046e3dcdfc0e2c4de5
* Implement get_unique_constraints, get_check_constraints for OracleEloy Felix2017-05-301-1/+25
| | | | | | | | Pull-request: https://github.com/zzzeek/sqlalchemy/pull/326 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/342 Fixes: #4002 Change-Id: I221fe8ba305fc455a03e3a5d15f803bf8ee2e8fb
* Allow metadata.reflect() to recover from unreflectable tablesMike Bayer2017-05-221-4/+11
| | | | | | | | | | | | | Added support for views that are unreflectable due to stale table definitions, when calling :meth:`.MetaData.reflect`; a warning is emitted for the table that cannot respond to ``DESCRIBE`` but the operation succeeds. The MySQL dialect now raises UnreflectableTableError which is in turn caught by MetaData.reflect(). Reflecting the view standalone raises this error directly. Change-Id: Id8005219d8e073c154cc84a873df911b4a6cf4d6 Fixes: #3871
* Add new "expanding" feature to bindparam()Mike Bayer2017-04-072-1/+63
| | | | | | | | | | | | | | | | 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
* Double percent signs based on paramstyle, not dialectMike Bayer2017-04-051-1/+33
| | | | | | | | | | | | This patch moves the "doubling" of percent signs into the base compiler and makes it completely a product of whether or not the paramstyle is format/pyformat or not. Without this paramstyle, percent signs are not doubled across text(), literal_column(), and column(). Change-Id: Ie2f278ab1dbb94b5078f85c0096d74dbfa049197 Fixes: #3740
* Add safe_reraise() + warnings only to Connection._autorollbackMike Bayer2017-03-271-4/+5
| | | | | | | | | | | | Added an exception handler that will warn for the "cause" exception on Py2K when the "autorollback" feature of :class:`.Connection` itself raises an exception. In Py3K, the two exceptions are naturally reported by the interpreter as one occurring during the handling of the other. This is continuing with the series of changes for rollback failure handling that were last visited as part of :ticket:`2696` in 1.0.12. Change-Id: I600ba455a14ebaea27c6189889181f97c632f179 Fixes: #3946
* Support hybrids/composites with bulk updatesMike Bayer2017-03-221-0/+4
| | | | | | | | | | | The :meth:`.Query.update` method can now accommodate both hybrid attributes as well as composite attributes as a source of the key to be placed in the SET clause. For hybrids, an additional decorator :meth:`.hybrid_property.update_expression` is supplied for which the user supplies a tuple-returning function. Change-Id: I15e97b02381d553f30b3301308155e19128d2cfb Fixes: #3229
* Use config.db global opts as defaults for all testing_engine()Mike Bayer2017-03-221-0/+3
| | | | | | | | | | Some options need to be passed to engines in all cases, such as currently the oracle 12516 workaround. make sure calls to testing_engine also set up the dictionary with defaults even if options is passed. not clear if this affects other backends yet. Change-Id: I5a1f7634e4ce5af6fe55dc21a24db6afacd19bb7
* Integrate "pre-ping" into connection pool.Mike Bayer2017-03-201-3/+19
| | | | | | | | | | | | | | | Added native "pessimistic disconnection" handling to the :class:`.Pool` object. The new parameter :paramref:`.Pool.pre_ping`, available from the engine as :paramref:`.create_engine.pool_pre_ping`, applies an efficient form of the "pre-ping" recipe featured in the pooling documentation, which upon each connection check out, emits a simple statement, typically "SELECT 1", to test the connection for liveness. If the existing connection is no longer able to respond to commands, the connection is transparently recycled, and all other connections made prior to the current timestamp are invalidated. Change-Id: I89700d0075e60abd2250e54b9bd14daf03c71c00 Fixes: #3919
* New features from python 2.7Катаев Денис2017-03-176-11/+9
| | | | | | | After bump minimum supported version to 2.7 (1da9d3752160430c91534a8868ceb8c5ad1451d4), we can use new syntax. Change-Id: Ib064c75a00562e641d132f9c57e5e69744200e05 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/347
* Implement comments for tables, columnsFrazer McLean2017-03-172-2/+48
| | | | | | | | | | | | | | Added support for SQL comments on :class:`.Table` and :class:`.Column` objects, via the new :paramref:`.Table.comment` and :paramref:`.Column.comment` arguments. The comments are included as part of DDL on table creation, either inline or via an appropriate ALTER statement, and are also reflected back within table reflection, as well as via the :class:`.Inspector`. Supported backends currently include MySQL, Postgresql, and Oracle. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Fixes: #1546 Change-Id: Ib90683850805a2b4ee198e420dc294f32f15d35d
* Normalize Oracle reflected FK constraint nameMike Bayer2017-03-131-3/+4
| | | | | | | | | | | | | Oracle reflection now "normalizes" the name given to a foreign key constraint, that is, returns it as all lower case for a case insensitive name. This was already the behavior for indexes and primary key constraints as well as all table and column names. This will allow Alembic autogenerate scripts to compare and render foreign key constraint names correctly when initially specified as case insensitive. Change-Id: Ibb34ec6ce7cb244d1c4ae9d44ce2d37d37227e69 Fixes: #3276
* Repair _execute_scalar for WITH_UNICODE modeMike Bayer2017-03-131-0/+6
| | | | | | | | | | | | | | | | | cx_Oracle 5.3 seems to code this flag ON now, so remove the warning and ensure WITH_UNICODE handling works. Additionally, the XE setup on jenkins is having more problems here, in particular low-connections mode is causing cx_Oracle to fail more frequently now. Turning off low-connections fixes those but then we get the TNS errors, so adding an emergency "retry" flag that is not yet a feature available to users. Real world applications are not dropping/creating thousands of tables the way our test suite is. Change-Id: Ie95b0e697276c404d3264c2e624e870463d966d6 Fixes: #3937
* Support python3.6Mike Bayer2017-01-131-0/+7
| | | | | | | | | | | 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
* update for 2017 copyrightMike Bayer2017-01-0418-18/+18
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* Don't select lastrowid for inline=TrueMike Bayer2016-12-211-0/+50
| | | | | | | | | | | - Fixed bug where SQL Server dialects would attempt to select the last row identity for an INSERT from SELECT, failing in the case when the SELECT has no rows. For such a statement, the inline flag is set to True indicating no last primary key should be fetched. Change-Id: Ic40d56d9eadadc3024a4d71245f9eed4c420024a Fixes: #3876
* Ensure Variant passes along impl right-hand typeMike Bayer2016-11-221-6/+53
| | | | | | | | | | | | | | | | | | | Fixed issue in :class:`.Variant` where the "right hand coercion" logic, inherited from :class:`.TypeDecorator`, would coerce the right-hand side into the :class:`.Variant` itself, rather than what the default type for the :class:`.Variant` would do. In the case of :class:`.Variant`, we want the type to act mostly like the base type so the default logic of :class:`.TypeDecorator` is now overridden to fall back to the underlying wrapped type's logic. Is mostly relevant for JSON at the moment. This patch additionally adds documentation and basic tests to allow for backend-agnostic comparison of JSON index elements to other objects. A future version should attempt to improve upon this by providing "astext", "asint" types of operators. Change-Id: I7b7b45d604a4ae8d1dc236a5a1248695aab5232e Fixes: #3859
* Port lower case quoted name fix to firebirdMike Bayer2016-11-161-1/+39
| | | | | | | | | | | | | | Ported the fix for Oracle quoted-lowercase names to Firebird, so that a table name that is quoted as lower case can be reflected properly including when the table name comes from the get_table_names() inspection function. Also genericize the test to the test suite for denormlized name dialects. Fixes: #3548 Change-Id: I8ca62e8d2b359e363ccb01cfe2daa0995354a3cb
* Add support for server side cursors to mysqldb and pymysqlRoman Podoliaka2016-11-102-1/+156
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows to skip buffering of the results on the client side, e.g. the following snippet: table = sa.Table( 'testtbl', sa.MetaData(), sa.Column('id', sa.Integer, primary_key=True), sa.Column('a', sa.Integer), sa.Column('b', sa.String(512)) ) table.create(eng, checkfirst=True) with eng.connect() as conn: result = conn.execute(table.select().limit(1)).fetchone() if result is None: for _ in range(1000): conn.execute( table.insert(), [{'a': random.randint(1, 100000), 'b': ''.join(random.choice(string.ascii_letters) for _ in range(100))} for _ in range(1000)] ) with eng.connect() as conn: for row in conn.execution_options(stream_results=True).execute(table.select()): pass now uses ~23 MB of memory instead of ~327 MB on CPython 3.5.2 and PyMySQL 0.7.9. psycopg2 implementation and execution options (stream_results, server_side_cursors) are reused. Change-Id: I4dc23ce3094f027bdff51b896b050361991c62e2
* spelling: Postgresql -> PostgreSQLVille Skyttä2016-10-082-3/+3
|
* Additions to support HAAlchemy pluginMike Bayer2016-09-164-8/+56
| | | | | | | | | | | | | | | | | | | - add a connect=True key to connection record to support pre-loading of _ConnectionRecord objects - ensure _ConnectionRecord.close() leaves the record in a good state for reopening - add _ConnectionRecord.record_info for persistent storage - add "in_use" accessor based on fairy_ref being present or not - allow for the exclusions system and SuiteRequirements to be usable without the full plugin_base setup. - move some Python-env requirements to the importable requirements.py module. - allow starttime to be queried - add additional events for engine plugins - have "dialect" be a first-class parameter to the pool, ensure the engine strategy supplies it up front Change-Id: Ibf549f7a1766e49d335cd6f5e26bacfaef9a8229