requirements.py 54 KB

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