requirements.py 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945
  1. # testing/requirements.py
  2. # Copyright (C) 2005-2026 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 column_collation_reflection(self):
  515. """Indicates if the database support column collation reflection.
  516. This requirement also uses ``get_order_by_collation`` to get
  517. an available collation.
  518. """
  519. return exclusions.closed()
  520. @property
  521. def view_column_reflection(self):
  522. """target database must support retrieval of the columns in a view,
  523. similarly to how a table is inspected.
  524. This does not include the full CREATE VIEW definition.
  525. """
  526. return self.views
  527. @property
  528. def view_reflection(self):
  529. """target database must support inspection of the full CREATE VIEW
  530. definition."""
  531. return self.views
  532. @property
  533. def schema_reflection(self):
  534. return self.schemas
  535. @property
  536. def schema_create_delete(self):
  537. """target database supports schema create and dropped with
  538. 'CREATE SCHEMA' and 'DROP SCHEMA'"""
  539. return exclusions.closed()
  540. @property
  541. def primary_key_constraint_reflection(self):
  542. return exclusions.open()
  543. @property
  544. def foreign_key_constraint_reflection(self):
  545. return exclusions.open()
  546. @property
  547. def foreign_key_constraint_option_reflection_ondelete(self):
  548. return exclusions.closed()
  549. @property
  550. def fk_constraint_option_reflection_ondelete_restrict(self):
  551. return exclusions.closed()
  552. @property
  553. def fk_constraint_option_reflection_ondelete_noaction(self):
  554. return exclusions.closed()
  555. @property
  556. def foreign_key_constraint_option_reflection_onupdate(self):
  557. return exclusions.closed()
  558. @property
  559. def fk_constraint_option_reflection_onupdate_restrict(self):
  560. return exclusions.closed()
  561. @property
  562. def temp_table_reflection(self):
  563. return exclusions.open()
  564. @property
  565. def temp_table_reflect_indexes(self):
  566. return self.temp_table_reflection
  567. @property
  568. def temp_table_names(self):
  569. """target dialect supports listing of temporary table names"""
  570. return exclusions.closed()
  571. @property
  572. def has_temp_table(self):
  573. """target dialect supports checking a single temp table name"""
  574. return exclusions.closed()
  575. @property
  576. def temporary_tables(self):
  577. """target database supports temporary tables"""
  578. return exclusions.open()
  579. @property
  580. def temporary_views(self):
  581. """target database supports temporary views"""
  582. return exclusions.closed()
  583. @property
  584. def index_reflection(self):
  585. return exclusions.open()
  586. @property
  587. def index_reflects_included_columns(self):
  588. return exclusions.closed()
  589. @property
  590. def indexes_with_ascdesc(self):
  591. """target database supports CREATE INDEX with per-column ASC/DESC."""
  592. return exclusions.open()
  593. @property
  594. def reflect_indexes_with_ascdesc(self):
  595. """target database supports reflecting INDEX with per-column
  596. ASC/DESC."""
  597. return exclusions.open()
  598. @property
  599. def reflect_indexes_with_ascdesc_as_expression(self):
  600. """target database supports reflecting INDEX with per-column
  601. ASC/DESC but reflects them as expressions (like oracle)."""
  602. return exclusions.closed()
  603. @property
  604. def indexes_check_column_order(self):
  605. """target database supports CREATE INDEX with column order check."""
  606. return exclusions.closed()
  607. @property
  608. def indexes_with_expressions(self):
  609. """target database supports CREATE INDEX against SQL expressions."""
  610. return exclusions.closed()
  611. @property
  612. def reflect_indexes_with_expressions(self):
  613. """target database supports reflection of indexes with
  614. SQL expressions."""
  615. return exclusions.closed()
  616. @property
  617. def unique_constraint_reflection(self):
  618. """target dialect supports reflection of unique constraints"""
  619. return exclusions.open()
  620. @property
  621. def inline_check_constraint_reflection(self):
  622. """target dialect supports reflection of inline check constraints"""
  623. return exclusions.closed()
  624. @property
  625. def check_constraint_reflection(self):
  626. """target dialect supports reflection of check constraints"""
  627. return exclusions.closed()
  628. @property
  629. def duplicate_key_raises_integrity_error(self):
  630. """target dialect raises IntegrityError when reporting an INSERT
  631. with a primary key violation. (hint: it should)
  632. """
  633. return exclusions.open()
  634. @property
  635. def unbounded_varchar(self):
  636. """Target database must support VARCHAR with no length"""
  637. return exclusions.open()
  638. @property
  639. def nvarchar_types(self):
  640. """target database supports NVARCHAR and NCHAR as an actual datatype"""
  641. return exclusions.closed()
  642. @property
  643. def unicode_data_no_special_types(self):
  644. """Target database/dialect can receive / deliver / compare data with
  645. non-ASCII characters in plain VARCHAR, TEXT columns, without the need
  646. for special "national" datatypes like NVARCHAR or similar.
  647. """
  648. return exclusions.open()
  649. @property
  650. def unicode_data(self):
  651. """Target database/dialect must support Python unicode objects with
  652. non-ASCII characters represented, delivered as bound parameters
  653. as well as in result rows.
  654. """
  655. return exclusions.open()
  656. @property
  657. def unicode_ddl(self):
  658. """Target driver must support some degree of non-ascii symbol
  659. names.
  660. """
  661. return exclusions.closed()
  662. @property
  663. def symbol_names_w_double_quote(self):
  664. """Target driver can create tables with a name like 'some " table'"""
  665. return exclusions.open()
  666. @property
  667. def datetime_interval(self):
  668. """target dialect supports rendering of a datetime.timedelta as a
  669. literal string, e.g. via the TypeEngine.literal_processor() method.
  670. """
  671. return exclusions.closed()
  672. @property
  673. def datetime_literals(self):
  674. """target dialect supports rendering of a date, time, or datetime as a
  675. literal string, e.g. via the TypeEngine.literal_processor() method.
  676. """
  677. return exclusions.closed()
  678. @property
  679. def datetime(self):
  680. """target dialect supports representation of Python
  681. datetime.datetime() objects."""
  682. return exclusions.open()
  683. @property
  684. def datetime_timezone(self):
  685. """target dialect supports representation of Python
  686. datetime.datetime() with tzinfo with DateTime(timezone=True)."""
  687. return exclusions.closed()
  688. @property
  689. def time_timezone(self):
  690. """target dialect supports representation of Python
  691. datetime.time() with tzinfo with Time(timezone=True)."""
  692. return exclusions.closed()
  693. @property
  694. def date_implicit_bound(self):
  695. """target dialect when given a date object will bind it such
  696. that the database server knows the object is a date, and not
  697. a plain string.
  698. """
  699. return exclusions.open()
  700. @property
  701. def time_implicit_bound(self):
  702. """target dialect when given a time object will bind it such
  703. that the database server knows the object is a time, and not
  704. a plain string.
  705. """
  706. return exclusions.open()
  707. @property
  708. def datetime_implicit_bound(self):
  709. """target dialect when given a datetime object will bind it such
  710. that the database server knows the object is a datetime, and not
  711. a plain string.
  712. """
  713. return exclusions.open()
  714. @property
  715. def datetime_microseconds(self):
  716. """target dialect supports representation of Python
  717. datetime.datetime() with microsecond objects."""
  718. return exclusions.open()
  719. @property
  720. def timestamp_microseconds(self):
  721. """target dialect supports representation of Python
  722. datetime.datetime() with microsecond objects but only
  723. if TIMESTAMP is used."""
  724. return exclusions.closed()
  725. @property
  726. def timestamp_microseconds_implicit_bound(self):
  727. """target dialect when given a datetime object which also includes
  728. a microseconds portion when using the TIMESTAMP data type
  729. will bind it such that the database server knows
  730. the object is a datetime with microseconds, and not a plain string.
  731. """
  732. return self.timestamp_microseconds
  733. @property
  734. def datetime_historic(self):
  735. """target dialect supports representation of Python
  736. datetime.datetime() objects with historic (pre 1970) values."""
  737. return exclusions.closed()
  738. @property
  739. def date(self):
  740. """target dialect supports representation of Python
  741. datetime.date() objects."""
  742. return exclusions.open()
  743. @property
  744. def date_coerces_from_datetime(self):
  745. """target dialect accepts a datetime object as the target
  746. of a date column."""
  747. return exclusions.open()
  748. @property
  749. def date_historic(self):
  750. """target dialect supports representation of Python
  751. datetime.datetime() objects with historic (pre 1970) values."""
  752. return exclusions.closed()
  753. @property
  754. def time(self):
  755. """target dialect supports representation of Python
  756. datetime.time() objects."""
  757. return exclusions.open()
  758. @property
  759. def time_microseconds(self):
  760. """target dialect supports representation of Python
  761. datetime.time() with microsecond objects."""
  762. return exclusions.open()
  763. @property
  764. def binary_comparisons(self):
  765. """target database/driver can allow BLOB/BINARY fields to be compared
  766. against a bound parameter value.
  767. """
  768. return exclusions.open()
  769. @property
  770. def binary_literals(self):
  771. """target backend supports simple binary literals, e.g. an
  772. expression like:
  773. .. sourcecode:: sql
  774. SELECT CAST('foo' AS BINARY)
  775. Where ``BINARY`` is the type emitted from :class:`.LargeBinary`,
  776. e.g. it could be ``BLOB`` or similar.
  777. Basically fails on Oracle.
  778. """
  779. return exclusions.open()
  780. @property
  781. def autocommit(self):
  782. """target dialect supports 'AUTOCOMMIT' as an isolation_level"""
  783. return exclusions.closed()
  784. @property
  785. def skip_autocommit_rollback(self):
  786. """target dialect supports the detect_autocommit_setting() method and
  787. uses the default implementation of do_rollback()"""
  788. return exclusions.closed()
  789. @property
  790. def isolation_level(self):
  791. """target dialect supports general isolation level settings.
  792. Note that this requirement, when enabled, also requires that
  793. the get_isolation_levels() method be implemented.
  794. """
  795. return exclusions.closed()
  796. def get_isolation_levels(self, config):
  797. """Return a structure of supported isolation levels for the current
  798. testing dialect.
  799. The structure indicates to the testing suite what the expected
  800. "default" isolation should be, as well as the other values that
  801. are accepted. The dictionary has two keys, "default" and "supported".
  802. The "supported" key refers to a list of all supported levels and
  803. it should include AUTOCOMMIT if the dialect supports it.
  804. If the :meth:`.DefaultRequirements.isolation_level` requirement is
  805. not open, then this method has no return value.
  806. E.g.::
  807. >>> testing.requirements.get_isolation_levels()
  808. {
  809. "default": "READ_COMMITTED",
  810. "supported": [
  811. "SERIALIZABLE", "READ UNCOMMITTED",
  812. "READ COMMITTED", "REPEATABLE READ",
  813. "AUTOCOMMIT"
  814. ]
  815. }
  816. """
  817. with config.db.connect() as conn:
  818. try:
  819. supported = conn.dialect.get_isolation_level_values(
  820. conn.connection.dbapi_connection
  821. )
  822. except NotImplementedError:
  823. return None
  824. else:
  825. return {
  826. "default": conn.dialect.default_isolation_level,
  827. "supported": supported,
  828. }
  829. @property
  830. def get_isolation_level_values(self):
  831. """target dialect supports the
  832. :meth:`_engine.Dialect.get_isolation_level_values`
  833. method added in SQLAlchemy 2.0.
  834. """
  835. def go(config):
  836. with config.db.connect() as conn:
  837. try:
  838. conn.dialect.get_isolation_level_values(
  839. conn.connection.dbapi_connection
  840. )
  841. except NotImplementedError:
  842. return False
  843. else:
  844. return True
  845. return exclusions.only_if(go)
  846. @property
  847. def dialect_level_isolation_level_param(self):
  848. """test that the dialect allows the 'isolation_level' argument
  849. to be handled by DefaultDialect"""
  850. def go(config):
  851. try:
  852. e = create_engine(
  853. config.db.url, isolation_level="READ COMMITTED"
  854. )
  855. except:
  856. return False
  857. else:
  858. return (
  859. e.dialect._on_connect_isolation_level == "READ COMMITTED"
  860. )
  861. return exclusions.only_if(go)
  862. @property
  863. def array_type(self):
  864. """Target platform implements a native ARRAY type"""
  865. return exclusions.closed()
  866. @property
  867. def json_type(self):
  868. """target platform implements a native JSON type."""
  869. return exclusions.closed()
  870. @property
  871. def json_array_indexes(self):
  872. """target platform supports numeric array indexes
  873. within a JSON structure"""
  874. return self.json_type
  875. @property
  876. def json_index_supplementary_unicode_element(self):
  877. return exclusions.open()
  878. @property
  879. def legacy_unconditional_json_extract(self):
  880. """Backend has a JSON_EXTRACT or similar function that returns a
  881. valid JSON string in all cases.
  882. Used to test a legacy feature and is not needed.
  883. """
  884. return exclusions.closed()
  885. @property
  886. def precision_numerics_general(self):
  887. """target backend has general support for moderately high-precision
  888. numerics."""
  889. return exclusions.open()
  890. @property
  891. def precision_numerics_enotation_small(self):
  892. """target backend supports Decimal() objects using E notation
  893. to represent very small values."""
  894. return exclusions.closed()
  895. @property
  896. def precision_numerics_enotation_large(self):
  897. """target backend supports Decimal() objects using E notation
  898. to represent very large values."""
  899. return exclusions.open()
  900. @property
  901. def precision_numerics_many_significant_digits(self):
  902. """target backend supports values with many digits on both sides,
  903. such as 319438950232418390.273596, 87673.594069654243
  904. """
  905. return exclusions.closed()
  906. @property
  907. def cast_precision_numerics_many_significant_digits(self):
  908. """same as precision_numerics_many_significant_digits but within the
  909. context of a CAST statement (hello MySQL)
  910. """
  911. return self.precision_numerics_many_significant_digits
  912. @property
  913. def server_defaults(self):
  914. """Target backend supports server side defaults for columns"""
  915. return exclusions.closed()
  916. @property
  917. def expression_server_defaults(self):
  918. """Target backend supports server side defaults with SQL expressions
  919. for columns"""
  920. return exclusions.closed()
  921. @property
  922. def implicit_decimal_binds(self):
  923. """target backend will return a selected Decimal as a Decimal, not
  924. a string.
  925. e.g.::
  926. expr = decimal.Decimal("15.7563")
  927. value = e.scalar(select(literal(expr)))
  928. assert value == expr
  929. See :ticket:`4036`
  930. """
  931. return exclusions.open()
  932. @property
  933. def numeric_received_as_decimal_untyped(self):
  934. """target backend will return result columns that are explicitly
  935. against NUMERIC or similar precision-numeric datatypes (not including
  936. FLOAT or INT types) as Python Decimal objects, and not as floats
  937. or ints, including when no SQLAlchemy-side typing information is
  938. associated with the statement (e.g. such as a raw SQL string).
  939. This should be enabled if either the DBAPI itself returns Decimal
  940. objects, or if the dialect has set up DBAPI-specific return type
  941. handlers such that Decimal objects come back automatically.
  942. """
  943. return exclusions.open()
  944. @property
  945. def nested_aggregates(self):
  946. """target database can select an aggregate from a subquery that's
  947. also using an aggregate
  948. """
  949. return exclusions.open()
  950. @property
  951. def recursive_fk_cascade(self):
  952. """target database must support ON DELETE CASCADE on a self-referential
  953. foreign key
  954. """
  955. return exclusions.open()
  956. @property
  957. def precision_numerics_retains_significant_digits(self):
  958. """A precision numeric type will return empty significant digits,
  959. i.e. a value such as 10.000 will come back in Decimal form with
  960. the .000 maintained."""
  961. return exclusions.closed()
  962. @property
  963. def infinity_floats(self):
  964. """The Float type can persist and load float('inf'), float('-inf')."""
  965. return exclusions.closed()
  966. @property
  967. def float_or_double_precision_behaves_generically(self):
  968. return exclusions.closed()
  969. @property
  970. def precision_generic_float_type(self):
  971. """target backend will return native floating point numbers with at
  972. least seven decimal places when using the generic Float type.
  973. """
  974. return exclusions.open()
  975. @property
  976. def literal_float_coercion(self):
  977. """target backend will return the exact float value 15.7563
  978. with only four significant digits from this statement:
  979. SELECT :param
  980. where :param is the Python float 15.7563
  981. i.e. it does not return 15.75629997253418
  982. """
  983. return exclusions.open()
  984. @property
  985. def floats_to_four_decimals(self):
  986. """target backend can return a floating-point number with four
  987. significant digits (such as 15.7563) accurately
  988. (i.e. without FP inaccuracies, such as 15.75629997253418).
  989. """
  990. return exclusions.open()
  991. @property
  992. def fetch_null_from_numeric(self):
  993. """target backend doesn't crash when you try to select a NUMERIC
  994. value that has a value of NULL.
  995. Added to support Pyodbc bug #351.
  996. """
  997. return exclusions.open()
  998. @property
  999. def float_is_numeric(self):
  1000. """target backend uses Numeric for Float/Dual"""
  1001. return exclusions.open()
  1002. @property
  1003. def text_type(self):
  1004. """Target database must support an unbounded Text() "
  1005. "type such as TEXT or CLOB"""
  1006. return exclusions.open()
  1007. @property
  1008. def empty_strings_varchar(self):
  1009. """target database can persist/return an empty string with a
  1010. varchar.
  1011. """
  1012. return exclusions.open()
  1013. @property
  1014. def empty_strings_text(self):
  1015. """target database can persist/return an empty string with an
  1016. unbounded text."""
  1017. return exclusions.open()
  1018. @property
  1019. def expressions_against_unbounded_text(self):
  1020. """target database supports use of an unbounded textual field in a
  1021. WHERE clause."""
  1022. return exclusions.open()
  1023. @property
  1024. def selectone(self):
  1025. """target driver must support the literal statement 'select 1'"""
  1026. return exclusions.open()
  1027. @property
  1028. def savepoints(self):
  1029. """Target database must support savepoints."""
  1030. return exclusions.closed()
  1031. @property
  1032. def two_phase_transactions(self):
  1033. """Target database must support two-phase transactions."""
  1034. return exclusions.closed()
  1035. @property
  1036. def update_from(self):
  1037. """Target must support UPDATE..FROM syntax"""
  1038. return exclusions.closed()
  1039. @property
  1040. def delete_from(self):
  1041. """Target must support DELETE FROM..FROM or DELETE..USING syntax"""
  1042. return exclusions.closed()
  1043. @property
  1044. def update_where_target_in_subquery(self):
  1045. """Target must support UPDATE (or DELETE) where the same table is
  1046. present in a subquery in the WHERE clause.
  1047. This is an ANSI-standard syntax that apparently MySQL can't handle,
  1048. such as:
  1049. .. sourcecode:: sql
  1050. UPDATE documents SET flag=1 WHERE documents.title IN
  1051. (SELECT max(documents.title) AS title
  1052. FROM documents GROUP BY documents.user_id
  1053. )
  1054. """
  1055. return exclusions.open()
  1056. @property
  1057. def mod_operator_as_percent_sign(self):
  1058. """target database must use a plain percent '%' as the 'modulus'
  1059. operator."""
  1060. return exclusions.closed()
  1061. @property
  1062. def percent_schema_names(self):
  1063. """target backend supports weird identifiers with percent signs
  1064. in them, e.g. 'some % column'.
  1065. this is a very weird use case but often has problems because of
  1066. DBAPIs that use python formatting. It's not a critical use
  1067. case either.
  1068. """
  1069. return exclusions.closed()
  1070. @property
  1071. def order_by_col_from_union(self):
  1072. """target database supports ordering by a column from a SELECT
  1073. inside of a UNION
  1074. E.g.:
  1075. .. sourcecode:: sql
  1076. (SELECT id, ...) UNION (SELECT id, ...) ORDER BY id
  1077. """
  1078. return exclusions.open()
  1079. @property
  1080. def order_by_label_with_expression(self):
  1081. """target backend supports ORDER BY a column label within an
  1082. expression.
  1083. Basically this:
  1084. .. sourcecode:: sql
  1085. select data as foo from test order by foo || 'bar'
  1086. Lots of databases including PostgreSQL don't support this,
  1087. so this is off by default.
  1088. """
  1089. return exclusions.closed()
  1090. @property
  1091. def order_by_collation(self):
  1092. def check(config):
  1093. try:
  1094. self.get_order_by_collation(config)
  1095. return False
  1096. except NotImplementedError:
  1097. return True
  1098. return exclusions.skip_if(check)
  1099. def get_order_by_collation(self, config):
  1100. raise NotImplementedError()
  1101. @property
  1102. def unicode_connections(self):
  1103. """Target driver must support non-ASCII characters being passed at
  1104. all.
  1105. """
  1106. return exclusions.open()
  1107. @property
  1108. def graceful_disconnects(self):
  1109. """Target driver must raise a DBAPI-level exception, such as
  1110. InterfaceError, when the underlying connection has been closed
  1111. and the execute() method is called.
  1112. """
  1113. return exclusions.open()
  1114. @property
  1115. def independent_connections(self):
  1116. """
  1117. Target must support simultaneous, independent database connections.
  1118. """
  1119. return exclusions.open()
  1120. @property
  1121. def independent_readonly_connections(self):
  1122. """
  1123. Target must support simultaneous, independent database connections
  1124. that will be used in a readonly fashion.
  1125. """
  1126. return exclusions.open()
  1127. @property
  1128. def skip_mysql_on_windows(self):
  1129. """Catchall for a large variety of MySQL on Windows failures"""
  1130. return exclusions.open()
  1131. @property
  1132. def ad_hoc_engines(self):
  1133. """Test environment must allow ad-hoc engine/connection creation.
  1134. No longer used in any tests; is a no-op
  1135. """
  1136. return exclusions.open()
  1137. @property
  1138. def no_windows(self):
  1139. return exclusions.skip_if(self._running_on_windows())
  1140. def _running_on_windows(self):
  1141. return exclusions.LambdaPredicate(
  1142. lambda: platform.system() == "Windows",
  1143. description="running on Windows",
  1144. )
  1145. @property
  1146. def timing_intensive(self):
  1147. from . import config
  1148. return config.add_to_marker.timing_intensive
  1149. @property
  1150. def posix(self):
  1151. return exclusions.skip_if(lambda: os.name != "posix")
  1152. @property
  1153. def memory_intensive(self):
  1154. from . import config
  1155. return config.add_to_marker.memory_intensive
  1156. @property
  1157. def threading_with_mock(self):
  1158. """Mark tests that use threading and mock at the same time - stability
  1159. issues have been observed with coverage
  1160. """
  1161. return exclusions.skip_if(
  1162. lambda config: config.options.has_coverage,
  1163. "Stability issues with coverage",
  1164. )
  1165. @property
  1166. def sqlalchemy2_stubs(self):
  1167. def check(config):
  1168. try:
  1169. __import__("sqlalchemy-stubs.ext.mypy")
  1170. except ImportError:
  1171. return False
  1172. else:
  1173. return True
  1174. return exclusions.only_if(check)
  1175. @property
  1176. def no_sqlalchemy2_stubs(self):
  1177. def check(config):
  1178. try:
  1179. __import__("sqlalchemy-stubs.ext.mypy")
  1180. except ImportError:
  1181. return False
  1182. else:
  1183. return True
  1184. return exclusions.skip_if(check)
  1185. @property
  1186. def up_to_date_typealias_type(self):
  1187. # this checks a particular quirk found in typing_extensions <=4.12.0
  1188. # using older python versions like 3.10 or 3.9, we use TypeAliasType
  1189. # from typing_extensions which does not provide for sufficient
  1190. # introspection prior to 4.13.0
  1191. def check(config):
  1192. import typing
  1193. import typing_extensions
  1194. TypeAliasType = getattr(
  1195. typing, "TypeAliasType", typing_extensions.TypeAliasType
  1196. )
  1197. TV = typing.TypeVar("TV")
  1198. TA_generic = TypeAliasType( # type: ignore
  1199. "TA_generic", typing.List[TV], type_params=(TV,)
  1200. )
  1201. return hasattr(TA_generic[int], "__value__")
  1202. return exclusions.only_if(check)
  1203. @property
  1204. def python38(self):
  1205. return exclusions.only_if(
  1206. lambda: util.py38, "Python 3.8 or above required"
  1207. )
  1208. @property
  1209. def python39(self):
  1210. return exclusions.only_if(
  1211. lambda: util.py39, "Python 3.9 or above required"
  1212. )
  1213. @property
  1214. def python310(self):
  1215. return exclusions.only_if(
  1216. lambda: util.py310, "Python 3.10 or above required"
  1217. )
  1218. @property
  1219. def python311(self):
  1220. return exclusions.only_if(
  1221. lambda: util.py311, "Python 3.11 or above required"
  1222. )
  1223. @property
  1224. def python312(self):
  1225. return exclusions.only_if(
  1226. lambda: util.py312, "Python 3.12 or above required"
  1227. )
  1228. @property
  1229. def python314(self):
  1230. return exclusions.only_if(
  1231. lambda: util.py314, "Python 3.14 or above required"
  1232. )
  1233. @property
  1234. def fail_python314b1(self):
  1235. return exclusions.fails_if(
  1236. lambda: util.compat.py314b1, "Fails as of python 3.14.0b1"
  1237. )
  1238. @property
  1239. def not_python314(self):
  1240. """This requirement is interim to assist with backporting of
  1241. issue #12405.
  1242. SQLAlchemy 2.0 still includes the ``await_fallback()`` method that
  1243. makes use of ``asyncio.get_event_loop_policy()``. This is removed
  1244. in SQLAlchemy 2.1.
  1245. """
  1246. return exclusions.skip_if(
  1247. lambda: util.py314, "Python 3.14 or above not supported"
  1248. )
  1249. @property
  1250. def pep649(self):
  1251. """pep649 deferred evaluation of annotations without future mode"""
  1252. return self.python314
  1253. @property
  1254. def cpython(self):
  1255. return exclusions.only_if(
  1256. lambda: util.cpython, "cPython interpreter needed"
  1257. )
  1258. @property
  1259. def gil_enabled(self):
  1260. return exclusions.only_if(
  1261. lambda: not util.freethreading, "GIL-enabled build needed"
  1262. )
  1263. @property
  1264. def is64bit(self):
  1265. return exclusions.only_if(lambda: util.is64bit, "64bit required")
  1266. @property
  1267. def patch_library(self):
  1268. def check_lib():
  1269. try:
  1270. __import__("patch")
  1271. except ImportError:
  1272. return False
  1273. else:
  1274. return True
  1275. return exclusions.only_if(check_lib, "patch library needed")
  1276. @property
  1277. def predictable_gc(self):
  1278. """target platform must remove all cycles unconditionally when
  1279. gc.collect() is called, as well as clean out unreferenced subclasses.
  1280. """
  1281. return self.cpython + self.gil_enabled
  1282. @property
  1283. def no_coverage(self):
  1284. """Test should be skipped if coverage is enabled.
  1285. This is to block tests that exercise libraries that seem to be
  1286. sensitive to coverage, such as PostgreSQL notice logging.
  1287. """
  1288. return exclusions.skip_if(
  1289. lambda config: config.options.has_coverage,
  1290. "Issues observed when coverage is enabled",
  1291. )
  1292. def _has_mysql_on_windows(self, config):
  1293. return False
  1294. def _has_mysql_fully_case_sensitive(self, config):
  1295. return False
  1296. @property
  1297. def sqlite(self):
  1298. return exclusions.skip_if(lambda: not self._has_sqlite())
  1299. @property
  1300. def cextensions(self):
  1301. return exclusions.skip_if(
  1302. lambda: not util.has_compiled_ext(),
  1303. "Cython extensions not installed",
  1304. )
  1305. def _has_sqlite(self):
  1306. from sqlalchemy import create_engine
  1307. try:
  1308. create_engine("sqlite://")
  1309. return True
  1310. except ImportError:
  1311. return False
  1312. @property
  1313. def async_dialect(self):
  1314. """dialect makes use of await_() to invoke operations on the DBAPI."""
  1315. return exclusions.closed()
  1316. @property
  1317. def asyncio(self):
  1318. return self.greenlet
  1319. @property
  1320. def no_greenlet(self):
  1321. def go(config):
  1322. try:
  1323. import greenlet # noqa: F401
  1324. except ImportError:
  1325. return True
  1326. else:
  1327. return False
  1328. return exclusions.only_if(go)
  1329. @property
  1330. def greenlet(self):
  1331. def go(config):
  1332. if not _test_asyncio.ENABLE_ASYNCIO:
  1333. return False
  1334. try:
  1335. import greenlet # noqa: F401
  1336. except ImportError:
  1337. return False
  1338. else:
  1339. return True
  1340. return exclusions.only_if(go)
  1341. @property
  1342. def computed_columns(self):
  1343. "Supports computed columns"
  1344. return exclusions.closed()
  1345. @property
  1346. def computed_columns_stored(self):
  1347. "Supports computed columns with `persisted=True`"
  1348. return exclusions.closed()
  1349. @property
  1350. def computed_columns_virtual(self):
  1351. "Supports computed columns with `persisted=False`"
  1352. return exclusions.closed()
  1353. @property
  1354. def computed_columns_default_persisted(self):
  1355. """If the default persistence is virtual or stored when `persisted`
  1356. is omitted"""
  1357. return exclusions.closed()
  1358. @property
  1359. def computed_columns_reflect_persisted(self):
  1360. """If persistence information is returned by the reflection of
  1361. computed columns"""
  1362. return exclusions.closed()
  1363. @property
  1364. def supports_distinct_on(self):
  1365. """If a backend supports the DISTINCT ON in a select"""
  1366. return exclusions.closed()
  1367. @property
  1368. def supports_is_distinct_from(self):
  1369. """Supports some form of "x IS [NOT] DISTINCT FROM y" construct.
  1370. Different dialects will implement their own flavour, e.g.,
  1371. sqlite will emit "x IS NOT y" instead of "x IS DISTINCT FROM y".
  1372. .. seealso::
  1373. :meth:`.ColumnOperators.is_distinct_from`
  1374. """
  1375. return exclusions.skip_if(
  1376. lambda config: not config.db.dialect.supports_is_distinct_from,
  1377. "driver doesn't support an IS DISTINCT FROM construct",
  1378. )
  1379. @property
  1380. def identity_columns(self):
  1381. """If a backend supports GENERATED { ALWAYS | BY DEFAULT }
  1382. AS IDENTITY"""
  1383. return exclusions.closed()
  1384. @property
  1385. def identity_columns_standard(self):
  1386. """If a backend supports GENERATED { ALWAYS | BY DEFAULT }
  1387. AS IDENTITY with a standard syntax.
  1388. This is mainly to exclude MSSql.
  1389. """
  1390. return exclusions.closed()
  1391. @property
  1392. def regexp_match(self):
  1393. """backend supports the regexp_match operator."""
  1394. return exclusions.closed()
  1395. @property
  1396. def regexp_replace(self):
  1397. """backend supports the regexp_replace operator."""
  1398. return exclusions.closed()
  1399. @property
  1400. def fetch_first(self):
  1401. """backend supports the fetch first clause."""
  1402. return exclusions.closed()
  1403. @property
  1404. def fetch_percent(self):
  1405. """backend supports the fetch first clause with percent."""
  1406. return exclusions.closed()
  1407. @property
  1408. def fetch_ties(self):
  1409. """backend supports the fetch first clause with ties."""
  1410. return exclusions.closed()
  1411. @property
  1412. def fetch_no_order_by(self):
  1413. """backend supports the fetch first without order by"""
  1414. return exclusions.closed()
  1415. @property
  1416. def fetch_offset_with_options(self):
  1417. """backend supports the offset when using fetch first with percent
  1418. or ties. basically this is "not mssql"
  1419. """
  1420. return exclusions.closed()
  1421. @property
  1422. def fetch_expression(self):
  1423. """backend supports fetch / offset with expression in them, like
  1424. SELECT * FROM some_table
  1425. OFFSET 1 + 1 ROWS FETCH FIRST 1 + 1 ROWS ONLY
  1426. """
  1427. return exclusions.closed()
  1428. @property
  1429. def autoincrement_without_sequence(self):
  1430. """If autoincrement=True on a column does not require an explicit
  1431. sequence. This should be false only for oracle.
  1432. """
  1433. return exclusions.open()
  1434. @property
  1435. def generic_classes(self):
  1436. "If X[Y] can be implemented with ``__class_getitem__``. py3.7+"
  1437. return exclusions.open()
  1438. @property
  1439. def json_deserializer_binary(self):
  1440. "indicates if the json_deserializer function is called with bytes"
  1441. return exclusions.closed()
  1442. @property
  1443. def reflect_table_options(self):
  1444. """Target database must support reflecting table_options."""
  1445. return exclusions.closed()
  1446. @property
  1447. def materialized_views(self):
  1448. """Target database must support MATERIALIZED VIEWs."""
  1449. return exclusions.closed()
  1450. @property
  1451. def materialized_views_reflect_pk(self):
  1452. """Target database reflect MATERIALIZED VIEWs pks."""
  1453. return exclusions.closed()
  1454. @property
  1455. def supports_bitwise_or(self):
  1456. """Target database supports bitwise or"""
  1457. return exclusions.closed()
  1458. @property
  1459. def supports_bitwise_and(self):
  1460. """Target database supports bitwise and"""
  1461. return exclusions.closed()
  1462. @property
  1463. def supports_bitwise_not(self):
  1464. """Target database supports bitwise not"""
  1465. return exclusions.closed()
  1466. @property
  1467. def supports_bitwise_xor(self):
  1468. """Target database supports bitwise xor"""
  1469. return exclusions.closed()
  1470. @property
  1471. def supports_bitwise_shift(self):
  1472. """Target database supports bitwise left or right shift"""
  1473. return exclusions.closed()
  1474. @property
  1475. def like_escapes(self):
  1476. """Target backend supports custom ESCAPE characters
  1477. with LIKE comparisons"""
  1478. return exclusions.open()