You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1427 lines
40KB

  1. # testing/requirements.py
  2. # Copyright (C) 2005-2021 the SQLAlchemy authors and contributors
  3. # <see AUTHORS file>
  4. #
  5. # This module is part of SQLAlchemy and is released under
  6. # the MIT License: http://www.opensource.org/licenses/mit-license.php
  7. """Global database feature support policy.
  8. Provides decorators to mark tests requiring specific feature support from the
  9. target database.
  10. External dialect test suites should subclass SuiteRequirements
  11. to provide specific inclusion/exclusions.
  12. """
  13. import platform
  14. import sys
  15. from . import exclusions
  16. from . import only_on
  17. from .. import util
  18. from ..pool import QueuePool
  19. class Requirements(object):
  20. pass
  21. class SuiteRequirements(Requirements):
  22. @property
  23. def create_table(self):
  24. """target platform can emit basic CreateTable DDL."""
  25. return exclusions.open()
  26. @property
  27. def drop_table(self):
  28. """target platform can emit basic DropTable DDL."""
  29. return exclusions.open()
  30. @property
  31. def table_ddl_if_exists(self):
  32. """target platform supports IF NOT EXISTS / IF EXISTS for tables."""
  33. return exclusions.closed()
  34. @property
  35. def index_ddl_if_exists(self):
  36. """target platform supports IF NOT EXISTS / IF EXISTS for indexes."""
  37. return exclusions.closed()
  38. @property
  39. def foreign_keys(self):
  40. """Target database must support foreign keys."""
  41. return exclusions.open()
  42. @property
  43. def table_value_constructor(self):
  44. """Database / dialect supports a query like::
  45. SELECT * FROM VALUES ( (c1, c2), (c1, c2), ...)
  46. AS some_table(col1, col2)
  47. SQLAlchemy generates this with the :func:`_sql.values` function.
  48. """
  49. return exclusions.closed()
  50. @property
  51. def standard_cursor_sql(self):
  52. """Target database passes SQL-92 style statements to cursor.execute()
  53. when a statement like select() or insert() is run.
  54. A very small portion of dialect-level tests will ensure that certain
  55. conditions are present in SQL strings, and these tests use very basic
  56. SQL that will work on any SQL-like platform in order to assert results.
  57. It's normally a given for any pep-249 DBAPI that a statement like
  58. "SELECT id, name FROM table WHERE some_table.id=5" will work.
  59. However, there are dialects that don't actually produce SQL Strings
  60. and instead may work with symbolic objects instead, or dialects that
  61. aren't working with SQL, so for those this requirement can be marked
  62. as excluded.
  63. """
  64. return exclusions.open()
  65. @property
  66. def on_update_cascade(self):
  67. """target database must support ON UPDATE..CASCADE behavior in
  68. foreign keys."""
  69. return exclusions.open()
  70. @property
  71. def non_updating_cascade(self):
  72. """target database must *not* support ON UPDATE..CASCADE behavior in
  73. foreign keys."""
  74. return exclusions.closed()
  75. @property
  76. def deferrable_fks(self):
  77. return exclusions.closed()
  78. @property
  79. def on_update_or_deferrable_fks(self):
  80. # TODO: exclusions should be composable,
  81. # somehow only_if([x, y]) isn't working here, negation/conjunctions
  82. # getting confused.
  83. return exclusions.only_if(
  84. lambda: self.on_update_cascade.enabled
  85. or self.deferrable_fks.enabled
  86. )
  87. @property
  88. def queue_pool(self):
  89. """target database is using QueuePool"""
  90. def go(config):
  91. return isinstance(config.db.pool, QueuePool)
  92. return exclusions.only_if(go)
  93. @property
  94. def self_referential_foreign_keys(self):
  95. """Target database must support self-referential foreign keys."""
  96. return exclusions.open()
  97. @property
  98. def foreign_key_ddl(self):
  99. """Target database must support the DDL phrases for FOREIGN KEY."""
  100. return exclusions.open()
  101. @property
  102. def named_constraints(self):
  103. """target database must support names for constraints."""
  104. return exclusions.open()
  105. @property
  106. def subqueries(self):
  107. """Target database must support subqueries."""
  108. return exclusions.open()
  109. @property
  110. def offset(self):
  111. """target database can render OFFSET, or an equivalent, in a
  112. SELECT.
  113. """
  114. return exclusions.open()
  115. @property
  116. def bound_limit_offset(self):
  117. """target database can render LIMIT and/or OFFSET using a bound
  118. parameter
  119. """
  120. return exclusions.open()
  121. @property
  122. def sql_expression_limit_offset(self):
  123. """target database can render LIMIT and/or OFFSET with a complete
  124. SQL expression, such as one that uses the addition operator.
  125. parameter
  126. """
  127. return exclusions.open()
  128. @property
  129. def parens_in_union_contained_select_w_limit_offset(self):
  130. """Target database must support parenthesized SELECT in UNION
  131. when LIMIT/OFFSET is specifically present.
  132. E.g. (SELECT ...) UNION (SELECT ..)
  133. This is known to fail on SQLite.
  134. """
  135. return exclusions.open()
  136. @property
  137. def parens_in_union_contained_select_wo_limit_offset(self):
  138. """Target database must support parenthesized SELECT in UNION
  139. when OFFSET/LIMIT is specifically not present.
  140. E.g. (SELECT ... LIMIT ..) UNION (SELECT .. OFFSET ..)
  141. This is known to fail on SQLite. It also fails on Oracle
  142. because without LIMIT/OFFSET, there is currently no step that
  143. creates an additional subquery.
  144. """
  145. return exclusions.open()
  146. @property
  147. def boolean_col_expressions(self):
  148. """Target database must support boolean expressions as columns"""
  149. return exclusions.closed()
  150. @property
  151. def nullable_booleans(self):
  152. """Target database allows boolean columns to store NULL."""
  153. return exclusions.open()
  154. @property
  155. def nullsordering(self):
  156. """Target backends that support nulls ordering."""
  157. return exclusions.closed()
  158. @property
  159. def standalone_binds(self):
  160. """target database/driver supports bound parameters as column expressions
  161. without being in the context of a typed column.
  162. """
  163. return exclusions.closed()
  164. @property
  165. def standalone_null_binds_whereclause(self):
  166. """target database/driver supports bound parameters with NULL in the
  167. WHERE clause, in situations where it has to be typed.
  168. """
  169. return exclusions.open()
  170. @property
  171. def intersect(self):
  172. """Target database must support INTERSECT or equivalent."""
  173. return exclusions.closed()
  174. @property
  175. def except_(self):
  176. """Target database must support EXCEPT or equivalent (i.e. MINUS)."""
  177. return exclusions.closed()
  178. @property
  179. def window_functions(self):
  180. """Target database must support window functions."""
  181. return exclusions.closed()
  182. @property
  183. def ctes(self):
  184. """Target database supports CTEs"""
  185. return exclusions.closed()
  186. @property
  187. def ctes_with_update_delete(self):
  188. """target database supports CTES that ride on top of a normal UPDATE
  189. or DELETE statement which refers to the CTE in a correlated subquery.
  190. """
  191. return exclusions.closed()
  192. @property
  193. def ctes_on_dml(self):
  194. """target database supports CTES which consist of INSERT, UPDATE
  195. or DELETE *within* the CTE, e.g. WITH x AS (UPDATE....)"""
  196. return exclusions.closed()
  197. @property
  198. def autoincrement_insert(self):
  199. """target platform generates new surrogate integer primary key values
  200. when insert() is executed, excluding the pk column."""
  201. return exclusions.open()
  202. @property
  203. def fetch_rows_post_commit(self):
  204. """target platform will allow cursor.fetchone() to proceed after a
  205. COMMIT.
  206. Typically this refers to an INSERT statement with RETURNING which
  207. is invoked within "autocommit". If the row can be returned
  208. after the autocommit, then this rule can be open.
  209. """
  210. return exclusions.open()
  211. @property
  212. def group_by_complex_expression(self):
  213. """target platform supports SQL expressions in GROUP BY
  214. e.g.
  215. SELECT x + y AS somelabel FROM table GROUP BY x + y
  216. """
  217. return exclusions.open()
  218. @property
  219. def sane_rowcount(self):
  220. return exclusions.skip_if(
  221. lambda config: not config.db.dialect.supports_sane_rowcount,
  222. "driver doesn't support 'sane' rowcount",
  223. )
  224. @property
  225. def sane_multi_rowcount(self):
  226. return exclusions.fails_if(
  227. lambda config: not config.db.dialect.supports_sane_multi_rowcount,
  228. "driver %(driver)s %(doesnt_support)s 'sane' multi row count",
  229. )
  230. @property
  231. def sane_rowcount_w_returning(self):
  232. return exclusions.fails_if(
  233. lambda config: not (
  234. config.db.dialect.supports_sane_rowcount_returning
  235. ),
  236. "driver doesn't support 'sane' rowcount when returning is on",
  237. )
  238. @property
  239. def empty_inserts(self):
  240. """target platform supports INSERT with no values, i.e.
  241. INSERT DEFAULT VALUES or equivalent."""
  242. return exclusions.only_if(
  243. lambda config: config.db.dialect.supports_empty_insert
  244. or config.db.dialect.supports_default_values
  245. or config.db.dialect.supports_default_metavalue,
  246. "empty inserts not supported",
  247. )
  248. @property
  249. def empty_inserts_executemany(self):
  250. """target platform supports INSERT with no values, i.e.
  251. INSERT DEFAULT VALUES or equivalent, within executemany()"""
  252. return self.empty_inserts
  253. @property
  254. def insert_from_select(self):
  255. """target platform supports INSERT from a SELECT."""
  256. return exclusions.open()
  257. @property
  258. def full_returning(self):
  259. """target platform supports RETURNING completely, including
  260. multiple rows returned.
  261. """
  262. return exclusions.only_if(
  263. lambda config: config.db.dialect.full_returning,
  264. "%(database)s %(does_support)s 'RETURNING of multiple rows'",
  265. )
  266. @property
  267. def insert_executemany_returning(self):
  268. """target platform supports RETURNING when INSERT is used with
  269. executemany(), e.g. multiple parameter sets, indicating
  270. as many rows come back as do parameter sets were passed.
  271. """
  272. return exclusions.only_if(
  273. lambda config: config.db.dialect.insert_executemany_returning,
  274. "%(database)s %(does_support)s 'RETURNING of "
  275. "multiple rows with INSERT executemany'",
  276. )
  277. @property
  278. def returning(self):
  279. """target platform supports RETURNING for at least one row.
  280. .. seealso::
  281. :attr:`.Requirements.full_returning`
  282. """
  283. return exclusions.only_if(
  284. lambda config: config.db.dialect.implicit_returning,
  285. "%(database)s %(does_support)s 'RETURNING of a single row'",
  286. )
  287. @property
  288. def tuple_in(self):
  289. """Target platform supports the syntax
  290. "(x, y) IN ((x1, y1), (x2, y2), ...)"
  291. """
  292. return exclusions.closed()
  293. @property
  294. def tuple_in_w_empty(self):
  295. """Target platform tuple IN w/ empty set"""
  296. return self.tuple_in
  297. @property
  298. def duplicate_names_in_cursor_description(self):
  299. """target platform supports a SELECT statement that has
  300. the same name repeated more than once in the columns list."""
  301. return exclusions.open()
  302. @property
  303. def denormalized_names(self):
  304. """Target database must have 'denormalized', i.e.
  305. UPPERCASE as case insensitive names."""
  306. return exclusions.skip_if(
  307. lambda config: not config.db.dialect.requires_name_normalize,
  308. "Backend does not require denormalized names.",
  309. )
  310. @property
  311. def multivalues_inserts(self):
  312. """target database must support multiple VALUES clauses in an
  313. INSERT statement."""
  314. return exclusions.skip_if(
  315. lambda config: not config.db.dialect.supports_multivalues_insert,
  316. "Backend does not support multirow inserts.",
  317. )
  318. @property
  319. def implements_get_lastrowid(self):
  320. """target dialect implements the executioncontext.get_lastrowid()
  321. method without reliance on RETURNING.
  322. """
  323. return exclusions.open()
  324. @property
  325. def emulated_lastrowid(self):
  326. """target dialect retrieves cursor.lastrowid, or fetches
  327. from a database-side function after an insert() construct executes,
  328. within the get_lastrowid() method.
  329. Only dialects that "pre-execute", or need RETURNING to get last
  330. inserted id, would return closed/fail/skip for this.
  331. """
  332. return exclusions.closed()
  333. @property
  334. def emulated_lastrowid_even_with_sequences(self):
  335. """target dialect retrieves cursor.lastrowid or an equivalent
  336. after an insert() construct executes, even if the table has a
  337. Sequence on it.
  338. """
  339. return exclusions.closed()
  340. @property
  341. def dbapi_lastrowid(self):
  342. """target platform includes a 'lastrowid' accessor on the DBAPI
  343. cursor object.
  344. """
  345. return exclusions.closed()
  346. @property
  347. def views(self):
  348. """Target database must support VIEWs."""
  349. return exclusions.closed()
  350. @property
  351. def schemas(self):
  352. """Target database must support external schemas, and have one
  353. named 'test_schema'."""
  354. return only_on(lambda config: config.db.dialect.supports_schemas)
  355. @property
  356. def cross_schema_fk_reflection(self):
  357. """target system must support reflection of inter-schema
  358. foreign keys"""
  359. return exclusions.closed()
  360. @property
  361. def foreign_key_constraint_name_reflection(self):
  362. """Target supports refleciton of FOREIGN KEY constraints and
  363. will return the name of the constraint that was used in the
  364. "CONSTRANT <name> FOREIGN KEY" DDL.
  365. MySQL prior to version 8 and MariaDB prior to version 10.5
  366. don't support this.
  367. """
  368. return exclusions.closed()
  369. @property
  370. def implicit_default_schema(self):
  371. """target system has a strong concept of 'default' schema that can
  372. be referred to implicitly.
  373. basically, PostgreSQL.
  374. """
  375. return exclusions.closed()
  376. @property
  377. def default_schema_name_switch(self):
  378. """target dialect implements provisioning module including
  379. set_default_schema_on_connection"""
  380. return exclusions.closed()
  381. @property
  382. def server_side_cursors(self):
  383. """Target dialect must support server side cursors."""
  384. return exclusions.only_if(
  385. [lambda config: config.db.dialect.supports_server_side_cursors],
  386. "no server side cursors support",
  387. )
  388. @property
  389. def sequences(self):
  390. """Target database must support SEQUENCEs."""
  391. return exclusions.only_if(
  392. [lambda config: config.db.dialect.supports_sequences],
  393. "no sequence support",
  394. )
  395. @property
  396. def no_sequences(self):
  397. """the opposite of "sequences", DB does not support sequences at
  398. all."""
  399. return exclusions.NotPredicate(self.sequences)
  400. @property
  401. def sequences_optional(self):
  402. """Target database supports sequences, but also optionally
  403. as a means of generating new PK values."""
  404. return exclusions.only_if(
  405. [
  406. lambda config: config.db.dialect.supports_sequences
  407. and config.db.dialect.sequences_optional
  408. ],
  409. "no sequence support, or sequences not optional",
  410. )
  411. @property
  412. def supports_lastrowid(self):
  413. """target database / driver supports cursor.lastrowid as a means
  414. of retrieving the last inserted primary key value.
  415. note that if the target DB supports sequences also, this is still
  416. assumed to work. This is a new use case brought on by MariaDB 10.3.
  417. """
  418. return exclusions.only_if(
  419. [lambda config: config.db.dialect.postfetch_lastrowid]
  420. )
  421. @property
  422. def no_lastrowid_support(self):
  423. """the opposite of supports_lastrowid"""
  424. return exclusions.only_if(
  425. [lambda config: not config.db.dialect.postfetch_lastrowid]
  426. )
  427. @property
  428. def reflects_pk_names(self):
  429. return exclusions.closed()
  430. @property
  431. def table_reflection(self):
  432. return exclusions.open()
  433. @property
  434. def comment_reflection(self):
  435. return exclusions.closed()
  436. @property
  437. def view_column_reflection(self):
  438. """target database must support retrieval of the columns in a view,
  439. similarly to how a table is inspected.
  440. This does not include the full CREATE VIEW definition.
  441. """
  442. return self.views
  443. @property
  444. def view_reflection(self):
  445. """target database must support inspection of the full CREATE VIEW
  446. definition."""
  447. return self.views
  448. @property
  449. def schema_reflection(self):
  450. return self.schemas
  451. @property
  452. def primary_key_constraint_reflection(self):
  453. return exclusions.open()
  454. @property
  455. def foreign_key_constraint_reflection(self):
  456. return exclusions.open()
  457. @property
  458. def foreign_key_constraint_option_reflection_ondelete(self):
  459. return exclusions.closed()
  460. @property
  461. def fk_constraint_option_reflection_ondelete_restrict(self):
  462. return exclusions.closed()
  463. @property
  464. def fk_constraint_option_reflection_ondelete_noaction(self):
  465. return exclusions.closed()
  466. @property
  467. def foreign_key_constraint_option_reflection_onupdate(self):
  468. return exclusions.closed()
  469. @property
  470. def fk_constraint_option_reflection_onupdate_restrict(self):
  471. return exclusions.closed()
  472. @property
  473. def temp_table_reflection(self):
  474. return exclusions.open()
  475. @property
  476. def temp_table_reflect_indexes(self):
  477. return self.temp_table_reflection
  478. @property
  479. def temp_table_names(self):
  480. """target dialect supports listing of temporary table names"""
  481. return exclusions.closed()
  482. @property
  483. def temporary_tables(self):
  484. """target database supports temporary tables"""
  485. return exclusions.open()
  486. @property
  487. def temporary_views(self):
  488. """target database supports temporary views"""
  489. return exclusions.closed()
  490. @property
  491. def index_reflection(self):
  492. return exclusions.open()
  493. @property
  494. def index_reflects_included_columns(self):
  495. return exclusions.closed()
  496. @property
  497. def indexes_with_ascdesc(self):
  498. """target database supports CREATE INDEX with per-column ASC/DESC."""
  499. return exclusions.open()
  500. @property
  501. def indexes_with_expressions(self):
  502. """target database supports CREATE INDEX against SQL expressions."""
  503. return exclusions.closed()
  504. @property
  505. def unique_constraint_reflection(self):
  506. """target dialect supports reflection of unique constraints"""
  507. return exclusions.open()
  508. @property
  509. def check_constraint_reflection(self):
  510. """target dialect supports reflection of check constraints"""
  511. return exclusions.closed()
  512. @property
  513. def duplicate_key_raises_integrity_error(self):
  514. """target dialect raises IntegrityError when reporting an INSERT
  515. with a primary key violation. (hint: it should)
  516. """
  517. return exclusions.open()
  518. @property
  519. def unbounded_varchar(self):
  520. """Target database must support VARCHAR with no length"""
  521. return exclusions.open()
  522. @property
  523. def unicode_data(self):
  524. """Target database/dialect must support Python unicode objects with
  525. non-ASCII characters represented, delivered as bound parameters
  526. as well as in result rows.
  527. """
  528. return exclusions.open()
  529. @property
  530. def unicode_ddl(self):
  531. """Target driver must support some degree of non-ascii symbol
  532. names.
  533. """
  534. return exclusions.closed()
  535. @property
  536. def symbol_names_w_double_quote(self):
  537. """Target driver can create tables with a name like 'some " table'"""
  538. return exclusions.open()
  539. @property
  540. def datetime_literals(self):
  541. """target dialect supports rendering of a date, time, or datetime as a
  542. literal string, e.g. via the TypeEngine.literal_processor() method.
  543. """
  544. return exclusions.closed()
  545. @property
  546. def datetime(self):
  547. """target dialect supports representation of Python
  548. datetime.datetime() objects."""
  549. return exclusions.open()
  550. @property
  551. def datetime_microseconds(self):
  552. """target dialect supports representation of Python
  553. datetime.datetime() with microsecond objects."""
  554. return exclusions.open()
  555. @property
  556. def timestamp_microseconds(self):
  557. """target dialect supports representation of Python
  558. datetime.datetime() with microsecond objects but only
  559. if TIMESTAMP is used."""
  560. return exclusions.closed()
  561. @property
  562. def datetime_historic(self):
  563. """target dialect supports representation of Python
  564. datetime.datetime() objects with historic (pre 1970) values."""
  565. return exclusions.closed()
  566. @property
  567. def date(self):
  568. """target dialect supports representation of Python
  569. datetime.date() objects."""
  570. return exclusions.open()
  571. @property
  572. def date_coerces_from_datetime(self):
  573. """target dialect accepts a datetime object as the target
  574. of a date column."""
  575. return exclusions.open()
  576. @property
  577. def date_historic(self):
  578. """target dialect supports representation of Python
  579. datetime.datetime() objects with historic (pre 1970) values."""
  580. return exclusions.closed()
  581. @property
  582. def time(self):
  583. """target dialect supports representation of Python
  584. datetime.time() objects."""
  585. return exclusions.open()
  586. @property
  587. def time_microseconds(self):
  588. """target dialect supports representation of Python
  589. datetime.time() with microsecond objects."""
  590. return exclusions.open()
  591. @property
  592. def binary_comparisons(self):
  593. """target database/driver can allow BLOB/BINARY fields to be compared
  594. against a bound parameter value.
  595. """
  596. return exclusions.open()
  597. @property
  598. def binary_literals(self):
  599. """target backend supports simple binary literals, e.g. an
  600. expression like::
  601. SELECT CAST('foo' AS BINARY)
  602. Where ``BINARY`` is the type emitted from :class:`.LargeBinary`,
  603. e.g. it could be ``BLOB`` or similar.
  604. Basically fails on Oracle.
  605. """
  606. return exclusions.open()
  607. @property
  608. def autocommit(self):
  609. """target dialect supports 'AUTOCOMMIT' as an isolation_level"""
  610. return exclusions.closed()
  611. @property
  612. def isolation_level(self):
  613. """target dialect supports general isolation level settings.
  614. Note that this requirement, when enabled, also requires that
  615. the get_isolation_levels() method be implemented.
  616. """
  617. return exclusions.closed()
  618. def get_isolation_levels(self, config):
  619. """Return a structure of supported isolation levels for the current
  620. testing dialect.
  621. The structure indicates to the testing suite what the expected
  622. "default" isolation should be, as well as the other values that
  623. are accepted. The dictionary has two keys, "default" and "supported".
  624. The "supported" key refers to a list of all supported levels and
  625. it should include AUTOCOMMIT if the dialect supports it.
  626. If the :meth:`.DefaultRequirements.isolation_level` requirement is
  627. not open, then this method has no return value.
  628. E.g.::
  629. >>> testing.requirements.get_isolation_levels()
  630. {
  631. "default": "READ_COMMITED",
  632. "supported": [
  633. "SERIALIZABLE", "READ UNCOMMITTED",
  634. "READ COMMITTED", "REPEATABLE READ",
  635. "AUTOCOMMIT"
  636. ]
  637. }
  638. """
  639. @property
  640. def json_type(self):
  641. """target platform implements a native JSON type."""
  642. return exclusions.closed()
  643. @property
  644. def json_array_indexes(self):
  645. """target platform supports numeric array indexes
  646. within a JSON structure"""
  647. return self.json_type
  648. @property
  649. def json_index_supplementary_unicode_element(self):
  650. return exclusions.open()
  651. @property
  652. def legacy_unconditional_json_extract(self):
  653. """Backend has a JSON_EXTRACT or similar function that returns a
  654. valid JSON string in all cases.
  655. Used to test a legacy feature and is not needed.
  656. """
  657. return exclusions.closed()
  658. @property
  659. def precision_numerics_general(self):
  660. """target backend has general support for moderately high-precision
  661. numerics."""
  662. return exclusions.open()
  663. @property
  664. def precision_numerics_enotation_small(self):
  665. """target backend supports Decimal() objects using E notation
  666. to represent very small values."""
  667. return exclusions.closed()
  668. @property
  669. def precision_numerics_enotation_large(self):
  670. """target backend supports Decimal() objects using E notation
  671. to represent very large values."""
  672. return exclusions.closed()
  673. @property
  674. def precision_numerics_many_significant_digits(self):
  675. """target backend supports values with many digits on both sides,
  676. such as 319438950232418390.273596, 87673.594069654243
  677. """
  678. return exclusions.closed()
  679. @property
  680. def cast_precision_numerics_many_significant_digits(self):
  681. """same as precision_numerics_many_significant_digits but within the
  682. context of a CAST statement (hello MySQL)
  683. """
  684. return self.precision_numerics_many_significant_digits
  685. @property
  686. def implicit_decimal_binds(self):
  687. """target backend will return a selected Decimal as a Decimal, not
  688. a string.
  689. e.g.::
  690. expr = decimal.Decimal("15.7563")
  691. value = e.scalar(
  692. select(literal(expr))
  693. )
  694. assert value == expr
  695. See :ticket:`4036`
  696. """
  697. return exclusions.open()
  698. @property
  699. def nested_aggregates(self):
  700. """target database can select an aggregate from a subquery that's
  701. also using an aggregate
  702. """
  703. return exclusions.open()
  704. @property
  705. def recursive_fk_cascade(self):
  706. """target database must support ON DELETE CASCADE on a self-referential
  707. foreign key
  708. """
  709. return exclusions.open()
  710. @property
  711. def precision_numerics_retains_significant_digits(self):
  712. """A precision numeric type will return empty significant digits,
  713. i.e. a value such as 10.000 will come back in Decimal form with
  714. the .000 maintained."""
  715. return exclusions.closed()
  716. @property
  717. def precision_generic_float_type(self):
  718. """target backend will return native floating point numbers with at
  719. least seven decimal places when using the generic Float type.
  720. """
  721. return exclusions.open()
  722. @property
  723. def floats_to_four_decimals(self):
  724. """target backend can return a floating-point number with four
  725. significant digits (such as 15.7563) accurately
  726. (i.e. without FP inaccuracies, such as 15.75629997253418).
  727. """
  728. return exclusions.open()
  729. @property
  730. def fetch_null_from_numeric(self):
  731. """target backend doesn't crash when you try to select a NUMERIC
  732. value that has a value of NULL.
  733. Added to support Pyodbc bug #351.
  734. """
  735. return exclusions.open()
  736. @property
  737. def text_type(self):
  738. """Target database must support an unbounded Text() "
  739. "type such as TEXT or CLOB"""
  740. return exclusions.open()
  741. @property
  742. def empty_strings_varchar(self):
  743. """target database can persist/return an empty string with a
  744. varchar.
  745. """
  746. return exclusions.open()
  747. @property
  748. def empty_strings_text(self):
  749. """target database can persist/return an empty string with an
  750. unbounded text."""
  751. return exclusions.open()
  752. @property
  753. def expressions_against_unbounded_text(self):
  754. """target database supports use of an unbounded textual field in a
  755. WHERE clause."""
  756. return exclusions.open()
  757. @property
  758. def selectone(self):
  759. """target driver must support the literal statement 'select 1'"""
  760. return exclusions.open()
  761. @property
  762. def savepoints(self):
  763. """Target database must support savepoints."""
  764. return exclusions.closed()
  765. @property
  766. def two_phase_transactions(self):
  767. """Target database must support two-phase transactions."""
  768. return exclusions.closed()
  769. @property
  770. def update_from(self):
  771. """Target must support UPDATE..FROM syntax"""
  772. return exclusions.closed()
  773. @property
  774. def delete_from(self):
  775. """Target must support DELETE FROM..FROM or DELETE..USING syntax"""
  776. return exclusions.closed()
  777. @property
  778. def update_where_target_in_subquery(self):
  779. """Target must support UPDATE (or DELETE) where the same table is
  780. present in a subquery in the WHERE clause.
  781. This is an ANSI-standard syntax that apparently MySQL can't handle,
  782. such as::
  783. UPDATE documents SET flag=1 WHERE documents.title IN
  784. (SELECT max(documents.title) AS title
  785. FROM documents GROUP BY documents.user_id
  786. )
  787. """
  788. return exclusions.open()
  789. @property
  790. def mod_operator_as_percent_sign(self):
  791. """target database must use a plain percent '%' as the 'modulus'
  792. operator."""
  793. return exclusions.closed()
  794. @property
  795. def percent_schema_names(self):
  796. """target backend supports weird identifiers with percent signs
  797. in them, e.g. 'some % column'.
  798. this is a very weird use case but often has problems because of
  799. DBAPIs that use python formatting. It's not a critical use
  800. case either.
  801. """
  802. return exclusions.closed()
  803. @property
  804. def order_by_col_from_union(self):
  805. """target database supports ordering by a column from a SELECT
  806. inside of a UNION
  807. E.g. (SELECT id, ...) UNION (SELECT id, ...) ORDER BY id
  808. """
  809. return exclusions.open()
  810. @property
  811. def order_by_label_with_expression(self):
  812. """target backend supports ORDER BY a column label within an
  813. expression.
  814. Basically this::
  815. select data as foo from test order by foo || 'bar'
  816. Lots of databases including PostgreSQL don't support this,
  817. so this is off by default.
  818. """
  819. return exclusions.closed()
  820. @property
  821. def order_by_collation(self):
  822. def check(config):
  823. try:
  824. self.get_order_by_collation(config)
  825. return False
  826. except NotImplementedError:
  827. return True
  828. return exclusions.skip_if(check)
  829. def get_order_by_collation(self, config):
  830. raise NotImplementedError()
  831. @property
  832. def unicode_connections(self):
  833. """Target driver must support non-ASCII characters being passed at
  834. all.
  835. """
  836. return exclusions.open()
  837. @property
  838. def graceful_disconnects(self):
  839. """Target driver must raise a DBAPI-level exception, such as
  840. InterfaceError, when the underlying connection has been closed
  841. and the execute() method is called.
  842. """
  843. return exclusions.open()
  844. @property
  845. def independent_connections(self):
  846. """
  847. Target must support simultaneous, independent database connections.
  848. """
  849. return exclusions.open()
  850. @property
  851. def skip_mysql_on_windows(self):
  852. """Catchall for a large variety of MySQL on Windows failures"""
  853. return exclusions.open()
  854. @property
  855. def ad_hoc_engines(self):
  856. """Test environment must allow ad-hoc engine/connection creation.
  857. DBs that scale poorly for many connections, even when closed, i.e.
  858. Oracle, may use the "--low-connections" option which flags this
  859. requirement as not present.
  860. """
  861. return exclusions.skip_if(
  862. lambda config: config.options.low_connections
  863. )
  864. @property
  865. def no_windows(self):
  866. return exclusions.skip_if(self._running_on_windows())
  867. def _running_on_windows(self):
  868. return exclusions.LambdaPredicate(
  869. lambda: platform.system() == "Windows",
  870. description="running on Windows",
  871. )
  872. @property
  873. def timing_intensive(self):
  874. return exclusions.requires_tag("timing_intensive")
  875. @property
  876. def memory_intensive(self):
  877. return exclusions.requires_tag("memory_intensive")
  878. @property
  879. def threading_with_mock(self):
  880. """Mark tests that use threading and mock at the same time - stability
  881. issues have been observed with coverage + python 3.3
  882. """
  883. return exclusions.skip_if(
  884. lambda config: util.py3k and config.options.has_coverage,
  885. "Stability issues with coverage + py3k",
  886. )
  887. @property
  888. def sqlalchemy2_stubs(self):
  889. def check(config):
  890. try:
  891. __import__("sqlalchemy-stubs.ext.mypy")
  892. except ImportError:
  893. return False
  894. else:
  895. return True
  896. return exclusions.only_if(check)
  897. @property
  898. def python2(self):
  899. return exclusions.skip_if(
  900. lambda: sys.version_info >= (3,),
  901. "Python version 2.xx is required.",
  902. )
  903. @property
  904. def python3(self):
  905. return exclusions.skip_if(
  906. lambda: sys.version_info < (3,), "Python version 3.xx is required."
  907. )
  908. @property
  909. def pep520(self):
  910. return self.python36
  911. @property
  912. def python36(self):
  913. return exclusions.skip_if(
  914. lambda: sys.version_info < (3, 6),
  915. "Python version 3.6 or greater is required.",
  916. )
  917. @property
  918. def python37(self):
  919. return exclusions.skip_if(
  920. lambda: sys.version_info < (3, 7),
  921. "Python version 3.7 or greater is required.",
  922. )
  923. @property
  924. def dataclasses(self):
  925. return self.python37
  926. @property
  927. def cpython(self):
  928. return exclusions.only_if(
  929. lambda: util.cpython, "cPython interpreter needed"
  930. )
  931. @property
  932. def patch_library(self):
  933. def check_lib():
  934. try:
  935. __import__("patch")
  936. except ImportError:
  937. return False
  938. else:
  939. return True
  940. return exclusions.only_if(check_lib, "patch library needed")
  941. @property
  942. def non_broken_pickle(self):
  943. from sqlalchemy.util import pickle
  944. return exclusions.only_if(
  945. lambda: util.cpython
  946. and pickle.__name__ == "cPickle"
  947. or sys.version_info >= (3, 2),
  948. "Needs cPickle+cPython or newer Python 3 pickle",
  949. )
  950. @property
  951. def predictable_gc(self):
  952. """target platform must remove all cycles unconditionally when
  953. gc.collect() is called, as well as clean out unreferenced subclasses.
  954. """
  955. return self.cpython
  956. @property
  957. def no_coverage(self):
  958. """Test should be skipped if coverage is enabled.
  959. This is to block tests that exercise libraries that seem to be
  960. sensitive to coverage, such as PostgreSQL notice logging.
  961. """
  962. return exclusions.skip_if(
  963. lambda config: config.options.has_coverage,
  964. "Issues observed when coverage is enabled",
  965. )
  966. def _has_mysql_on_windows(self, config):
  967. return False
  968. def _has_mysql_fully_case_sensitive(self, config):
  969. return False
  970. @property
  971. def sqlite(self):
  972. return exclusions.skip_if(lambda: not self._has_sqlite())
  973. @property
  974. def cextensions(self):
  975. return exclusions.skip_if(
  976. lambda: not util.has_compiled_ext(), "C extensions not installed"
  977. )
  978. def _has_sqlite(self):
  979. from sqlalchemy import create_engine
  980. try:
  981. create_engine("sqlite://")
  982. return True
  983. except ImportError:
  984. return False
  985. @property
  986. def async_dialect(self):
  987. """dialect makes use of await_() to invoke operations on the DBAPI."""
  988. return exclusions.closed()
  989. @property
  990. def computed_columns(self):
  991. "Supports computed columns"
  992. return exclusions.closed()
  993. @property
  994. def computed_columns_stored(self):
  995. "Supports computed columns with `persisted=True`"
  996. return exclusions.closed()
  997. @property
  998. def computed_columns_virtual(self):
  999. "Supports computed columns with `persisted=False`"
  1000. return exclusions.closed()
  1001. @property
  1002. def computed_columns_default_persisted(self):
  1003. """If the default persistence is virtual or stored when `persisted`
  1004. is omitted"""
  1005. return exclusions.closed()
  1006. @property
  1007. def computed_columns_reflect_persisted(self):
  1008. """If persistence information is returned by the reflection of
  1009. computed columns"""
  1010. return exclusions.closed()
  1011. @property
  1012. def supports_distinct_on(self):
  1013. """If a backend supports the DISTINCT ON in a select"""
  1014. return exclusions.closed()
  1015. @property
  1016. def supports_is_distinct_from(self):
  1017. """Supports some form of "x IS [NOT] DISTINCT FROM y" construct.
  1018. Different dialects will implement their own flavour, e.g.,
  1019. sqlite will emit "x IS NOT y" instead of "x IS DISTINCT FROM y".
  1020. .. seealso::
  1021. :meth:`.ColumnOperators.is_distinct_from`
  1022. """
  1023. return exclusions.skip_if(
  1024. lambda config: not config.db.dialect.supports_is_distinct_from,
  1025. "driver doesn't support an IS DISTINCT FROM construct",
  1026. )
  1027. @property
  1028. def identity_columns(self):
  1029. """If a backend supports GENERATED { ALWAYS | BY DEFAULT }
  1030. AS IDENTITY"""
  1031. return exclusions.closed()
  1032. @property
  1033. def identity_columns_standard(self):
  1034. """If a backend supports GENERATED { ALWAYS | BY DEFAULT }
  1035. AS IDENTITY with a standard syntax.
  1036. This is mainly to exclude MSSql.
  1037. """
  1038. return exclusions.closed()
  1039. @property
  1040. def regexp_match(self):
  1041. """backend supports the regexp_match operator."""
  1042. return exclusions.closed()
  1043. @property
  1044. def regexp_replace(self):
  1045. """backend supports the regexp_replace operator."""
  1046. return exclusions.closed()
  1047. @property
  1048. def fetch_first(self):
  1049. """backend supports the fetch first clause."""
  1050. return exclusions.closed()
  1051. @property
  1052. def fetch_percent(self):
  1053. """backend supports the fetch first clause with percent."""
  1054. return exclusions.closed()
  1055. @property
  1056. def fetch_ties(self):
  1057. """backend supports the fetch first clause with ties."""
  1058. return exclusions.closed()
  1059. @property
  1060. def fetch_no_order_by(self):
  1061. """backend supports the fetch first without order by"""
  1062. return exclusions.closed()
  1063. @property
  1064. def fetch_offset_with_options(self):
  1065. """backend supports the offset when using fetch first with percent
  1066. or ties. basically this is "not mssql"
  1067. """
  1068. return exclusions.closed()
  1069. @property
  1070. def autoincrement_without_sequence(self):
  1071. """If autoincrement=True on a column does not require an explicit
  1072. sequence. This should be false only for oracle.
  1073. """
  1074. return exclusions.open()