requirements.py 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918
  1. # testing/requirements.py
  2. # Copyright (C) 2005-2025 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: https://www.opensource.org/licenses/mit-license.php
  7. # mypy: ignore-errors
  8. """Global database feature support policy.
  9. Provides decorators to mark tests requiring specific feature support from the
  10. target database.
  11. External dialect test suites should subclass SuiteRequirements
  12. to provide specific inclusion/exclusions.
  13. """
  14. from __future__ import annotations
  15. import os
  16. import platform
  17. from . import asyncio as _test_asyncio
  18. from . import exclusions
  19. from .exclusions import only_on
  20. from .. import create_engine
  21. from .. import util
  22. from ..pool import QueuePool
  23. class Requirements:
  24. pass
  25. class SuiteRequirements(Requirements):
  26. @property
  27. def create_table(self):
  28. """target platform can emit basic CreateTable DDL."""
  29. return exclusions.open()
  30. @property
  31. def drop_table(self):
  32. """target platform can emit basic DropTable DDL."""
  33. return exclusions.open()
  34. @property
  35. def table_ddl_if_exists(self):
  36. """target platform supports IF NOT EXISTS / IF EXISTS for tables."""
  37. return exclusions.closed()
  38. @property
  39. def index_ddl_if_exists(self):
  40. """target platform supports IF NOT EXISTS / IF EXISTS for indexes."""
  41. return exclusions.closed()
  42. @property
  43. def uuid_data_type(self):
  44. """Return databases that support the UUID datatype."""
  45. return exclusions.closed()
  46. @property
  47. def foreign_keys(self):
  48. """Target database must support foreign keys."""
  49. return exclusions.open()
  50. @property
  51. def foreign_keys_reflect_as_index(self):
  52. """Target database creates an index that's reflected for
  53. foreign keys."""
  54. return exclusions.closed()
  55. @property
  56. def unique_index_reflect_as_unique_constraints(self):
  57. """Target database reflects unique indexes as unique constrains."""
  58. return exclusions.closed()
  59. @property
  60. def unique_constraints_reflect_as_index(self):
  61. """Target database reflects unique constraints as indexes."""
  62. return exclusions.closed()
  63. @property
  64. def table_value_constructor(self):
  65. """Database / dialect supports a query like:
  66. .. sourcecode:: sql
  67. SELECT * FROM VALUES ( (c1, c2), (c1, c2), ...)
  68. AS some_table(col1, col2)
  69. SQLAlchemy generates this with the :func:`_sql.values` function.
  70. """
  71. return exclusions.closed()
  72. @property
  73. def standard_cursor_sql(self):
  74. """Target database passes SQL-92 style statements to cursor.execute()
  75. when a statement like select() or insert() is run.
  76. A very small portion of dialect-level tests will ensure that certain
  77. conditions are present in SQL strings, and these tests use very basic
  78. SQL that will work on any SQL-like platform in order to assert results.
  79. It's normally a given for any pep-249 DBAPI that a statement like
  80. "SELECT id, name FROM table WHERE some_table.id=5" will work.
  81. However, there are dialects that don't actually produce SQL Strings
  82. and instead may work with symbolic objects instead, or dialects that
  83. aren't working with SQL, so for those this requirement can be marked
  84. as excluded.
  85. """
  86. return exclusions.open()
  87. @property
  88. def on_update_cascade(self):
  89. """target database must support ON UPDATE..CASCADE behavior in
  90. foreign keys."""
  91. return exclusions.open()
  92. @property
  93. def non_updating_cascade(self):
  94. """target database must *not* support ON UPDATE..CASCADE behavior in
  95. foreign keys."""
  96. return exclusions.closed()
  97. @property
  98. def deferrable_fks(self):
  99. return exclusions.closed()
  100. @property
  101. def on_update_or_deferrable_fks(self):
  102. # TODO: exclusions should be composable,
  103. # somehow only_if([x, y]) isn't working here, negation/conjunctions
  104. # getting confused.
  105. return exclusions.only_if(
  106. lambda: self.on_update_cascade.enabled
  107. or self.deferrable_fks.enabled
  108. )
  109. @property
  110. def queue_pool(self):
  111. """target database is using QueuePool"""
  112. def go(config):
  113. return isinstance(config.db.pool, QueuePool)
  114. return exclusions.only_if(go)
  115. @property
  116. def self_referential_foreign_keys(self):
  117. """Target database must support self-referential foreign keys."""
  118. return exclusions.open()
  119. @property
  120. def foreign_key_ddl(self):
  121. """Target database must support the DDL phrases for FOREIGN KEY."""
  122. return exclusions.open()
  123. @property
  124. def named_constraints(self):
  125. """target database must support names for constraints."""
  126. return exclusions.open()
  127. @property
  128. def implicitly_named_constraints(self):
  129. """target database must apply names to unnamed constraints."""
  130. return exclusions.open()
  131. @property
  132. def unusual_column_name_characters(self):
  133. """target database allows column names that have unusual characters
  134. in them, such as dots, spaces, slashes, or percent signs.
  135. The column names are as always in such a case quoted, however the
  136. DB still needs to support those characters in the name somehow.
  137. """
  138. return exclusions.open()
  139. @property
  140. def subqueries(self):
  141. """Target database must support subqueries."""
  142. return exclusions.open()
  143. @property
  144. def offset(self):
  145. """target database can render OFFSET, or an equivalent, in a
  146. SELECT.
  147. """
  148. return exclusions.open()
  149. @property
  150. def bound_limit_offset(self):
  151. """target database can render LIMIT and/or OFFSET using a bound
  152. parameter
  153. """
  154. return exclusions.open()
  155. @property
  156. def sql_expression_limit_offset(self):
  157. """target database can render LIMIT and/or OFFSET with a complete
  158. SQL expression, such as one that uses the addition operator.
  159. parameter
  160. """
  161. return exclusions.open()
  162. @property
  163. def parens_in_union_contained_select_w_limit_offset(self):
  164. """Target database must support parenthesized SELECT in UNION
  165. when LIMIT/OFFSET is specifically present.
  166. E.g. (SELECT ...) UNION (SELECT ..)
  167. This is known to fail on SQLite.
  168. """
  169. return exclusions.open()
  170. @property
  171. def parens_in_union_contained_select_wo_limit_offset(self):
  172. """Target database must support parenthesized SELECT in UNION
  173. when OFFSET/LIMIT is specifically not present.
  174. E.g. (SELECT ... LIMIT ..) UNION (SELECT .. OFFSET ..)
  175. This is known to fail on SQLite. It also fails on Oracle
  176. because without LIMIT/OFFSET, there is currently no step that
  177. creates an additional subquery.
  178. """
  179. return exclusions.open()
  180. @property
  181. def boolean_col_expressions(self):
  182. """Target database must support boolean expressions as columns"""
  183. return exclusions.closed()
  184. @property
  185. def nullable_booleans(self):
  186. """Target database allows boolean columns to store NULL."""
  187. return exclusions.open()
  188. @property
  189. def nullsordering(self):
  190. """Target backends that support nulls ordering."""
  191. return exclusions.closed()
  192. @property
  193. def standalone_binds(self):
  194. """target database/driver supports bound parameters as column
  195. expressions without being in the context of a typed column.
  196. """
  197. return exclusions.open()
  198. @property
  199. def standalone_null_binds_whereclause(self):
  200. """target database/driver supports bound parameters with NULL in the
  201. WHERE clause, in situations where it has to be typed.
  202. """
  203. return exclusions.open()
  204. @property
  205. def intersect(self):
  206. """Target database must support INTERSECT or equivalent."""
  207. return exclusions.closed()
  208. @property
  209. def except_(self):
  210. """Target database must support EXCEPT or equivalent (i.e. MINUS)."""
  211. return exclusions.closed()
  212. @property
  213. def window_functions(self):
  214. """Target database must support window functions."""
  215. return exclusions.closed()
  216. @property
  217. def ctes(self):
  218. """Target database supports CTEs"""
  219. return exclusions.closed()
  220. @property
  221. def ctes_with_update_delete(self):
  222. """target database supports CTES that ride on top of a normal UPDATE
  223. or DELETE statement which refers to the CTE in a correlated subquery.
  224. """
  225. return exclusions.closed()
  226. @property
  227. def ctes_with_values(self):
  228. """target database supports CTES that ride on top of a VALUES
  229. clause."""
  230. return exclusions.closed()
  231. @property
  232. def ctes_on_dml(self):
  233. """target database supports CTES which consist of INSERT, UPDATE
  234. or DELETE *within* the CTE, e.g. WITH x AS (UPDATE....)"""
  235. return exclusions.closed()
  236. @property
  237. def autoincrement_insert(self):
  238. """target platform generates new surrogate integer primary key values
  239. when insert() is executed, excluding the pk column."""
  240. return exclusions.open()
  241. @property
  242. def fetch_rows_post_commit(self):
  243. """target platform will allow cursor.fetchone() to proceed after a
  244. COMMIT.
  245. Typically this refers to an INSERT statement with RETURNING which
  246. is invoked within "autocommit". If the row can be returned
  247. after the autocommit, then this rule can be open.
  248. """
  249. return exclusions.open()
  250. @property
  251. def group_by_complex_expression(self):
  252. """target platform supports SQL expressions in GROUP BY
  253. e.g.
  254. SELECT x + y AS somelabel FROM table GROUP BY x + y
  255. """
  256. return exclusions.open()
  257. @property
  258. def sane_rowcount(self):
  259. return exclusions.skip_if(
  260. lambda config: not config.db.dialect.supports_sane_rowcount,
  261. "driver doesn't support 'sane' rowcount",
  262. )
  263. @property
  264. def sane_multi_rowcount(self):
  265. return exclusions.fails_if(
  266. lambda config: not config.db.dialect.supports_sane_multi_rowcount,
  267. "driver %(driver)s %(doesnt_support)s 'sane' multi row count",
  268. )
  269. @property
  270. def sane_rowcount_w_returning(self):
  271. return exclusions.fails_if(
  272. lambda config: not (
  273. config.db.dialect.supports_sane_rowcount_returning
  274. ),
  275. "driver doesn't support 'sane' rowcount when returning is on",
  276. )
  277. @property
  278. def empty_inserts(self):
  279. """target platform supports INSERT with no values, i.e.
  280. INSERT DEFAULT VALUES or equivalent."""
  281. return exclusions.only_if(
  282. lambda config: config.db.dialect.supports_empty_insert
  283. or config.db.dialect.supports_default_values
  284. or config.db.dialect.supports_default_metavalue,
  285. "empty inserts not supported",
  286. )
  287. @property
  288. def empty_inserts_executemany(self):
  289. """target platform supports INSERT with no values, i.e.
  290. INSERT DEFAULT VALUES or equivalent, within executemany()"""
  291. return self.empty_inserts
  292. @property
  293. def insert_from_select(self):
  294. """target platform supports INSERT from a SELECT."""
  295. return exclusions.open()
  296. @property
  297. def delete_returning(self):
  298. """target platform supports DELETE ... RETURNING."""
  299. return exclusions.only_if(
  300. lambda config: config.db.dialect.delete_returning,
  301. "%(database)s %(does_support)s 'DELETE ... RETURNING'",
  302. )
  303. @property
  304. def insert_returning(self):
  305. """target platform supports INSERT ... RETURNING."""
  306. return exclusions.only_if(
  307. lambda config: config.db.dialect.insert_returning,
  308. "%(database)s %(does_support)s 'INSERT ... RETURNING'",
  309. )
  310. @property
  311. def update_returning(self):
  312. """target platform supports UPDATE ... RETURNING."""
  313. return exclusions.only_if(
  314. lambda config: config.db.dialect.update_returning,
  315. "%(database)s %(does_support)s 'UPDATE ... RETURNING'",
  316. )
  317. @property
  318. def insert_executemany_returning(self):
  319. """target platform supports RETURNING when INSERT is used with
  320. executemany(), e.g. multiple parameter sets, indicating
  321. as many rows come back as do parameter sets were passed.
  322. """
  323. return exclusions.only_if(
  324. lambda config: config.db.dialect.insert_executemany_returning,
  325. "%(database)s %(does_support)s 'RETURNING of "
  326. "multiple rows with INSERT executemany'",
  327. )
  328. @property
  329. def insertmanyvalues(self):
  330. return exclusions.only_if(
  331. lambda config: config.db.dialect.supports_multivalues_insert
  332. and config.db.dialect.insert_returning
  333. and config.db.dialect.use_insertmanyvalues,
  334. "%(database)s %(does_support)s 'insertmanyvalues functionality",
  335. )
  336. @property
  337. def tuple_in(self):
  338. """Target platform supports the syntax
  339. "(x, y) IN ((x1, y1), (x2, y2), ...)"
  340. """
  341. return exclusions.closed()
  342. @property
  343. def tuple_in_w_empty(self):
  344. """Target platform tuple IN w/ empty set"""
  345. return self.tuple_in
  346. @property
  347. def duplicate_names_in_cursor_description(self):
  348. """target platform supports a SELECT statement that has
  349. the same name repeated more than once in the columns list."""
  350. return exclusions.open()
  351. @property
  352. def denormalized_names(self):
  353. """Target database must have 'denormalized', i.e.
  354. UPPERCASE as case insensitive names."""
  355. return exclusions.skip_if(
  356. lambda config: not config.db.dialect.requires_name_normalize,
  357. "Backend does not require denormalized names.",
  358. )
  359. @property
  360. def multivalues_inserts(self):
  361. """target database must support multiple VALUES clauses in an
  362. INSERT statement."""
  363. return exclusions.skip_if(
  364. lambda config: not config.db.dialect.supports_multivalues_insert,
  365. "Backend does not support multirow inserts.",
  366. )
  367. @property
  368. def implements_get_lastrowid(self):
  369. """target dialect implements the executioncontext.get_lastrowid()
  370. method without reliance on RETURNING.
  371. """
  372. return exclusions.open()
  373. @property
  374. def arraysize(self):
  375. """dialect includes the required pep-249 attribute
  376. ``cursor.arraysize``"""
  377. return exclusions.open()
  378. @property
  379. def emulated_lastrowid(self):
  380. """target dialect retrieves cursor.lastrowid, or fetches
  381. from a database-side function after an insert() construct executes,
  382. within the get_lastrowid() method.
  383. Only dialects that "pre-execute", or need RETURNING to get last
  384. inserted id, would return closed/fail/skip for this.
  385. """
  386. return exclusions.closed()
  387. @property
  388. def emulated_lastrowid_even_with_sequences(self):
  389. """target dialect retrieves cursor.lastrowid or an equivalent
  390. after an insert() construct executes, even if the table has a
  391. Sequence on it.
  392. """
  393. return exclusions.closed()
  394. @property
  395. def dbapi_lastrowid(self):
  396. """target platform includes a 'lastrowid' accessor on the DBAPI
  397. cursor object.
  398. """
  399. return exclusions.closed()
  400. @property
  401. def views(self):
  402. """Target database must support VIEWs."""
  403. return exclusions.closed()
  404. @property
  405. def schemas(self):
  406. """Target database must support external schemas, and have one
  407. named 'test_schema'."""
  408. return only_on(lambda config: config.db.dialect.supports_schemas)
  409. @property
  410. def cross_schema_fk_reflection(self):
  411. """target system must support reflection of inter-schema
  412. foreign keys"""
  413. return exclusions.closed()
  414. @property
  415. def foreign_key_constraint_name_reflection(self):
  416. """Target supports reflection of FOREIGN KEY constraints and
  417. will return the name of the constraint that was used in the
  418. "CONSTRAINT <name> FOREIGN KEY" DDL.
  419. MySQL prior to version 8 and MariaDB prior to version 10.5
  420. don't support this.
  421. """
  422. return exclusions.closed()
  423. @property
  424. def implicit_default_schema(self):
  425. """target system has a strong concept of 'default' schema that can
  426. be referred to implicitly.
  427. basically, PostgreSQL.
  428. """
  429. return exclusions.closed()
  430. @property
  431. def default_schema_name_switch(self):
  432. """target dialect implements provisioning module including
  433. set_default_schema_on_connection"""
  434. return exclusions.closed()
  435. @property
  436. def server_side_cursors(self):
  437. """Target dialect must support server side cursors."""
  438. return exclusions.only_if(
  439. [lambda config: config.db.dialect.supports_server_side_cursors],
  440. "no server side cursors support",
  441. )
  442. @property
  443. def sequences(self):
  444. """Target database must support SEQUENCEs."""
  445. return exclusions.only_if(
  446. [lambda config: config.db.dialect.supports_sequences],
  447. "no sequence support",
  448. )
  449. @property
  450. def no_sequences(self):
  451. """the opposite of "sequences", DB does not support sequences at
  452. all."""
  453. return exclusions.NotPredicate(self.sequences)
  454. @property
  455. def sequences_optional(self):
  456. """Target database supports sequences, but also optionally
  457. as a means of generating new PK values."""
  458. return exclusions.only_if(
  459. [
  460. lambda config: config.db.dialect.supports_sequences
  461. and config.db.dialect.sequences_optional
  462. ],
  463. "no sequence support, or sequences not optional",
  464. )
  465. @property
  466. def supports_lastrowid(self):
  467. """target database / driver supports cursor.lastrowid as a means
  468. of retrieving the last inserted primary key value.
  469. note that if the target DB supports sequences also, this is still
  470. assumed to work. This is a new use case brought on by MariaDB 10.3.
  471. """
  472. return exclusions.only_if(
  473. [lambda config: config.db.dialect.postfetch_lastrowid]
  474. )
  475. @property
  476. def no_lastrowid_support(self):
  477. """the opposite of supports_lastrowid"""
  478. return exclusions.only_if(
  479. [lambda config: not config.db.dialect.postfetch_lastrowid]
  480. )
  481. @property
  482. def reflects_pk_names(self):
  483. return exclusions.closed()
  484. @property
  485. def table_reflection(self):
  486. """target database has general support for table reflection"""
  487. return exclusions.open()
  488. @property
  489. def reflect_tables_no_columns(self):
  490. """target database supports creation and reflection of tables with no
  491. columns, or at least tables that seem to have no columns."""
  492. return exclusions.closed()
  493. @property
  494. def temp_table_comment_reflection(self):
  495. """indicates if database supports comments on temp tables and
  496. the dialect can reflect them"""
  497. return exclusions.closed()
  498. @property
  499. def comment_reflection(self):
  500. """Indicates if the database support table comment reflection"""
  501. return exclusions.closed()
  502. @property
  503. def comment_reflection_full_unicode(self):
  504. """Indicates if the database support table comment reflection in the
  505. full unicode range, including emoji etc.
  506. """
  507. return exclusions.closed()
  508. @property
  509. def constraint_comment_reflection(self):
  510. """indicates if the database support comments on constraints
  511. and their reflection"""
  512. return exclusions.closed()
  513. @property
  514. def view_column_reflection(self):
  515. """target database must support retrieval of the columns in a view,
  516. similarly to how a table is inspected.
  517. This does not include the full CREATE VIEW definition.
  518. """
  519. return self.views
  520. @property
  521. def view_reflection(self):
  522. """target database must support inspection of the full CREATE VIEW
  523. definition."""
  524. return self.views
  525. @property
  526. def schema_reflection(self):
  527. return self.schemas
  528. @property
  529. def schema_create_delete(self):
  530. """target database supports schema create and dropped with
  531. 'CREATE SCHEMA' and 'DROP SCHEMA'"""
  532. return exclusions.closed()
  533. @property
  534. def primary_key_constraint_reflection(self):
  535. return exclusions.open()
  536. @property
  537. def foreign_key_constraint_reflection(self):
  538. return exclusions.open()
  539. @property
  540. def foreign_key_constraint_option_reflection_ondelete(self):
  541. return exclusions.closed()
  542. @property
  543. def fk_constraint_option_reflection_ondelete_restrict(self):
  544. return exclusions.closed()
  545. @property
  546. def fk_constraint_option_reflection_ondelete_noaction(self):
  547. return exclusions.closed()
  548. @property
  549. def foreign_key_constraint_option_reflection_onupdate(self):
  550. return exclusions.closed()
  551. @property
  552. def fk_constraint_option_reflection_onupdate_restrict(self):
  553. return exclusions.closed()
  554. @property
  555. def temp_table_reflection(self):
  556. return exclusions.open()
  557. @property
  558. def temp_table_reflect_indexes(self):
  559. return self.temp_table_reflection
  560. @property
  561. def temp_table_names(self):
  562. """target dialect supports listing of temporary table names"""
  563. return exclusions.closed()
  564. @property
  565. def has_temp_table(self):
  566. """target dialect supports checking a single temp table name"""
  567. return exclusions.closed()
  568. @property
  569. def temporary_tables(self):
  570. """target database supports temporary tables"""
  571. return exclusions.open()
  572. @property
  573. def temporary_views(self):
  574. """target database supports temporary views"""
  575. return exclusions.closed()
  576. @property
  577. def index_reflection(self):
  578. return exclusions.open()
  579. @property
  580. def index_reflects_included_columns(self):
  581. return exclusions.closed()
  582. @property
  583. def indexes_with_ascdesc(self):
  584. """target database supports CREATE INDEX with per-column ASC/DESC."""
  585. return exclusions.open()
  586. @property
  587. def reflect_indexes_with_ascdesc(self):
  588. """target database supports reflecting INDEX with per-column
  589. ASC/DESC."""
  590. return exclusions.open()
  591. @property
  592. def reflect_indexes_with_ascdesc_as_expression(self):
  593. """target database supports reflecting INDEX with per-column
  594. ASC/DESC but reflects them as expressions (like oracle)."""
  595. return exclusions.closed()
  596. @property
  597. def indexes_with_expressions(self):
  598. """target database supports CREATE INDEX against SQL expressions."""
  599. return exclusions.closed()
  600. @property
  601. def reflect_indexes_with_expressions(self):
  602. """target database supports reflection of indexes with
  603. SQL expressions."""
  604. return exclusions.closed()
  605. @property
  606. def unique_constraint_reflection(self):
  607. """target dialect supports reflection of unique constraints"""
  608. return exclusions.open()
  609. @property
  610. def inline_check_constraint_reflection(self):
  611. """target dialect supports reflection of inline check constraints"""
  612. return exclusions.closed()
  613. @property
  614. def check_constraint_reflection(self):
  615. """target dialect supports reflection of check constraints"""
  616. return exclusions.closed()
  617. @property
  618. def duplicate_key_raises_integrity_error(self):
  619. """target dialect raises IntegrityError when reporting an INSERT
  620. with a primary key violation. (hint: it should)
  621. """
  622. return exclusions.open()
  623. @property
  624. def unbounded_varchar(self):
  625. """Target database must support VARCHAR with no length"""
  626. return exclusions.open()
  627. @property
  628. def nvarchar_types(self):
  629. """target database supports NVARCHAR and NCHAR as an actual datatype"""
  630. return exclusions.closed()
  631. @property
  632. def unicode_data_no_special_types(self):
  633. """Target database/dialect can receive / deliver / compare data with
  634. non-ASCII characters in plain VARCHAR, TEXT columns, without the need
  635. for special "national" datatypes like NVARCHAR or similar.
  636. """
  637. return exclusions.open()
  638. @property
  639. def unicode_data(self):
  640. """Target database/dialect must support Python unicode objects with
  641. non-ASCII characters represented, delivered as bound parameters
  642. as well as in result rows.
  643. """
  644. return exclusions.open()
  645. @property
  646. def unicode_ddl(self):
  647. """Target driver must support some degree of non-ascii symbol
  648. names.
  649. """
  650. return exclusions.closed()
  651. @property
  652. def symbol_names_w_double_quote(self):
  653. """Target driver can create tables with a name like 'some " table'"""
  654. return exclusions.open()
  655. @property
  656. def datetime_interval(self):
  657. """target dialect supports rendering of a datetime.timedelta as a
  658. literal string, e.g. via the TypeEngine.literal_processor() method.
  659. """
  660. return exclusions.closed()
  661. @property
  662. def datetime_literals(self):
  663. """target dialect supports rendering of a date, time, or datetime as a
  664. literal string, e.g. via the TypeEngine.literal_processor() method.
  665. """
  666. return exclusions.closed()
  667. @property
  668. def datetime(self):
  669. """target dialect supports representation of Python
  670. datetime.datetime() objects."""
  671. return exclusions.open()
  672. @property
  673. def datetime_timezone(self):
  674. """target dialect supports representation of Python
  675. datetime.datetime() with tzinfo with DateTime(timezone=True)."""
  676. return exclusions.closed()
  677. @property
  678. def time_timezone(self):
  679. """target dialect supports representation of Python
  680. datetime.time() with tzinfo with Time(timezone=True)."""
  681. return exclusions.closed()
  682. @property
  683. def date_implicit_bound(self):
  684. """target dialect when given a date object will bind it such
  685. that the database server knows the object is a date, and not
  686. a plain string.
  687. """
  688. return exclusions.open()
  689. @property
  690. def time_implicit_bound(self):
  691. """target dialect when given a time object will bind it such
  692. that the database server knows the object is a time, and not
  693. a plain string.
  694. """
  695. return exclusions.open()
  696. @property
  697. def datetime_implicit_bound(self):
  698. """target dialect when given a datetime object will bind it such
  699. that the database server knows the object is a datetime, and not
  700. a plain string.
  701. """
  702. return exclusions.open()
  703. @property
  704. def datetime_microseconds(self):
  705. """target dialect supports representation of Python
  706. datetime.datetime() with microsecond objects."""
  707. return exclusions.open()
  708. @property
  709. def timestamp_microseconds(self):
  710. """target dialect supports representation of Python
  711. datetime.datetime() with microsecond objects but only
  712. if TIMESTAMP is used."""
  713. return exclusions.closed()
  714. @property
  715. def timestamp_microseconds_implicit_bound(self):
  716. """target dialect when given a datetime object which also includes
  717. a microseconds portion when using the TIMESTAMP data type
  718. will bind it such that the database server knows
  719. the object is a datetime with microseconds, and not a plain string.
  720. """
  721. return self.timestamp_microseconds
  722. @property
  723. def datetime_historic(self):
  724. """target dialect supports representation of Python
  725. datetime.datetime() objects with historic (pre 1970) values."""
  726. return exclusions.closed()
  727. @property
  728. def date(self):
  729. """target dialect supports representation of Python
  730. datetime.date() objects."""
  731. return exclusions.open()
  732. @property
  733. def date_coerces_from_datetime(self):
  734. """target dialect accepts a datetime object as the target
  735. of a date column."""
  736. return exclusions.open()
  737. @property
  738. def date_historic(self):
  739. """target dialect supports representation of Python
  740. datetime.datetime() objects with historic (pre 1970) values."""
  741. return exclusions.closed()
  742. @property
  743. def time(self):
  744. """target dialect supports representation of Python
  745. datetime.time() objects."""
  746. return exclusions.open()
  747. @property
  748. def time_microseconds(self):
  749. """target dialect supports representation of Python
  750. datetime.time() with microsecond objects."""
  751. return exclusions.open()
  752. @property
  753. def binary_comparisons(self):
  754. """target database/driver can allow BLOB/BINARY fields to be compared
  755. against a bound parameter value.
  756. """
  757. return exclusions.open()
  758. @property
  759. def binary_literals(self):
  760. """target backend supports simple binary literals, e.g. an
  761. expression like:
  762. .. sourcecode:: sql
  763. SELECT CAST('foo' AS BINARY)
  764. Where ``BINARY`` is the type emitted from :class:`.LargeBinary`,
  765. e.g. it could be ``BLOB`` or similar.
  766. Basically fails on Oracle.
  767. """
  768. return exclusions.open()
  769. @property
  770. def autocommit(self):
  771. """target dialect supports 'AUTOCOMMIT' as an isolation_level"""
  772. return exclusions.closed()
  773. @property
  774. def skip_autocommit_rollback(self):
  775. """target dialect supports the detect_autocommit_setting() method and
  776. uses the default implementation of do_rollback()"""
  777. return exclusions.closed()
  778. @property
  779. def isolation_level(self):
  780. """target dialect supports general isolation level settings.
  781. Note that this requirement, when enabled, also requires that
  782. the get_isolation_levels() method be implemented.
  783. """
  784. return exclusions.closed()
  785. def get_isolation_levels(self, config):
  786. """Return a structure of supported isolation levels for the current
  787. testing dialect.
  788. The structure indicates to the testing suite what the expected
  789. "default" isolation should be, as well as the other values that
  790. are accepted. The dictionary has two keys, "default" and "supported".
  791. The "supported" key refers to a list of all supported levels and
  792. it should include AUTOCOMMIT if the dialect supports it.
  793. If the :meth:`.DefaultRequirements.isolation_level` requirement is
  794. not open, then this method has no return value.
  795. E.g.::
  796. >>> testing.requirements.get_isolation_levels()
  797. {
  798. "default": "READ_COMMITTED",
  799. "supported": [
  800. "SERIALIZABLE", "READ UNCOMMITTED",
  801. "READ COMMITTED", "REPEATABLE READ",
  802. "AUTOCOMMIT"
  803. ]
  804. }
  805. """
  806. with config.db.connect() as conn:
  807. try:
  808. supported = conn.dialect.get_isolation_level_values(
  809. conn.connection.dbapi_connection
  810. )
  811. except NotImplementedError:
  812. return None
  813. else:
  814. return {
  815. "default": conn.dialect.default_isolation_level,
  816. "supported": supported,
  817. }
  818. @property
  819. def get_isolation_level_values(self):
  820. """target dialect supports the
  821. :meth:`_engine.Dialect.get_isolation_level_values`
  822. method added in SQLAlchemy 2.0.
  823. """
  824. def go(config):
  825. with config.db.connect() as conn:
  826. try:
  827. conn.dialect.get_isolation_level_values(
  828. conn.connection.dbapi_connection
  829. )
  830. except NotImplementedError:
  831. return False
  832. else:
  833. return True
  834. return exclusions.only_if(go)
  835. @property
  836. def dialect_level_isolation_level_param(self):
  837. """test that the dialect allows the 'isolation_level' argument
  838. to be handled by DefaultDialect"""
  839. def go(config):
  840. try:
  841. e = create_engine(
  842. config.db.url, isolation_level="READ COMMITTED"
  843. )
  844. except:
  845. return False
  846. else:
  847. return (
  848. e.dialect._on_connect_isolation_level == "READ COMMITTED"
  849. )
  850. return exclusions.only_if(go)
  851. @property
  852. def array_type(self):
  853. """Target platform implements a native ARRAY type"""
  854. return exclusions.closed()
  855. @property
  856. def json_type(self):
  857. """target platform implements a native JSON type."""
  858. return exclusions.closed()
  859. @property
  860. def json_array_indexes(self):
  861. """target platform supports numeric array indexes
  862. within a JSON structure"""
  863. return self.json_type
  864. @property
  865. def json_index_supplementary_unicode_element(self):
  866. return exclusions.open()
  867. @property
  868. def legacy_unconditional_json_extract(self):
  869. """Backend has a JSON_EXTRACT or similar function that returns a
  870. valid JSON string in all cases.
  871. Used to test a legacy feature and is not needed.
  872. """
  873. return exclusions.closed()
  874. @property
  875. def precision_numerics_general(self):
  876. """target backend has general support for moderately high-precision
  877. numerics."""
  878. return exclusions.open()
  879. @property
  880. def precision_numerics_enotation_small(self):
  881. """target backend supports Decimal() objects using E notation
  882. to represent very small values."""
  883. return exclusions.closed()
  884. @property
  885. def precision_numerics_enotation_large(self):
  886. """target backend supports Decimal() objects using E notation
  887. to represent very large values."""
  888. return exclusions.open()
  889. @property
  890. def precision_numerics_many_significant_digits(self):
  891. """target backend supports values with many digits on both sides,
  892. such as 319438950232418390.273596, 87673.594069654243
  893. """
  894. return exclusions.closed()
  895. @property
  896. def cast_precision_numerics_many_significant_digits(self):
  897. """same as precision_numerics_many_significant_digits but within the
  898. context of a CAST statement (hello MySQL)
  899. """
  900. return self.precision_numerics_many_significant_digits
  901. @property
  902. def server_defaults(self):
  903. """Target backend supports server side defaults for columns"""
  904. return exclusions.closed()
  905. @property
  906. def expression_server_defaults(self):
  907. """Target backend supports server side defaults with SQL expressions
  908. for columns"""
  909. return exclusions.closed()
  910. @property
  911. def implicit_decimal_binds(self):
  912. """target backend will return a selected Decimal as a Decimal, not
  913. a string.
  914. e.g.::
  915. expr = decimal.Decimal("15.7563")
  916. value = e.scalar(select(literal(expr)))
  917. assert value == expr
  918. See :ticket:`4036`
  919. """
  920. return exclusions.open()
  921. @property
  922. def numeric_received_as_decimal_untyped(self):
  923. """target backend will return result columns that are explicitly
  924. against NUMERIC or similar precision-numeric datatypes (not including
  925. FLOAT or INT types) as Python Decimal objects, and not as floats
  926. or ints, including when no SQLAlchemy-side typing information is
  927. associated with the statement (e.g. such as a raw SQL string).
  928. This should be enabled if either the DBAPI itself returns Decimal
  929. objects, or if the dialect has set up DBAPI-specific return type
  930. handlers such that Decimal objects come back automatically.
  931. """
  932. return exclusions.open()
  933. @property
  934. def nested_aggregates(self):
  935. """target database can select an aggregate from a subquery that's
  936. also using an aggregate
  937. """
  938. return exclusions.open()
  939. @property
  940. def recursive_fk_cascade(self):
  941. """target database must support ON DELETE CASCADE on a self-referential
  942. foreign key
  943. """
  944. return exclusions.open()
  945. @property
  946. def precision_numerics_retains_significant_digits(self):
  947. """A precision numeric type will return empty significant digits,
  948. i.e. a value such as 10.000 will come back in Decimal form with
  949. the .000 maintained."""
  950. return exclusions.closed()
  951. @property
  952. def infinity_floats(self):
  953. """The Float type can persist and load float('inf'), float('-inf')."""
  954. return exclusions.closed()
  955. @property
  956. def float_or_double_precision_behaves_generically(self):
  957. return exclusions.closed()
  958. @property
  959. def precision_generic_float_type(self):
  960. """target backend will return native floating point numbers with at
  961. least seven decimal places when using the generic Float type.
  962. """
  963. return exclusions.open()
  964. @property
  965. def literal_float_coercion(self):
  966. """target backend will return the exact float value 15.7563
  967. with only four significant digits from this statement:
  968. SELECT :param
  969. where :param is the Python float 15.7563
  970. i.e. it does not return 15.75629997253418
  971. """
  972. return exclusions.open()
  973. @property
  974. def floats_to_four_decimals(self):
  975. """target backend can return a floating-point number with four
  976. significant digits (such as 15.7563) accurately
  977. (i.e. without FP inaccuracies, such as 15.75629997253418).
  978. """
  979. return exclusions.open()
  980. @property
  981. def fetch_null_from_numeric(self):
  982. """target backend doesn't crash when you try to select a NUMERIC
  983. value that has a value of NULL.
  984. Added to support Pyodbc bug #351.
  985. """
  986. return exclusions.open()
  987. @property
  988. def float_is_numeric(self):
  989. """target backend uses Numeric for Float/Dual"""
  990. return exclusions.open()
  991. @property
  992. def text_type(self):
  993. """Target database must support an unbounded Text() "
  994. "type such as TEXT or CLOB"""
  995. return exclusions.open()
  996. @property
  997. def empty_strings_varchar(self):
  998. """target database can persist/return an empty string with a
  999. varchar.
  1000. """
  1001. return exclusions.open()
  1002. @property
  1003. def empty_strings_text(self):
  1004. """target database can persist/return an empty string with an
  1005. unbounded text."""
  1006. return exclusions.open()
  1007. @property
  1008. def expressions_against_unbounded_text(self):
  1009. """target database supports use of an unbounded textual field in a
  1010. WHERE clause."""
  1011. return exclusions.open()
  1012. @property
  1013. def selectone(self):
  1014. """target driver must support the literal statement 'select 1'"""
  1015. return exclusions.open()
  1016. @property
  1017. def savepoints(self):
  1018. """Target database must support savepoints."""
  1019. return exclusions.closed()
  1020. @property
  1021. def two_phase_transactions(self):
  1022. """Target database must support two-phase transactions."""
  1023. return exclusions.closed()
  1024. @property
  1025. def update_from(self):
  1026. """Target must support UPDATE..FROM syntax"""
  1027. return exclusions.closed()
  1028. @property
  1029. def delete_from(self):
  1030. """Target must support DELETE FROM..FROM or DELETE..USING syntax"""
  1031. return exclusions.closed()
  1032. @property
  1033. def update_where_target_in_subquery(self):
  1034. """Target must support UPDATE (or DELETE) where the same table is
  1035. present in a subquery in the WHERE clause.
  1036. This is an ANSI-standard syntax that apparently MySQL can't handle,
  1037. such as:
  1038. .. sourcecode:: sql
  1039. UPDATE documents SET flag=1 WHERE documents.title IN
  1040. (SELECT max(documents.title) AS title
  1041. FROM documents GROUP BY documents.user_id
  1042. )
  1043. """
  1044. return exclusions.open()
  1045. @property
  1046. def mod_operator_as_percent_sign(self):
  1047. """target database must use a plain percent '%' as the 'modulus'
  1048. operator."""
  1049. return exclusions.closed()
  1050. @property
  1051. def percent_schema_names(self):
  1052. """target backend supports weird identifiers with percent signs
  1053. in them, e.g. 'some % column'.
  1054. this is a very weird use case but often has problems because of
  1055. DBAPIs that use python formatting. It's not a critical use
  1056. case either.
  1057. """
  1058. return exclusions.closed()
  1059. @property
  1060. def order_by_col_from_union(self):
  1061. """target database supports ordering by a column from a SELECT
  1062. inside of a UNION
  1063. E.g.:
  1064. .. sourcecode:: sql
  1065. (SELECT id, ...) UNION (SELECT id, ...) ORDER BY id
  1066. """
  1067. return exclusions.open()
  1068. @property
  1069. def order_by_label_with_expression(self):
  1070. """target backend supports ORDER BY a column label within an
  1071. expression.
  1072. Basically this:
  1073. .. sourcecode:: sql
  1074. select data as foo from test order by foo || 'bar'
  1075. Lots of databases including PostgreSQL don't support this,
  1076. so this is off by default.
  1077. """
  1078. return exclusions.closed()
  1079. @property
  1080. def order_by_collation(self):
  1081. def check(config):
  1082. try:
  1083. self.get_order_by_collation(config)
  1084. return False
  1085. except NotImplementedError:
  1086. return True
  1087. return exclusions.skip_if(check)
  1088. def get_order_by_collation(self, config):
  1089. raise NotImplementedError()
  1090. @property
  1091. def unicode_connections(self):
  1092. """Target driver must support non-ASCII characters being passed at
  1093. all.
  1094. """
  1095. return exclusions.open()
  1096. @property
  1097. def graceful_disconnects(self):
  1098. """Target driver must raise a DBAPI-level exception, such as
  1099. InterfaceError, when the underlying connection has been closed
  1100. and the execute() method is called.
  1101. """
  1102. return exclusions.open()
  1103. @property
  1104. def independent_connections(self):
  1105. """
  1106. Target must support simultaneous, independent database connections.
  1107. """
  1108. return exclusions.open()
  1109. @property
  1110. def independent_readonly_connections(self):
  1111. """
  1112. Target must support simultaneous, independent database connections
  1113. that will be used in a readonly fashion.
  1114. """
  1115. return exclusions.open()
  1116. @property
  1117. def skip_mysql_on_windows(self):
  1118. """Catchall for a large variety of MySQL on Windows failures"""
  1119. return exclusions.open()
  1120. @property
  1121. def ad_hoc_engines(self):
  1122. """Test environment must allow ad-hoc engine/connection creation.
  1123. DBs that scale poorly for many connections, even when closed, i.e.
  1124. Oracle, may use the "--low-connections" option which flags this
  1125. requirement as not present.
  1126. """
  1127. return exclusions.skip_if(
  1128. lambda config: config.options.low_connections
  1129. )
  1130. @property
  1131. def no_windows(self):
  1132. return exclusions.skip_if(self._running_on_windows())
  1133. def _running_on_windows(self):
  1134. return exclusions.LambdaPredicate(
  1135. lambda: platform.system() == "Windows",
  1136. description="running on Windows",
  1137. )
  1138. @property
  1139. def timing_intensive(self):
  1140. from . import config
  1141. return config.add_to_marker.timing_intensive
  1142. @property
  1143. def posix(self):
  1144. return exclusions.skip_if(lambda: os.name != "posix")
  1145. @property
  1146. def memory_intensive(self):
  1147. from . import config
  1148. return config.add_to_marker.memory_intensive
  1149. @property
  1150. def threading_with_mock(self):
  1151. """Mark tests that use threading and mock at the same time - stability
  1152. issues have been observed with coverage
  1153. """
  1154. return exclusions.skip_if(
  1155. lambda config: config.options.has_coverage,
  1156. "Stability issues with coverage",
  1157. )
  1158. @property
  1159. def sqlalchemy2_stubs(self):
  1160. def check(config):
  1161. try:
  1162. __import__("sqlalchemy-stubs.ext.mypy")
  1163. except ImportError:
  1164. return False
  1165. else:
  1166. return True
  1167. return exclusions.only_if(check)
  1168. @property
  1169. def no_sqlalchemy2_stubs(self):
  1170. def check(config):
  1171. try:
  1172. __import__("sqlalchemy-stubs.ext.mypy")
  1173. except ImportError:
  1174. return False
  1175. else:
  1176. return True
  1177. return exclusions.skip_if(check)
  1178. @property
  1179. def up_to_date_typealias_type(self):
  1180. # this checks a particular quirk found in typing_extensions <=4.12.0
  1181. # using older python versions like 3.10 or 3.9, we use TypeAliasType
  1182. # from typing_extensions which does not provide for sufficient
  1183. # introspection prior to 4.13.0
  1184. def check(config):
  1185. import typing
  1186. import typing_extensions
  1187. TypeAliasType = getattr(
  1188. typing, "TypeAliasType", typing_extensions.TypeAliasType
  1189. )
  1190. TV = typing.TypeVar("TV")
  1191. TA_generic = TypeAliasType( # type: ignore
  1192. "TA_generic", typing.List[TV], type_params=(TV,)
  1193. )
  1194. return hasattr(TA_generic[int], "__value__")
  1195. return exclusions.only_if(check)
  1196. @property
  1197. def python38(self):
  1198. return exclusions.only_if(
  1199. lambda: util.py38, "Python 3.8 or above required"
  1200. )
  1201. @property
  1202. def python39(self):
  1203. return exclusions.only_if(
  1204. lambda: util.py39, "Python 3.9 or above required"
  1205. )
  1206. @property
  1207. def python310(self):
  1208. return exclusions.only_if(
  1209. lambda: util.py310, "Python 3.10 or above required"
  1210. )
  1211. @property
  1212. def python311(self):
  1213. return exclusions.only_if(
  1214. lambda: util.py311, "Python 3.11 or above required"
  1215. )
  1216. @property
  1217. def python312(self):
  1218. return exclusions.only_if(
  1219. lambda: util.py312, "Python 3.12 or above required"
  1220. )
  1221. @property
  1222. def fail_python314b1(self):
  1223. return exclusions.fails_if(
  1224. lambda: util.compat.py314b1, "Fails as of python 3.14.0b1"
  1225. )
  1226. @property
  1227. def not_python314(self):
  1228. """This requirement is interim to assist with backporting of
  1229. issue #12405.
  1230. SQLAlchemy 2.0 still includes the ``await_fallback()`` method that
  1231. makes use of ``asyncio.get_event_loop_policy()``. This is removed
  1232. in SQLAlchemy 2.1.
  1233. """
  1234. return exclusions.skip_if(
  1235. lambda: util.py314, "Python 3.14 or above not supported"
  1236. )
  1237. @property
  1238. def cpython(self):
  1239. return exclusions.only_if(
  1240. lambda: util.cpython, "cPython interpreter needed"
  1241. )
  1242. @property
  1243. def is64bit(self):
  1244. return exclusions.only_if(lambda: util.is64bit, "64bit required")
  1245. @property
  1246. def patch_library(self):
  1247. def check_lib():
  1248. try:
  1249. __import__("patch")
  1250. except ImportError:
  1251. return False
  1252. else:
  1253. return True
  1254. return exclusions.only_if(check_lib, "patch library needed")
  1255. @property
  1256. def predictable_gc(self):
  1257. """target platform must remove all cycles unconditionally when
  1258. gc.collect() is called, as well as clean out unreferenced subclasses.
  1259. """
  1260. return self.cpython
  1261. @property
  1262. def no_coverage(self):
  1263. """Test should be skipped if coverage is enabled.
  1264. This is to block tests that exercise libraries that seem to be
  1265. sensitive to coverage, such as PostgreSQL notice logging.
  1266. """
  1267. return exclusions.skip_if(
  1268. lambda config: config.options.has_coverage,
  1269. "Issues observed when coverage is enabled",
  1270. )
  1271. def _has_mysql_on_windows(self, config):
  1272. return False
  1273. def _has_mysql_fully_case_sensitive(self, config):
  1274. return False
  1275. @property
  1276. def sqlite(self):
  1277. return exclusions.skip_if(lambda: not self._has_sqlite())
  1278. @property
  1279. def cextensions(self):
  1280. return exclusions.skip_if(
  1281. lambda: not util.has_compiled_ext(),
  1282. "Cython extensions not installed",
  1283. )
  1284. def _has_sqlite(self):
  1285. from sqlalchemy import create_engine
  1286. try:
  1287. create_engine("sqlite://")
  1288. return True
  1289. except ImportError:
  1290. return False
  1291. @property
  1292. def async_dialect(self):
  1293. """dialect makes use of await_() to invoke operations on the DBAPI."""
  1294. return exclusions.closed()
  1295. @property
  1296. def asyncio(self):
  1297. return self.greenlet
  1298. @property
  1299. def no_greenlet(self):
  1300. def go(config):
  1301. try:
  1302. import greenlet # noqa: F401
  1303. except ImportError:
  1304. return True
  1305. else:
  1306. return False
  1307. return exclusions.only_if(go)
  1308. @property
  1309. def greenlet(self):
  1310. def go(config):
  1311. if not _test_asyncio.ENABLE_ASYNCIO:
  1312. return False
  1313. try:
  1314. import greenlet # noqa: F401
  1315. except ImportError:
  1316. return False
  1317. else:
  1318. return True
  1319. return exclusions.only_if(go)
  1320. @property
  1321. def computed_columns(self):
  1322. "Supports computed columns"
  1323. return exclusions.closed()
  1324. @property
  1325. def computed_columns_stored(self):
  1326. "Supports computed columns with `persisted=True`"
  1327. return exclusions.closed()
  1328. @property
  1329. def computed_columns_virtual(self):
  1330. "Supports computed columns with `persisted=False`"
  1331. return exclusions.closed()
  1332. @property
  1333. def computed_columns_default_persisted(self):
  1334. """If the default persistence is virtual or stored when `persisted`
  1335. is omitted"""
  1336. return exclusions.closed()
  1337. @property
  1338. def computed_columns_reflect_persisted(self):
  1339. """If persistence information is returned by the reflection of
  1340. computed columns"""
  1341. return exclusions.closed()
  1342. @property
  1343. def supports_distinct_on(self):
  1344. """If a backend supports the DISTINCT ON in a select"""
  1345. return exclusions.closed()
  1346. @property
  1347. def supports_is_distinct_from(self):
  1348. """Supports some form of "x IS [NOT] DISTINCT FROM y" construct.
  1349. Different dialects will implement their own flavour, e.g.,
  1350. sqlite will emit "x IS NOT y" instead of "x IS DISTINCT FROM y".
  1351. .. seealso::
  1352. :meth:`.ColumnOperators.is_distinct_from`
  1353. """
  1354. return exclusions.skip_if(
  1355. lambda config: not config.db.dialect.supports_is_distinct_from,
  1356. "driver doesn't support an IS DISTINCT FROM construct",
  1357. )
  1358. @property
  1359. def identity_columns(self):
  1360. """If a backend supports GENERATED { ALWAYS | BY DEFAULT }
  1361. AS IDENTITY"""
  1362. return exclusions.closed()
  1363. @property
  1364. def identity_columns_standard(self):
  1365. """If a backend supports GENERATED { ALWAYS | BY DEFAULT }
  1366. AS IDENTITY with a standard syntax.
  1367. This is mainly to exclude MSSql.
  1368. """
  1369. return exclusions.closed()
  1370. @property
  1371. def regexp_match(self):
  1372. """backend supports the regexp_match operator."""
  1373. return exclusions.closed()
  1374. @property
  1375. def regexp_replace(self):
  1376. """backend supports the regexp_replace operator."""
  1377. return exclusions.closed()
  1378. @property
  1379. def fetch_first(self):
  1380. """backend supports the fetch first clause."""
  1381. return exclusions.closed()
  1382. @property
  1383. def fetch_percent(self):
  1384. """backend supports the fetch first clause with percent."""
  1385. return exclusions.closed()
  1386. @property
  1387. def fetch_ties(self):
  1388. """backend supports the fetch first clause with ties."""
  1389. return exclusions.closed()
  1390. @property
  1391. def fetch_no_order_by(self):
  1392. """backend supports the fetch first without order by"""
  1393. return exclusions.closed()
  1394. @property
  1395. def fetch_offset_with_options(self):
  1396. """backend supports the offset when using fetch first with percent
  1397. or ties. basically this is "not mssql"
  1398. """
  1399. return exclusions.closed()
  1400. @property
  1401. def fetch_expression(self):
  1402. """backend supports fetch / offset with expression in them, like
  1403. SELECT * FROM some_table
  1404. OFFSET 1 + 1 ROWS FETCH FIRST 1 + 1 ROWS ONLY
  1405. """
  1406. return exclusions.closed()
  1407. @property
  1408. def autoincrement_without_sequence(self):
  1409. """If autoincrement=True on a column does not require an explicit
  1410. sequence. This should be false only for oracle.
  1411. """
  1412. return exclusions.open()
  1413. @property
  1414. def generic_classes(self):
  1415. "If X[Y] can be implemented with ``__class_getitem__``. py3.7+"
  1416. return exclusions.open()
  1417. @property
  1418. def json_deserializer_binary(self):
  1419. "indicates if the json_deserializer function is called with bytes"
  1420. return exclusions.closed()
  1421. @property
  1422. def reflect_table_options(self):
  1423. """Target database must support reflecting table_options."""
  1424. return exclusions.closed()
  1425. @property
  1426. def materialized_views(self):
  1427. """Target database must support MATERIALIZED VIEWs."""
  1428. return exclusions.closed()
  1429. @property
  1430. def materialized_views_reflect_pk(self):
  1431. """Target database reflect MATERIALIZED VIEWs pks."""
  1432. return exclusions.closed()
  1433. @property
  1434. def supports_bitwise_or(self):
  1435. """Target database supports bitwise or"""
  1436. return exclusions.closed()
  1437. @property
  1438. def supports_bitwise_and(self):
  1439. """Target database supports bitwise and"""
  1440. return exclusions.closed()
  1441. @property
  1442. def supports_bitwise_not(self):
  1443. """Target database supports bitwise not"""
  1444. return exclusions.closed()
  1445. @property
  1446. def supports_bitwise_xor(self):
  1447. """Target database supports bitwise xor"""
  1448. return exclusions.closed()
  1449. @property
  1450. def supports_bitwise_shift(self):
  1451. """Target database supports bitwise left or right shift"""
  1452. return exclusions.closed()
  1453. @property
  1454. def like_escapes(self):
  1455. """Target backend supports custom ESCAPE characters
  1456. with LIKE comparisons"""
  1457. return exclusions.open()