summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/suite
Commit message (Collapse)AuthorAgeFilesLines
* 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-101-0/+30
|\
| * Skip expression-based index reflection for SQLiteMike Bayer2019-01-091-0/+30
| | | | | | | | | | | | | | | | | | | | | | 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-0611-107/+159
| | | | | | | | | | | | | 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-0611-1417/+1403
| | | | | | | | | | | | | | 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
* 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
* Add test support for #4036Mike Bayer2018-08-161-8/+21
| | | | | | | 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
* Use utf8mb4 (or utf8mb3) for all things MySQLMike Bayer2018-06-251-0/+4
| | | | | | | | | | | | | | | | | 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-183-0/+196
| | | | | | | | | | | | | | | | 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
* 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
* Support foreign key option reflection for OracleMiroslav Shubernetskiy2018-02-051-4/+11
| | | | | | | | | 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-121-0/+40
|\
| * Make column-level collation quoting dialect-specificMike Bayer2018-01-121-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | 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-081-2/+9
|/ | | | | | | | | 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-041-0/+1
|\
| * Add rule to prevent "GROUP BY <expr>" in testsMike Bayer2018-01-041-0/+1
| | | | | | | | | | | | | | | | 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
* 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-281-0/+45
| | | | | | | | | | | 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
* Refactor for cx_Oracle version 6oracle_numericMike Bayer2017-09-111-2/+1
| | | | | | | | | 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-311-0/+1
| | | | Change-Id: Ida0d01ae9bcc0573b86e24fddea620a38c962822
* Generalize autocommit testingMike Bayer2017-08-291-0/+43
| | | | | | | 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
* - correct server side cursor assertion for driver namesMike Bayer2017-08-191-5/+5
| | | | Change-Id: Id8156f6af15a36f7d5653dff56f68e81431692a6
* 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
* 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
* 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
* Add new "expanding" feature to bindparam()Mike Bayer2017-04-071-1/+55
| | | | | | | | | | | | | | | | 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
* New features from python 2.7Катаев Денис2017-03-172-2/+2
| | | | | | | 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-171-2/+44
| | | | | | | | | | | | | | 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
* 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