Here are the examples of the python api sqlalchemy.testing.exclusions.only_on taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
71 Examples
3
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def deferrable_fks(self):
"""target database must support deferrable fks"""
return only_on(["oracle"])
@property
3
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def tuple_in(self):
def _sqlite_tuple_in(config):
return against(
config, "sqlite"
) and config.db.dialect.dbapi.sqlite_version_info >= (3, 15, 0)
return only_on(["mysql", "postgresql", _sqlite_tuple_in])
@property
3
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def isolation_level(self):
return only_on(
("postgresql", "sqlite", "mysql", "mssql", "oracle"),
"DBAPI has no isolation level support",
) + fails_on(
"postgresql+pypostgresql",
"pypostgresql bombs on multiple isolation level calls",
)
def get_isolation_levels(self, config):
3
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def sequences_as_server_defaults(self):
"""Target database must support SEQUENCE as a server side default."""
return only_on(
"postgresql", "doesn't support sequences as a server side default."
)
@property
3
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def update_from(self):
"""Target must support UPDATE..FROM syntax"""
return only_on(
["postgresql", "mssql", "mysql"],
"Backend does not support UPDATE..FROM",
)
@property
3
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def delete_from(self):
"""Target must support DELETE FROM..FROM or DELETE..USING syntax"""
return only_on(
["postgresql", "mssql", "mysql", "sybase"],
"Backend does not support DELETE..FROM",
)
@property
3
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def cross_schema_fk_reflection(self):
"""target system must support reflection of inter-schema foreign keys
"""
return only_on(["postgresql", "mysql", "mssql"])
@property
3
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def implicit_default_schema(self):
"""target system has a strong concept of 'default' schema that can
be referred to implicitly.
basically, PostgreSQL.
"""
return only_on(["postgresql"])
@property
3
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def temp_table_names(self):
"""target dialect supports listing of temporary table names"""
return only_on(["sqlite", "oracle"]) + skip_if(self._sqlite_file_db)
@property
3
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def temporary_views(self):
"""target database supports temporary views"""
return only_on(["sqlite", "postgresql"]) + skip_if(
self._sqlite_file_db
)
@property
3
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def ctes_with_update_delete(self):
"""target database supports CTES that ride on top of a normal UPDATE
or DELETE statement which refers to the CTE in a correlated subquery.
"""
return only_on(
[
"postgresql",
"mssql",
# "oracle" - oracle can do this but SQLAlchemy doesn't support
# their syntax yet
]
)
@property
3
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def array_type(self):
return only_on(
[
lambda config: against(config, "postgresql")
and not against(config, "+pg8000")
and not against(config, "+zxjdbc")
]
)
@property
3
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def reflects_json_type(self):
return only_on(
[
lambda config: against(config, "mysql >= 5.7")
and not config.db.dialect._is_mariadb,
"postgresql >= 9.3",
"sqlite >= 3.9",
]
)
@property
3
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def timestamp_microseconds(self):
"""target dialect supports representation of Python
datetime.datetime() with microsecond objects but only
if TIMESTAMP is used."""
return only_on(["oracle"])
@property
3
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def postgresql_jsonb(self):
return only_on("postgresql >= 9.4") + skip_if(
lambda config: config.db.dialect.driver == "pg8000"
and config.db.dialect._dbapi_version < = (1, 10, 1)
)
@property
3
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def psycopg2_or_pg8000_compatibility(self):
return only_on(
[
"postgresql+psycopg2",
"postgresql+psycopg2cffi",
"postgresql+pg8000",
]
)
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def table_ddl_if_exists(self):
"""target platform supports IF NOT EXISTS / IF EXISTS for tables."""
return only_on(["postgresql", "mysql", "mariadb", "sqlite"])
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def index_ddl_if_exists(self):
"""target platform supports IF NOT EXISTS / IF EXISTS for indexes."""
# mariadb but not mysql, tested up to mysql 8
return only_on(["postgresql", "mariadb", "sqlite"])
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def deferrable_fks(self):
"""target database must support deferrable fks"""
return only_on(["oracle", "postgresql"])
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def foreign_key_constraint_option_reflection_ondelete(self):
return only_on(
["postgresql", "mysql", "mariadb", "sqlite", "oracle", "mssql"]
)
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def format_paramstyle(self):
return only_on(
[
"mysql+mysqldb",
"mysql+pymysql",
"mysql+cymysql",
"mysql+mysqlconnector",
"mariadb+mysqldb",
"mariadb+pymysql",
"mariadb+cymysql",
"mariadb+mysqlconnector",
"postgresql+asyncpg",
"postgresql+pg8000",
]
)
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def pyformat_paramstyle(self):
return only_on(
[
"postgresql+psycopg",
"postgresql+psycopg2",
"postgresql+psycopg2cffi",
"mysql+mysqlconnector",
"mysql+pymysql",
"mysql+cymysql",
"mariadb+mysqlconnector",
"mariadb+pymysql",
"mariadb+cymysql",
"mssql+pymssql",
]
)
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def tuple_in(self):
def _sqlite_tuple_in(config):
return against(
config, "sqlite"
) and config.db.dialect.dbapi.sqlite_version_info >= (3, 15, 0)
return only_on(
["mysql", "mariadb", "postgresql", _sqlite_tuple_in, "oracle"]
)
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def isolation_level(self):
return only_on(
("postgresql", "sqlite", "mysql", "mariadb", "mssql", "oracle"),
"DBAPI has no isolation level support",
)
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def sequences_as_server_defaults(self):
"""Target database must support SEQUENCE as a server side default."""
return self.sequences + only_on(
["postgresql", "mariadb", "oracle >= 18"],
"doesn't support sequences as a server side default.",
)
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def update_from(self):
"""Target must support UPDATE..FROM syntax"""
return only_on(
["postgresql", "mssql", "mysql", "mariadb"],
"Backend does not support UPDATE..FROM",
)
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def delete_from(self):
"""Target must support DELETE FROM..FROM or DELETE..USING syntax"""
return only_on(
["postgresql", "mssql", "mysql", "mariadb"],
"Backend does not support DELETE..FROM",
)
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def cross_schema_fk_reflection(self):
"""target system must support reflection of inter-schema foreign
keys"""
return only_on(["postgresql", "mysql", "mariadb", "mssql"])
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def implicit_default_schema(self):
"""target system has a strong concept of 'default' schema that can
be referred to implicitly.
basically, PostgreSQL.
TODO: what does this mean? all the backends have a "default"
schema
"""
return only_on(["postgresql"])
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def dbapi_lastrowid(self):
""" "target backend includes a 'lastrowid' accessor on the DBAPI
cursor object.
"""
return skip_if("mssql+pymssql", "crashes on pymssql") + only_on(
[
"mysql",
"mariadb",
"sqlite+pysqlite",
"sqlite+aiosqlite",
"sqlite+pysqlcipher",
"mssql",
]
)
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def tuple_valued_builtin_functions(self):
return only_on(
lambda config: self._sqlite_json(config)
or against(config, "postgresql")
)
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def array_type(self):
return only_on(
[
lambda config: against(config, "postgresql")
and not against(config, "+pg8000")
]
)
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def legacy_unconditional_json_extract(self):
"""Backend has a JSON_EXTRACT or similar function that returns a
valid JSON string in all cases.
Used to test a legacy feature and is not needed.
"""
return self.json_type + only_on(
["postgresql", "mysql", "mariadb", "sqlite"]
)
def _sqlite_file_db(self, config):
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def async_dialect(self):
"""dialect makes use of await_() to invoke operations on the DBAPI."""
return only_on(
LambdaPredicate(
lambda config: config.db.dialect.is_async,
"Async dialect required",
)
)
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def psycopg_compatibility(self):
return only_on(
[
"postgresql+psycopg2",
"postgresql+psycopg2cffi",
"postgresql+psycopg",
]
)
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def index_reflects_included_columns(self):
return only_on(["postgresql >= 11", "mssql"])
# mssql>= 11 -> >= MS_2012_VERSION
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def fetch_first(self):
return only_on(
["postgresql", "mssql >= 11", "oracle >= 12", "mariadb >= 10.6"]
)
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def fetch_ties(self):
return only_on(
[
"postgresql >= 13",
"mssql >= 11",
"oracle >= 12",
"mariadb >= 10.6",
]
)
@property
3
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def mssql_filestream(self):
"returns if mssql supports filestream"
def check(config):
with config.db.connect() as conn:
res = conn.exec_driver_sql(
"SELECT [type] FROM sys.master_files WHERE "
"database_id = DB_ID() AND [type] = 2"
).scalar()
return res is not None
return only_on(["mssql"]) + only_if(check)
0
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def foreign_key_constraint_option_reflection_ondelete(self):
return only_on(["postgresql", "mysql", "sqlite", "oracle"])
@property
0
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def foreign_key_constraint_option_reflection_onupdate(self):
return only_on(["postgresql", "mysql", "sqlite"])
@property
0
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def comment_reflection(self):
return only_on(["postgresql", "mysql", "oracle"])
@property
0
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def indexes_with_expressions(self):
return only_on(["postgresql", "sqlite>=3.9.0"])
@property
0
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def ctes(self):
"""Target database supports CTEs"""
return only_on(
[
lambda config: against(config, "mysql")
and (
(
config.db.dialect._is_mariadb
and config.db.dialect._mariadb_normalized_version_info
>= (10, 2)
)
or (
not config.db.dialect._is_mariadb
and config.db.dialect.server_version_info >= (8,)
)
),
"postgresql",
"mssql",
"oracle",
"sqlite>=3.8.3",
]
)
@property
0
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def json_type(self):
return only_on(
[
lambda config: against(config, "mysql")
and (
(
not config.db.dialect._is_mariadb
and against(config, "mysql >= 5.7")
)
or (
config.db.dialect._mariadb_normalized_version_info
>= (10, 2, 7)
)
),
"postgresql >= 9.3",
self._sqlite_json,
]
)
@property
0
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def psycopg2_compatibility(self):
return only_on(["postgresql+psycopg2", "postgresql+psycopg2cffi"])
@property
0
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def mssql_freetds(self):
return only_on(["mssql+pymssql"])
@property
0
Source : requirements.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def python_profiling_backend(self):
return only_on([self._sqlite_memory_db])
@property
0
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def fk_constraint_option_reflection_ondelete_restrict(self):
return only_on(["postgresql", "sqlite", self._mysql_80])
@property
0
Source : requirements.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def fk_constraint_option_reflection_ondelete_noaction(self):
return only_on(["postgresql", "mysql", "mariadb", "sqlite", "mssql"])
@property
See More Examples