summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing
Commit message (Collapse)AuthorAgeFilesLines
* happy new yearMike Bayer2019-01-1118-18/+18
| | | | Change-Id: I6a71f4924d046cf306961c58dffccf21e9c03911
* Leave bytestring exception messages as bytestringsMike Bayer2019-01-101-0/+25
| | | | | | | | | | | | | | | | | Fixed a regression introduced in version 1.2 where a refactor of the :class:`.SQLAlchemyError` base exception class introduced an inappropriate coercion of a plain string message into Unicode under python 2k, which is not handled by the Python interpreter for characters outside of the platform's encoding (typically ascii). The :class:`.SQLAlchemyError` class now passes a bytestring through under Py2K for ``__str__()`` as is the behavior of exception objects in general under Py2K, does a safe coercion to unicode utf-8 with backslash fallback for ``__unicode__()``. For Py3K the message is typically unicode already, but if not is again safe-coerced with utf-8 with backslash fallback for the ``__str__()`` method. Fixes: #4429 Change-Id: I2289da3f2c45c7d0041fa43d838958f7614defc3
* Merge "Skip expression-based index reflection for SQLite"mike bayer2019-01-102-0/+35
|\
| * Skip expression-based index reflection for SQLiteMike Bayer2019-01-092-0/+35
| | | | | | | | | | | | | | | | | | | | | | Reflection of an index based on SQL expressions are now skipped with a warning, in the same way as that of the Postgresql dialect, where we currently do not support reflecting indexes that have SQL expressions within them. Previously, an index with columns of None were produced which would break tools like Alembic. Fixes: #4431 Change-Id: I1363ade912d206b42669331e2be2bb6f444b65a2
* | Render correct DDL for unsetting table commentsMike Bayer2019-01-091-0/+24
|/ | | | | | | | | Fixed issue where the DDL emitted for :class:`.DropTableComment`, which will be used by an upcoming version of Alembic, was incorrect for the MySQL and Oracle databases. Fixes: #4436 Change-Id: I196de09495a37adface4caa9dcbc29a6d0ad159a
* Post black reformattingMike Bayer2019-01-0631-249/+347
| | | | | | | | | | | | | Applied on top of a pure run of black -l 79 in I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9, this set of changes resolves all remaining flake8 conditions for those codes we have enabled in setup.cfg. Included are resolutions for all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I4f72d3ba1380dd601610ff80b8fb06a2aff8b0fe
* Run black -l 79 against all source filesMike Bayer2019-01-0633-2114/+2399
| | | | | | | | | | | | | | This is a straight reformat run using black as is, with no edits applied at all. The black run will format code consistently, however in some cases that are prevalent in SQLAlchemy code it produces too-long lines. The too-long lines will be resolved in the following commit that will resolve all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9
* Assorted pre-Black fixesMike Bayer2019-01-053-9/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes to the test suite, a few errant imports, and setup.py: - mysql and postgresql have unused 'json' imports; remove - postgresql is exporting the 'json' symbol, remove - make sure setup.py can find __version__ using " or ' - retry logic in provision create database for postgresql fixed - refactor test_magazine to use cls.tables rather than globals - remove unused class in test_scoping - add a comment to test_deprecations that this test suite itself is deprecated - don't use mapper() and orm_mapper() in test_unitofwork, just use mapper() - remove dupe test_scalar_set_None test in test_attributes - Python 2.7 and above includes unittest.SkipTest, remove pre-2.7 fallback - use imported SkipTest in profiling - declarative test_reflection tests with "reflectable_autoincrement" already don't run on oracle or firebird; remove conditional logic for these, which also removes an "id" symbol - clean up test in test_functions, remove print statement - remove dupe test_literal_processor_coercion_native_int_out_of_range in test/sql/test_types.py - fix psycopg2_hstore ref Change-Id: I7b3444f8546aac82be81cd1e7b6d8b2ad6834fe6
* rework the exclusions spec expressionMike Bayer2018-12-311-12/+18
| | | | | | | The expression was expecting spaces which means we were skipping Postgresql window function tests and possibly other things. Change-Id: I57c4aed558f4011f2f7b882a2d9b1fee210f9eaf
* commit 1b774808c926665047bf353222ecd191679a95d1Lele Gaifax2018-12-301-1/+1
| | | | | | | | | | | | | | | Author: Lele Gaifax <lele@metapensiero.it> Date: Tue Dec 25 12:35:41 2018 +0100 Consistently use "PostgreSQL", fixing also a few doc glitches commit 0e382aaee4427193926f0dc10ad29056bc12c85e Author: Lele Gaifax <lele@metapensiero.it> Date: Tue Dec 25 12:08:49 2018 +0100 Remove duplicated words Change-Id: Iaa586b9412f46a50fe6ff3bbb92e07d6cb1905c8
* Don't call rollback on DBAPI connection that's "closed"Mike Bayer2018-10-141-0/+6
| | | | | | | | | | Use the existence of ConnectionRecord.connection to estimate that this connection is likely closed, and if so, don't try to call "rollback" on it. This rollback is normally harmless but is causing segfaults in mysqlclient due to https://github.com/PyMySQL/mysqlclient-python/issues/270. Change-Id: I1d7c5f5a520527d8268b6334795c2051f7ceeea6
* Support tuples of heterogeneous types for empty expanding INMike Bayer2018-10-031-0/+42
| | | | | | | | | Pass a list of all the types for the left side of an IN expression to the visit_empty_set_expr() method, so that the "empty expanding IN" can produce clauses for each element. Fixes: #4271 Change-Id: I2738b9df2292ac01afda37f16d4fa56ae7bf9147
* MariaDB 10.3 updatesMike Bayer2018-08-301-2/+2
| | | | | | | | | MariaDB seems to handle some additional UPDATE/DELETE FROM syntaxes as well as some forms of INTERSECT and EXCEPT. Open up tests that expect failure for MySQL to allow success for MariaDB 10.3. Change-Id: Ia9341a82485ef7201bb8130d8dbf4a9b6976035a
* Add test support for #4036Mike Bayer2018-08-162-8/+42
| | | | | | | Add a test that asserts MySQL can't implicitly treat a decimal bound parameter without context and everyone else can. Change-Id: I40e24a463d6eb03fd677195895891e73624776c3
* Add support of empty list in exanding of bindparamNicolas Rolin2018-08-071-8/+95
| | | | | | | | | | | Added new logic to the "expanding IN" bound parameter feature whereby if the given list is empty, a special "empty set" expression that is specific to different backends is generated, thus allowing IN expressions to be fully dynamic including empty IN expressions. Fixes: #4271 Change-Id: Icc3c73bbd6005206b9d06baaeb14a097af5edd36 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/432
* Bind Integers to int for cx_OracleMike Bayer2018-08-011-1/+35
| | | | | | | | | For cx_Oracle, Integer datatypes will now be bound to "int", per advice from the cx_Oracle developers. Previously, using cx_Oracle.NUMBER caused a loss in precision within the cx_Oracle 6.x series. Change-Id: I4c6b2cca490aff5b98b7ceff3414715202881c89 Fixes: #4309
* Add unique_constraint_name to MSSQL FK reflectionSean Dunn2018-06-291-0/+1
| | | | | | | | | | | Fixed bug in MSSQL reflection where when two same-named tables in different schemas had same-named primary key constraints, foreign key constraints referring to one of the tables would have their columns doubled, causing errors. Pull request courtesy Sean Dunn. Fixes: #4228 Change-Id: I7dabaaee0944e1030048826ba39fc574b0d63031 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/457
* Use utf8mb4 (or utf8mb3) for all things MySQLMike Bayer2018-06-253-4/+15
| | | | | | | | | | | | | | | | | Fixed bug in MySQLdb dialect and variants such as PyMySQL where an additional "unicode returns" check upon connection makes explicit use of the "utf8" character set, which in MySQL 8.0 emits a warning that utf8mb4 should be used. This is now replaced with a utf8mb4 equivalent. Documentation is also updated for the MySQL dialect to specify utf8mb4 in all examples. Additional changes have been made to the test suite to use utf8mb3 charsets and databases (there seem to be collation issues in some edge cases with utf8mb4), and to support configuration default changes made in MySQL 8.0 such as explicit_defaults_for_timestamp as well as new errors raised for invalid MyISAM indexes. Change-Id: Ib596ea7de4f69f976872a33bffa4c902d17dea25 Fixes: #4283 Fixes: #4192
* render WITH clause after INSERT for INSERT..SELECT on Oracle, MySQLMike Bayer2018-06-184-1/+206
| | | | | | | | | | | | | | | | Fixed INSERT FROM SELECT with CTEs for the Oracle and MySQL dialects, where the CTE was being placed above the entire statement as is typical with other databases, however Oracle and MariaDB 10.2 wants the CTE underneath the "INSERT" segment. Note that the Oracle and MySQL dialects don't yet work when a CTE is applied to a subquery inside of an UPDATE or DELETE statement, as the CTE is still applied to the top rather than inside the subquery. Also adds test suite support CTEs against backends. Change-Id: I8ac337104d5c546dd4f0cd305632ffb56ac8bf90 Fixes: #4275 Fixes: #4230
* Add Query.lazy_load_from attribute for shardingMike Bayer2018-06-041-0/+15
| | | | | | | | | | | | | | | | | | Added new attribute :attr:`.Query.lazy_loaded_from` which is populated with an :class:`.InstanceState` that is using this :class:`.Query` in order to lazy load a relationship. The rationale for this is that it serves as a hint for the horizontal sharding feature to use, such that the identity token of the state can be used as the default identity token to use for the query within id_chooser(). Also repaired an issue in the :meth:`.Result.with_post_criteria` method added in I899808734458e25a023142c2c5bb37cbed869479 for :ticket:`4128` where the "unbake subquery loaders" version was calling the post crtieria functions given the :class:`.Result` as the argument rather than applying them to the :class:`.Query`. Change-Id: I3c0919ce7fd151b80fe2f9b5f99f60df31c2d73d Fixes: #4243
* Merge "Default server_version_info to (0, )"mike bayer2018-05-112-2/+4
|\
| * Default server_version_info to (0, )Mike Bayer2018-05-112-2/+4
| | | | | | | | | | | | | | | | | | Fixed a bug in the test suite where if an external dialect returned ``None`` for ``server_version_info``, the exclusion logic would raise an ``AttributeError``. Change-Id: I9124d3ac5484941081127274e6eb71f392fb94f7 Fixes: #4249
* | SQL Server is not native boolean; add new flag for CHECK constraintMike Bayer2018-05-101-0/+42
|/ | | | | | | | | | | | | | Fixed a 1.2 regression caused by :ticket:`4061` where the SQL Server "BIT" type would be considered to be "native boolean". The goal here was to avoid creating a CHECK constraint on the column, however the bigger issue is that the BIT value does not behave like a true/false constant and cannot be interpreted as a standalone expression, e.g. "WHERE <column>". The SQL Server dialect now goes back to being non-native boolean, but with an extra flag that still avoids creating the CHECK constraint. Change-Id: I4765d2a2a00b0d14f50282603cc4d48d4739dac1 Fixes: #4250
* Fix - Order of records is not guaranteedPat Buxton2018-04-161-3/+3
| | | | | | | | | * Causes intermittent failure against Greenplum cluster * Tested using Greenplum dialact: https://github.com/PlaidCloud/sqlalchemy-greenplum Change-Id: I6387e98f17a3667612fdaaadb27a08f79ec46398 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/440
* Correct join for FKs with schema in SQL ServerMike Bayer2018-04-111-1/+74
| | | | | | | | | | | | | Fixed 1.2 regression caused by :ticket:`4060` where the query used to reflect SQL Server cross-schema foreign keys was limiting the criteria incorrectly. Additionally, added some rework of the inter-schema reflection tests so that MySQL, MSSQL can be included, breaking out some of the Postgresql-specific behaviors into separate requirements. Fixes: #4234 Change-Id: I20c8e70707075f1767b79127c2c27d4b313c6515
* Ensure all visit_sequence accepts **kw argsMike Bayer2018-04-041-1/+23
| | | | | | | | | | Fixed issue where the compilation of an INSERT statement with the "literal_binds" option that also uses an explicit sequence and "inline" generation, as on Postgresql and Oracle, would fail to accommodate the extra keyword argument within the sequence processing routine. Change-Id: Ibdab7d340aea7429a210c9535ccf1a3e85f074fb Fixes: #4231
* Remove erroneous skip messageMike Bayer2018-02-161-18/+14
| | | | | | | | | The logic here seems to try to say something different when __backend__ is True but it produces a nonsensical message, since __only_on__ doesn't tell us about the implementation we are actually running. Change-Id: I14e20cadcba975f8efe8fdefa439c8b8c480b3ed
* Support foreign key option reflection for OracleMiroslav Shubernetskiy2018-02-052-5/+16
| | | | | | | | | The ON DELETE options for foreign keys are now part of Oracle reflection. Oracle does not support ON UPDATE cascades. Pull request courtesy Miroslav Shubernetskiy. Change-Id: I135cd6cd3436354a86b2c1e1437c3785c38eed26 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/418
* Normalize check constraints even more radicallyFlorian Apolloner2018-01-171-4/+7
| | | | | | | | | | | | | This is the only way I could get this test pass on informix, basically I strip every whitespace. The sql text as recorded in informix is: ``` ((a > 1 ) AND (a < 5 ) ) ((a = 1 ) OR ((a > 2 ) AND (a <5 ) ) ) ``` Yes, this is absolutely bonkers, but that is what I get :( Change-Id: I936e860f2b75b521e5560c05c452dbe72f0d3812 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/413
* Merge "Make column-level collation quoting dialect-specific"mike bayer2018-01-122-0/+54
|\
| * Make column-level collation quoting dialect-specificMike Bayer2018-01-122-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixed regression in 1.2 where newly repaired quoting of collation names in :ticket:`3785` breaks SQL Server, which explicitly does not understand a quoted collation name. Whether or not mixed-case collation names are quoted or not is now deferred down to a dialect-level decision so that each dialect can prepare these identifiers directly. Change-Id: Iaf0a8123d9bf4711219e320896bb28c5d2649304 Fixes: #4154
* | happy new yearMike Bayer2018-01-1218-18/+18
| | | | | | | | Change-Id: I3ef36bfd0cb0ba62b3123c8cf92370a43156cf8f
* | Merge "Turn on testing for JSON under Mariadb 10.2.7 and greater"mike bayer2018-01-121-11/+14
|\ \
| * | Turn on testing for JSON under Mariadb 10.2.7 and greaterMike Bayer2018-01-121-11/+14
| |/ | | | | | | | | | | | | | | | | | | | | MariaDB adds a JSON alias for the LONGTEXT datatype and all the same json functions work against it in any case. What doesn't work is reflection, since it's just an alias, and also the CAST we were using in one of our tests doesn't seem to work for JSON which is probably also because it's not a real datatype. Change-Id: I44e5503db29ca2f04de8e521527978f34675a5e0
* | Re-enable setinputsizes for Oracle TIMESTAMPMike Bayer2018-01-082-2/+16
|/ | | | | | | | | Fixed regression where the removal of most setinputsizes rules from cx_Oracle dialect impacted the TIMESTAMP datatype's ability to retrieve fractional seconds. Fixes: #4157 Change-Id: Ic53109fd199aea8b9c4da14355e125849b8b198f
* Merge "Add rule to prevent "GROUP BY <expr>" in tests"mike bayer2018-01-042-0/+12
|\
| * Add rule to prevent "GROUP BY <expr>" in testsMike Bayer2018-01-042-0/+12
| | | | | | | | | | | | | | | | Added a new exclusion rule group_by_complex_expression which disables tests that use "GROUP BY <expr>", which seems to be not viable for at least two third party dialects. Change-Id: I47284513382ae93f5a3d12c734b3a44643147c99
* | Remove cx_oracle test rule from requirementsMike Bayer2018-01-041-1/+0
|/ | | | | | | | Removed an oracle-specific requirements rule from the public test suite that was interfering with third party dialect suites. Change-Id: Iebae510edcb8ef908dcd9be9222888e12caed97d
* Open up all cx_Oracle numeric tests, finish infinity supportMike Bayer2017-12-171-16/+0
| | | | | | | | | | | | Added some additional rules to fully handle ``Decimal('Infinity')``, ``Decimal('-Infinity')`` values with cx_Oracle numerics when using ``asdecimal=True``. Allow remaining cx_Oracle numeric tests that were waiting for the refactor to be finished and forgot to get enabled. Change-Id: I1e2365176e34559c0230c84f800a7cfe0a034ed5 Fixes: #4064
* Allow delete where clause to refer multiple tables.inytar2017-12-051-0/+5
| | | | | | | | | | | | | | | | | | | | | Implemented "DELETE..FROM" syntax for Postgresql, MySQL, MS SQL Server (as well as within the unsupported Sybase dialect) in a manner similar to how "UPDATE..FROM" works. A DELETE statement that refers to more than one table will switch into "multi-table" mode and render the appropriate "USING" or multi-table "FROM" clause as understood by the database. Pull request courtesy Pieter Mulder. For SQL syntaxes see: Postgresql: https://www.postgresql.org/docs/current/static/sql-delete.html MySQL: https://dev.mysql.com/doc/refman/5.7/en/delete.html#multiple-table_syntax MSSQL: https://docs.microsoft.com/en-us/sql/t-sql/statements/delete-transact-sql Sybase: http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc00801.1510/html/iqrefso/X315721.htm Co-authored by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: I6dfd57b49e44a095d076dc493cd2360bb5d920d3 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/392 Fixes: #959
* Rework autoescape to be a simple boolean; escape the escape characterMike Bayer2017-10-241-0/+105
| | | | | | | | | | | | Reworked the new "autoescape" feature introduced in :ref:`change_2694` in 1.2.0b2 to be fully automatic; the escape character now defaults to a forwards slash ``"/"`` and is applied to percent, underscore, as well as the escape character itself, for fully automatic escaping. The character can also be changed using the "escape" parameter. Change-Id: I74894a2576983c0f6eb89480c9e5727f49fa9c25 Fixes: #2694
* Merge "Don't commit failed transaction"mike bayer2017-10-201-1/+5
|\
| * Don't commit failed transactionMike Bayer2017-10-181-1/+5
| | | | | | | | | | | | | | | | | | | | The test here commits even though integrityerror was raised due to the fixture. Postgresql seems to allow this even though it's usually strict about this. remove the requirement that a database needs to be able to commit after an integrity error was raised. Change-Id: I437faadb04ff7a9c3f624c68646b4f4f504b504a
* | add order_by clause to make tests stableJan2017-10-171-2/+2
|/ | | | | | | I observed test runs that failed on 'test_bound_in_scalar' due to arbitrary ordering of the result set. The assertion not only tests for the elements to be present, but also for the correct ordering. Hence, the proposal to add an order_by clause to the select statements. Change-Id: If1fbb864761e77dfd2a42ef857801c8aaf893bee Pull-request: https://github.com/zzzeek/sqlalchemy/pull/389
* Take schema name into account when querying sqlite_masterMike Bayer2017-09-282-0/+50
| | | | | | | | | | | Fixed bug where SQLite CHECK constraint reflection would fail if the referenced table were in a remote schema, e.g. on SQLite a remote database referred to by ATTACH. Also add suite support for general CHECK constraint reflection. Change-Id: I073a72cb47dc4f8c5683000d708768523759332f Fixes: #4099
* Fix noseplugin to accept `zeroarg_callback` for `--dbs` optionIryna Shcherbina2017-09-261-1/+1
| | | ./sqla_nose.py --dbs works fine with zero arguments, so `zeroarg_callback` should be treated as `callback`.
* 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