Ejemplo n.º 1
0
    def ctes_on_dml(self):
        """target database supports CTES which consist of INSERT, UPDATE
        or DELETE *within* the CTE, e.g. WITH x AS (UPDATE....)"""

        return only_if(
            ['postgresql']
        )
Ejemplo n.º 2
0
    def ctes_on_dml(self):
        """target database supports CTES which consist of INSERT, UPDATE
        or DELETE"""

        return only_if(
            ['postgresql']
        )
Ejemplo n.º 3
0
 def bulletproof_pickle(self):
     from sqlalchemy.util import pickle
     return only_if(
         lambda: pickle.__name__ == 'cPickle' and \
             sys.version_info < (3, 0) and not util.pypy,
         "Needs Python 2.x cPickle"
     )
Ejemplo n.º 4
0
    def mod_operator_as_percent_sign(self):
        """target database must use a plain percent '%' as the 'modulus'
        operator."""

        return only_if(
                    ['mysql', 'sqlite', 'postgresql+psycopg2', 'mssql']
                )
Ejemplo n.º 5
0
 def non_broken_pickle(self):
     from sqlalchemy.util import pickle
     return only_if(
         lambda: not util.pypy and pickle.__name__ == 'cPickle'
             or sys.version_info >= (3, 2),
         "Needs cPickle+cPython or newer Python 3 pickle"
     )
Ejemplo n.º 6
0
    def mysql_zero_date(self):
        def check(config):
            if not against(config, 'mysql'):
                return False

            row = config.db.execute("show variables like 'sql_mode'").first()
            return not row or "NO_ZERO_DATE" not in row[1]

        return only_if(check)
Ejemplo n.º 7
0
    def mysql_non_strict(self):
        def check(config):
            if not against(config, 'mysql'):
                return False

            row = config.db.execute("show variables like 'sql_mode'").first()
            return not row or "STRICT_TRANS_TABLES" not in row[1]

        return only_if(check)
Ejemplo n.º 8
0
    def mysql_ngram_fulltext(self):
        def check(config):
            return (
                against(config, "mysql")
                and not config.db.dialect._is_mariadb
                and config.db.dialect.server_version_info >= (5, 7)
            )

        return only_if(check)
Ejemplo n.º 9
0
 def _has_pg_extension(self, name):
     def check(config):
         if not against(config, "postgresql"):
             return False
         count = config.db.scalar(
             "SELECT count(*) FROM pg_extension "
             "WHERE extname='%s'" % name)
         return bool(count)
     return only_if(check, "needs %s extension" % name)
Ejemplo n.º 10
0
    def hstore(self):
        def check_hstore(config):
            if not against(config, "postgresql"):
                return False
            try:
                config.db.execute("SELECT 'a=>1,a=>2'::hstore;")
                return True
            except Exception:
                return False

        return only_if(check_hstore)
Ejemplo n.º 11
0
    def hstore(self):
        def check_hstore():
            if not against("postgresql"):
                return False
            try:
                self.db.execute("SELECT 'a=>1,a=>2'::hstore;")
                return True
            except:
                return False

        return only_if(check_hstore)
Ejemplo n.º 12
0
    def range_types(self):
        def check_range_types():
            if not against("postgresql+psycopg2"):
                return False
            try:
                self.db.execute("select '[1,2)'::int4range;")
                # only supported in psycopg 2.5+
                from psycopg2.extras import NumericRange
                return True
            except:
                return False

        return only_if(check_range_types)
Ejemplo n.º 13
0
    def range_types(self):
        def check_range_types(config):
            if not against(
                    config,
                    ["postgresql+psycopg2", "postgresql+psycopg2cffi"]):
                return False
            try:
                config.db.scalar("select '[1,2)'::int4range;")
                return True
            except:
                return False

        return only_if(check_range_types)
Ejemplo n.º 14
0
 def pyodbc_fast_executemany(self):
     def has_fastexecutemany(config):
         if not against(config, "mssql+pyodbc"):
             return False
         if config.db.dialect._dbapi_version() < (4, 0, 19):
             return False
         with config.db.connect() as conn:
             drivername = conn.connection.connection.getinfo(
                 config.db.dialect.dbapi.SQL_DRIVER_NAME)
             # on linux this is 'libmsodbcsql-13.1.so.9.2'.
             # don't know what it is on windows
             return "msodbc" in drivername
     return only_if(
         has_fastexecutemany,
         "only on pyodbc > 4.0.19 w/ msodbc driver")
Ejemplo n.º 15
0
    def ctes(self):
        """Target database supports CTEs"""

        return only_if(
            ['postgresql', 'mssql']
        )
Ejemplo n.º 16
0
    def mysql_non_strict(self):
        def check(config):
             row = config.db.execute("show variables like 'sql_mode'").first()
             return not row or "STRICT" not in row[1]

        return only_if(check)
Ejemplo n.º 17
0
    def ctes_on_dml(self):
        """target database supports CTES which consist of INSERT, UPDATE
        or DELETE"""

        return only_if(['postgresql'])
Ejemplo n.º 18
0
 def identity_columns(self):
     return only_if(["greenplum >= 10"])
Ejemplo n.º 19
0
 def supports_distinct_on(self):
     """If a backend supports the DISTINCT ON in a select"""
     return only_if(["postgresql"])
Ejemplo n.º 20
0
    def mod_operator_as_percent_sign(self):
        """target database must use a plain percent '%' as the 'modulus'
        operator."""

        return only_if(["mysql", "sqlite", "postgresql+psycopg2", "mssql"])
Ejemplo n.º 21
0
    def mysql_non_strict(self):
        def check(config):
            row = config.db.execute("show variables like 'sql_mode'").first()
            return not row or "STRICT" not in row[1]

        return only_if(check)
Ejemplo n.º 22
0
 def cpython(self):
     return only_if(lambda: util.cpython,
            "cPython interpreter needed"
          )
Ejemplo n.º 23
0
 def mysql_fsp(self):
     return only_if('mysql >= 5.6.4')
Ejemplo n.º 24
0
    def mysql_zero_date(self):
        def check(config):
            row = config.db.execute("show variables like 'sql_mode'").first()
            return not row or "NO_ZERO_DATE" not in row[1]

        return only_if(check)
Ejemplo n.º 25
0
    def ctes(self):
        """Target database supports CTEs"""

        return only_if(['postgresql', 'mssql'])
Ejemplo n.º 26
0
    def ctes_on_dml(self):
        """target database supports CTES which consist of INSERT, UPDATE
        or DELETE *within* the CTE, e.g. WITH x AS (UPDATE....)"""

        return only_if(['postgresql'])
Ejemplo n.º 27
0
 def mysql_ngram_fulltext(self):
     def check(config):
         return against(config, "mysql") and \
             not config.db.dialect._is_mariadb and \
             config.db.dialect.server_version_info >= (5, 7)
     return only_if(check)
Ejemplo n.º 28
0
 def mysql_fully_case_sensitive(self):
     return only_if(self._has_mysql_fully_case_sensitive)
Ejemplo n.º 29
0
 def non_broken_pickle(self):
     from sqlalchemy.util import pickle
     return only_if(
         lambda: not util.pypy and pickle.__name__ == 'cPickle' or sys.
         version_info >= (3, 2),
         "Needs cPickle+cPython or newer Python 3 pickle")
 def cpython(self):
     """Insert DocString Here."""
     return exclusions.only_if(lambda: util.cpython,
                               "cPython interpreter needed")
Ejemplo n.º 31
0
 def postgresql_utf8_server_encoding(self):
     return only_if(lambda config: against(config, 'postgresql') and config.
                    db.scalar("show server_encoding").lower() == "utf8")
Ejemplo n.º 32
0
 def window_functions(self):
     return only_if(
         ["postgresql>=8.4", "mssql", "oracle", "sqlite>=3.25.0"],
         "Backend does not support window functions",
     )
Ejemplo n.º 33
0
 def sql_expressions_inserted_as_primary_key(self):
     return only_if([self.returning, self.sqlite])
Ejemplo n.º 34
0
 def supports_for_update_of(self):
     return only_if(lambda config: config.db.dialect.supports_for_update_of)
Ejemplo n.º 35
0
 def oracle5x(self):
     return only_if(
         lambda config: against(config, "oracle+cx_oracle") and
         config.db.dialect.cx_oracle_ver < (6, )
     )
Ejemplo n.º 36
0
    def mod_operator_as_percent_sign(self):
        """target database must use a plain percent '%' as the 'modulus'
        operator."""

        return only_if(['mysql', 'sqlite', 'postgresql+psycopg2', 'mssql'])
Ejemplo n.º 37
0
    def mysql_timestamp_reflection(self):
        def go(config):
            return (not self._mariadb_102(config)
                    or self.sqlalchemy_1115.enabled)

        return exclusions.only_if(go)
Ejemplo n.º 38
0
 def cxoracle6_or_greater(self):
     return only_if(
         lambda config: against(config, "oracle+cx_oracle")
         and config.db.dialect.cx_oracle_ver >= (6,)
     )
Ejemplo n.º 39
0
 def window_functions(self):
     return only_if(["postgresql", "mssql", "oracle"],
                    "Backend does not support window functions")
Ejemplo n.º 40
0
 def mysql_fsp(self):
     return only_if("mysql >= 5.6.4")
Ejemplo n.º 41
0
 def sql_expressions_inserted_as_primary_key(self):
     return only_if([self.returning, self.sqlite])
Ejemplo n.º 42
0
    def autocommit(self):
        """target dialect supports 'AUTOCOMMIT' as an isolation_level"""

        return self.isolation_level + only_if(
            lambda config: "AUTOCOMMIT" in self.get_isolation_levels(config)[
                "supported"])
Ejemplo n.º 43
0
 def window_functions(self):
     return only_if(
         ["postgresql>=8.4", "mssql", "oracle", "sqlite>=3.25.0"],
         "Backend does not support window functions",
     )
Ejemplo n.º 44
0
 def mysql_fsp(self):
     return only_if('mysql >= 5.6.4')
Ejemplo n.º 45
0
 def mysql_fully_case_sensitive(self):
     return only_if(self._has_mysql_fully_case_sensitive)
Ejemplo n.º 46
0
    def postgresql_utf8_server_encoding(self):

        return only_if(lambda config: against(config, "postgresql") and config.
                       db.connect(close_with_result=True).exec_driver_sql(
                           "show server_encoding").scalar().lower() == "utf8")
Ejemplo n.º 47
0
 def cxoracle6_or_greater(self):
     return only_if(lambda config: against(config, "oracle+cx_oracle") and
                    config.db.dialect.cx_oracle_ver >= (6, ))
Ejemplo n.º 48
0
 def postgresql_utf8_server_encoding(self):
     return only_if(
         lambda config: against(config, 'postgresql') and
         config.db.scalar("show server_encoding").lower() == "utf8"
     )
Ejemplo n.º 49
0
 def oracle5x(self):
     return only_if(lambda config: against(config, "oracle+cx_oracle") and
                    config.db.dialect.cx_oracle_ver < (6, ))
Ejemplo n.º 50
0
 def window_functions(self):
     return only_if([
                 "postgresql", "mssql", "oracle"
             ], "Backend does not support window functions")
Ejemplo n.º 51
0
 def computed_columns_default_persisted(self):
     return self.computed_columns + only_if("postgresql")
Ejemplo n.º 52
0
 def cpython(self):
     return only_if(lambda: util.cpython, "cPython interpreter needed")
Ejemplo n.º 53
0
    def mod_operator_as_percent_sign(self):
        """target database must use a plain percent '%' as the 'modulus'
        operator."""

        return only_if(["mysql", "sqlite", "postgresql+psycopg2", "mssql"])
Ejemplo n.º 54
0
 def mysql_fsp(self):
     return only_if("mysql >= 5.6.4")
 def postgresql_utf8_server_encoding(self):
     return only_if(
         config.db.scalar("show server_encoding").lower() == "utf8")