From 014e9128546a0c32cdd90ad5ccdcc21269987ee0 Mon Sep 17 00:00:00 2001 From: Diana Clarke Date: Mon, 19 Nov 2012 23:29:08 -0500 Subject: [PATCH] juts a 'expected 2 blank lines' pep8 pass --- lib/sqlalchemy/dialects/__init__.py | 1 + lib/sqlalchemy/dialects/firebird/base.py | 2 ++ lib/sqlalchemy/dialects/firebird/fdb.py | 1 + .../dialects/firebird/kinterbasdb.py | 2 ++ lib/sqlalchemy/dialects/informix/base.py | 7 ++++ .../dialects/informix/informixdb.py | 2 ++ lib/sqlalchemy/dialects/mssql/adodbapi.py | 1 + lib/sqlalchemy/dialects/mssql/base.py | 27 +++++++++++++++ .../dialects/mssql/information_schema.py | 1 + lib/sqlalchemy/dialects/mssql/mxodbc.py | 4 +++ lib/sqlalchemy/dialects/mssql/pymssql.py | 2 ++ lib/sqlalchemy/dialects/mssql/pyodbc.py | 1 + lib/sqlalchemy/dialects/mssql/zxjdbc.py | 1 + lib/sqlalchemy/dialects/mysql/base.py | 33 +++++++++++++++++-- .../dialects/mysql/mysqlconnector.py | 4 +++ lib/sqlalchemy/dialects/mysql/mysqldb.py | 2 ++ lib/sqlalchemy/dialects/mysql/oursql.py | 1 + lib/sqlalchemy/dialects/mysql/pymysql.py | 1 + lib/sqlalchemy/dialects/mysql/pyodbc.py | 2 ++ lib/sqlalchemy/dialects/mysql/zxjdbc.py | 1 + lib/sqlalchemy/dialects/oracle/base.py | 12 +++++++ lib/sqlalchemy/dialects/oracle/cx_oracle.py | 19 ++++++++++- lib/sqlalchemy/dialects/oracle/zxjdbc.py | 1 + lib/sqlalchemy/testing/plugin/noseplugin.py | 17 +++++++++- 24 files changed, 141 insertions(+), 4 deletions(-) diff --git a/lib/sqlalchemy/dialects/__init__.py b/lib/sqlalchemy/dialects/__init__.py index 2d400aa60d..af0dc37eab 100644 --- a/lib/sqlalchemy/dialects/__init__.py +++ b/lib/sqlalchemy/dialects/__init__.py @@ -18,6 +18,7 @@ __all__ = ( from .. import util + def _auto_fn(name): """default dialect importer. diff --git a/lib/sqlalchemy/dialects/firebird/base.py b/lib/sqlalchemy/dialects/firebird/base.py index df20060e58..d40ca30dff 100644 --- a/lib/sqlalchemy/dialects/firebird/base.py +++ b/lib/sqlalchemy/dialects/firebird/base.py @@ -130,6 +130,7 @@ class _StringType(sqltypes.String): self.charset = charset super(_StringType, self).__init__(**kw) + class VARCHAR(_StringType, sqltypes.VARCHAR): """Firebird VARCHAR type""" __visit_name__ = 'VARCHAR' @@ -137,6 +138,7 @@ class VARCHAR(_StringType, sqltypes.VARCHAR): def __init__(self, length=None, **kwargs): super(VARCHAR, self).__init__(length=length, **kwargs) + class CHAR(_StringType, sqltypes.CHAR): """Firebird CHAR type""" __visit_name__ = 'CHAR' diff --git a/lib/sqlalchemy/dialects/firebird/fdb.py b/lib/sqlalchemy/dialects/firebird/fdb.py index aac3579d6f..ce872d5623 100644 --- a/lib/sqlalchemy/dialects/firebird/fdb.py +++ b/lib/sqlalchemy/dialects/firebird/fdb.py @@ -26,6 +26,7 @@ The fdb dialect is new and not yet tested (can't get fdb to build). from .kinterbasdb import FBDialect_kinterbasdb from ... import util + class FBDialect_fdb(FBDialect_kinterbasdb): @classmethod diff --git a/lib/sqlalchemy/dialects/firebird/kinterbasdb.py b/lib/sqlalchemy/dialects/firebird/kinterbasdb.py index 90fadde50b..cae9f4e3e8 100644 --- a/lib/sqlalchemy/dialects/firebird/kinterbasdb.py +++ b/lib/sqlalchemy/dialects/firebird/kinterbasdb.py @@ -63,6 +63,7 @@ class _FBNumeric_kinterbasdb(sqltypes.Numeric): return value return process + class FBExecutionContext_kinterbasdb(FBExecutionContext): @property def rowcount(self): @@ -72,6 +73,7 @@ class FBExecutionContext_kinterbasdb(FBExecutionContext): else: return -1 + class FBDialect_kinterbasdb(FBDialect): driver = 'kinterbasdb' supports_sane_rowcount = False diff --git a/lib/sqlalchemy/dialects/informix/base.py b/lib/sqlalchemy/dialects/informix/base.py index f54bf6d37b..ee0d3a8312 100644 --- a/lib/sqlalchemy/dialects/informix/base.py +++ b/lib/sqlalchemy/dialects/informix/base.py @@ -144,7 +144,9 @@ RESERVED_WORDS = set( "xadatasource", "xid", "xload", "xunload", "year" ]) + class InfoDateTime(sqltypes.DateTime): + def bind_processor(self, dialect): def process(value): if value is not None: @@ -153,7 +155,9 @@ class InfoDateTime(sqltypes.DateTime): return value return process + class InfoTime(sqltypes.Time): + def bind_processor(self, dialect): def process(value): if value is not None: @@ -217,7 +221,9 @@ class InfoTypeCompiler(compiler.GenericTypeCompiler): def visit_boolean(self, type_): return "SMALLINT" + class InfoSQLCompiler(compiler.SQLCompiler): + def default_from(self): return " from systables where tabname = 'systables' " @@ -337,6 +343,7 @@ class InfoDDLCompiler(compiler.DDLCompiler): text += "CONSTRAINT %s " % self.preparer.format_constraint(constraint) return text + class InformixIdentifierPreparer(compiler.IdentifierPreparer): reserved_words = RESERVED_WORDS diff --git a/lib/sqlalchemy/dialects/informix/informixdb.py b/lib/sqlalchemy/dialects/informix/informixdb.py index 474bc5f11b..2fdccfdc21 100644 --- a/lib/sqlalchemy/dialects/informix/informixdb.py +++ b/lib/sqlalchemy/dialects/informix/informixdb.py @@ -21,7 +21,9 @@ from sqlalchemy.engine import default VERSION_RE = re.compile(r'(\d+)\.(\d+)(.+\d+)') + class InformixExecutionContext_informixdb(default.DefaultExecutionContext): + def post_exec(self): if self.isinsert: self._lastrowid = self.cursor.sqlerrd[1] diff --git a/lib/sqlalchemy/dialects/mssql/adodbapi.py b/lib/sqlalchemy/dialects/mssql/adodbapi.py index 747ea17db7..247c1ce8fe 100644 --- a/lib/sqlalchemy/dialects/mssql/adodbapi.py +++ b/lib/sqlalchemy/dialects/mssql/adodbapi.py @@ -22,6 +22,7 @@ from sqlalchemy import types as sqltypes, util from sqlalchemy.dialects.mssql.base import MSDateTime, MSDialect import sys + class MSDateTime_adodbapi(MSDateTime): def result_processor(self, dialect, coltype): def process(value): diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index 09db05e1fe..8292d08f16 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -216,6 +216,7 @@ RESERVED_WORDS = set( 'writetext', ]) + class REAL(sqltypes.REAL): __visit_name__ = 'REAL' @@ -224,6 +225,7 @@ class REAL(sqltypes.REAL): kw['precision'] = 24 super(REAL, self).__init__(**kw) + class TINYINT(sqltypes.Integer): __visit_name__ = 'TINYINT' @@ -256,6 +258,7 @@ class _MSDate(sqltypes.Date): return value return process + class TIME(sqltypes.TIME): def __init__(self, precision=None, **kwargs): self.precision = precision @@ -287,6 +290,7 @@ class TIME(sqltypes.TIME): return process _MSTime = TIME + class _DateTimeBase(object): def bind_processor(self, dialect): def process(value): @@ -296,12 +300,15 @@ class _DateTimeBase(object): return value return process + class _MSDateTime(_DateTimeBase, sqltypes.DateTime): pass + class SMALLDATETIME(_DateTimeBase, sqltypes.DateTime): __visit_name__ = 'SMALLDATETIME' + class DATETIME2(_DateTimeBase, sqltypes.DateTime): __visit_name__ = 'DATETIME2' @@ -317,12 +324,14 @@ class DATETIMEOFFSET(sqltypes.TypeEngine): def __init__(self, precision=None, **kwargs): self.precision = precision + class _StringType(object): """Base for MSSQL string types.""" def __init__(self, collation=None): self.collation = collation + class TEXT(_StringType, sqltypes.TEXT): """MSSQL TEXT type, for variable-length text up to 2^31 characters.""" @@ -336,6 +345,7 @@ class TEXT(_StringType, sqltypes.TEXT): _StringType.__init__(self, collation) sqltypes.Text.__init__(self, length, **kw) + class NTEXT(_StringType, sqltypes.UnicodeText): """MSSQL NTEXT type, for variable-length unicode text up to 2^30 characters.""" @@ -381,6 +391,7 @@ class VARCHAR(_StringType, sqltypes.VARCHAR): _StringType.__init__(self, collation) sqltypes.VARCHAR.__init__(self, length, **kw) + class NVARCHAR(_StringType, sqltypes.NVARCHAR): """MSSQL NVARCHAR type. @@ -398,6 +409,7 @@ class NVARCHAR(_StringType, sqltypes.NVARCHAR): _StringType.__init__(self, collation) sqltypes.NVARCHAR.__init__(self, length, **kw) + class CHAR(_StringType, sqltypes.CHAR): """MSSQL CHAR type, for fixed-length non-Unicode data with a maximum of 8,000 characters.""" @@ -426,6 +438,7 @@ class CHAR(_StringType, sqltypes.CHAR): _StringType.__init__(self, collation) sqltypes.CHAR.__init__(self, length, **kw) + class NCHAR(_StringType, sqltypes.NCHAR): """MSSQL NCHAR type. @@ -443,9 +456,11 @@ class NCHAR(_StringType, sqltypes.NCHAR): _StringType.__init__(self, collation) sqltypes.NCHAR.__init__(self, length, **kw) + class IMAGE(sqltypes.LargeBinary): __visit_name__ = 'IMAGE' + class BIT(sqltypes.TypeEngine): __visit_name__ = 'BIT' @@ -453,12 +468,15 @@ class BIT(sqltypes.TypeEngine): class MONEY(sqltypes.TypeEngine): __visit_name__ = 'MONEY' + class SMALLMONEY(sqltypes.TypeEngine): __visit_name__ = 'SMALLMONEY' + class UNIQUEIDENTIFIER(sqltypes.TypeEngine): __visit_name__ = "UNIQUEIDENTIFIER" + class SQL_VARIANT(sqltypes.TypeEngine): __visit_name__ = 'SQL_VARIANT' @@ -641,6 +659,7 @@ class MSTypeCompiler(compiler.GenericTypeCompiler): def visit_SQL_VARIANT(self, type_): return 'SQL_VARIANT' + class MSExecutionContext(default.DefaultExecutionContext): _enable_identity_insert = False _select_lastrowid = False @@ -718,6 +737,7 @@ class MSExecutionContext(default.DefaultExecutionContext): else: return engine.ResultProxy(self) + class MSSQLCompiler(compiler.SQLCompiler): returning_precedes_values = True @@ -947,6 +967,7 @@ class MSSQLCompiler(compiler.SQLCompiler): fromhints=from_hints, **kw) for t in [from_table] + extra_froms) + class MSSQLStrictCompiler(MSSQLCompiler): """A subclass of MSSQLCompiler which disables the usage of bind parameters where not allowed natively by MS-SQL. @@ -990,6 +1011,7 @@ class MSSQLStrictCompiler(MSSQLCompiler): return super(MSSQLStrictCompiler, self).\ render_literal_value(value, type_) + class MSDDLCompiler(compiler.DDLCompiler): def get_column_specification(self, column, **kwargs): colspec = (self.preparer.format_column(column) + " " @@ -1049,6 +1071,7 @@ class MSIdentifierPreparer(compiler.IdentifierPreparer): result = '.'.join([self.quote(x, force) for x in schema.split('.')]) return result + def _db_plus_owner_listing(fn): def wrap(dialect, connection, schema=None, **kw): dbname, owner = _owner_plus_db(dialect, schema) @@ -1056,6 +1079,7 @@ def _db_plus_owner_listing(fn): dbname, owner, schema, **kw) return update_wrapper(wrap, fn) + def _db_plus_owner(fn): def wrap(dialect, connection, tablename, schema=None, **kw): dbname, owner = _owner_plus_db(dialect, schema) @@ -1063,6 +1087,7 @@ def _db_plus_owner(fn): tablename, dbname, owner, schema, **kw) return update_wrapper(wrap, fn) + def _switch_db(dbname, connection, fn, *arg, **kw): if dbname: current_db = connection.scalar("select db_name()") @@ -1073,6 +1098,7 @@ def _switch_db(dbname, connection, fn, *arg, **kw): if dbname: connection.execute("use %s" % current_db) + def _owner_plus_db(dialect, schema): if not schema: return None, dialect.default_schema_name @@ -1081,6 +1107,7 @@ def _owner_plus_db(dialect, schema): else: return None, schema + class MSDialect(default.DefaultDialect): name = 'mssql' supports_default_values = True diff --git a/lib/sqlalchemy/dialects/mssql/information_schema.py b/lib/sqlalchemy/dialects/mssql/information_schema.py index 30849e0efa..bd88a67d89 100644 --- a/lib/sqlalchemy/dialects/mssql/information_schema.py +++ b/lib/sqlalchemy/dialects/mssql/information_schema.py @@ -11,6 +11,7 @@ from ...types import String, Unicode, Integer, TypeDecorator ischema = MetaData() + class CoerceUnicode(TypeDecorator): impl = Unicode diff --git a/lib/sqlalchemy/dialects/mssql/mxodbc.py b/lib/sqlalchemy/dialects/mssql/mxodbc.py index 91922a442a..ccafe0efe0 100644 --- a/lib/sqlalchemy/dialects/mssql/mxodbc.py +++ b/lib/sqlalchemy/dialects/mssql/mxodbc.py @@ -54,6 +54,7 @@ class _MSNumeric_mxodbc(_MSNumeric_pyodbc): """Include pyodbc's numeric processor. """ + class _MSDate_mxodbc(_MSDate): def bind_processor(self, dialect): def process(value): @@ -63,6 +64,7 @@ class _MSDate_mxodbc(_MSDate): return None return process + class _MSTime_mxodbc(_MSTime): def bind_processor(self, dialect): def process(value): @@ -72,6 +74,7 @@ class _MSTime_mxodbc(_MSTime): return None return process + class MSExecutionContext_mxodbc(MSExecutionContext_pyodbc): """ The pyodbc execution context is useful for enabling @@ -82,6 +85,7 @@ class MSExecutionContext_mxodbc(MSExecutionContext_pyodbc): # is really only being used in cases where OUTPUT # won't work. + class MSDialect_mxodbc(MxODBCConnector, MSDialect): # this is only needed if "native ODBC" mode is used, diff --git a/lib/sqlalchemy/dialects/mssql/pymssql.py b/lib/sqlalchemy/dialects/mssql/pymssql.py index 881893422b..b51e88e36b 100644 --- a/lib/sqlalchemy/dialects/mssql/pymssql.py +++ b/lib/sqlalchemy/dialects/mssql/pymssql.py @@ -28,6 +28,7 @@ from .base import MSDialect from ... import types as sqltypes, util, processors import re + class _MSNumeric_pymssql(sqltypes.Numeric): def result_processor(self, dialect, type_): if not self.asdecimal: @@ -35,6 +36,7 @@ class _MSNumeric_pymssql(sqltypes.Numeric): else: return sqltypes.Numeric.result_processor(self, dialect, type_) + class MSDialect_pymssql(MSDialect): supports_sane_rowcount = False driver = 'pymssql' diff --git a/lib/sqlalchemy/dialects/mssql/pyodbc.py b/lib/sqlalchemy/dialects/mssql/pyodbc.py index 47a4851b00..8264347dff 100644 --- a/lib/sqlalchemy/dialects/mssql/pyodbc.py +++ b/lib/sqlalchemy/dialects/mssql/pyodbc.py @@ -116,6 +116,7 @@ from ...connectors.pyodbc import PyODBCConnector from ... import types as sqltypes, util from ...util.compat import decimal + class _MSNumeric_pyodbc(sqltypes.Numeric): """Turns Decimals with adjusted() < 0 or > 7 into strings. diff --git a/lib/sqlalchemy/dialects/mssql/zxjdbc.py b/lib/sqlalchemy/dialects/mssql/zxjdbc.py index 1b36075b07..751af6efe1 100644 --- a/lib/sqlalchemy/dialects/mssql/zxjdbc.py +++ b/lib/sqlalchemy/dialects/mssql/zxjdbc.py @@ -17,6 +17,7 @@ from ...connectors.zxJDBC import ZxJDBCConnector from .base import MSDialect, MSExecutionContext from ... import engine + class MSExecutionContext_zxjdbc(MSExecutionContext): _embedded_scope_identity = False diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index 92c6f58a0a..fa874ac5b3 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -361,6 +361,7 @@ class _NumericType(object): self.zerofill = zerofill super(_NumericType, self).__init__(**kw) + class _FloatType(_NumericType, sqltypes.Float): def __init__(self, precision=None, scale=None, asdecimal=True, **kw): if isinstance(self, (REAL, DOUBLE)) and \ @@ -375,11 +376,13 @@ class _FloatType(_NumericType, sqltypes.Float): super(_FloatType, self).__init__(precision=precision, asdecimal=asdecimal, **kw) self.scale = scale + class _IntegerType(_NumericType, sqltypes.Integer): def __init__(self, display_width=None, **kw): self.display_width = display_width super(_IntegerType, self).__init__(**kw) + class _StringType(sqltypes.String): """Base for MySQL string types.""" @@ -476,6 +479,7 @@ class DOUBLE(_FloatType): super(DOUBLE, self).__init__(precision=precision, scale=scale, asdecimal=asdecimal, **kw) + class REAL(_FloatType, sqltypes.REAL): """MySQL REAL type.""" @@ -500,6 +504,7 @@ class REAL(_FloatType, sqltypes.REAL): super(REAL, self).__init__(precision=precision, scale=scale, asdecimal=asdecimal, **kw) + class FLOAT(_FloatType, sqltypes.FLOAT): """MySQL FLOAT type.""" @@ -527,6 +532,7 @@ class FLOAT(_FloatType, sqltypes.FLOAT): def bind_processor(self, dialect): return None + class INTEGER(_IntegerType, sqltypes.INTEGER): """MySQL INTEGER type.""" @@ -547,6 +553,7 @@ class INTEGER(_IntegerType, sqltypes.INTEGER): """ super(INTEGER, self).__init__(display_width=display_width, **kw) + class BIGINT(_IntegerType, sqltypes.BIGINT): """MySQL BIGINTEGER type.""" @@ -567,6 +574,7 @@ class BIGINT(_IntegerType, sqltypes.BIGINT): """ super(BIGINT, self).__init__(display_width=display_width, **kw) + class MEDIUMINT(_IntegerType): """MySQL MEDIUMINTEGER type.""" @@ -587,6 +595,7 @@ class MEDIUMINT(_IntegerType): """ super(MEDIUMINT, self).__init__(display_width=display_width, **kw) + class TINYINT(_IntegerType): """MySQL TINYINT type.""" @@ -607,6 +616,7 @@ class TINYINT(_IntegerType): """ super(TINYINT, self).__init__(display_width=display_width, **kw) + class SMALLINT(_IntegerType, sqltypes.SMALLINT): """MySQL SMALLINTEGER type.""" @@ -627,6 +637,7 @@ class SMALLINT(_IntegerType, sqltypes.SMALLINT): """ super(SMALLINT, self).__init__(display_width=display_width, **kw) + class BIT(sqltypes.TypeEngine): """MySQL BIT type. @@ -663,6 +674,7 @@ class BIT(sqltypes.TypeEngine): return value return process + class TIME(sqltypes.TIME): """MySQL TIME type. @@ -710,10 +722,12 @@ class TIME(sqltypes.TIME): return None return process + class TIMESTAMP(sqltypes.TIMESTAMP): """MySQL TIMESTAMP type.""" __visit_name__ = 'TIMESTAMP' + class YEAR(sqltypes.TypeEngine): """MySQL YEAR type, for single byte storage of years 1901-2155.""" @@ -722,6 +736,7 @@ class YEAR(sqltypes.TypeEngine): def __init__(self, display_width=None): self.display_width = display_width + class TEXT(_StringType, sqltypes.TEXT): """MySQL TEXT type, for text up to 2^16 characters.""" @@ -757,6 +772,7 @@ class TEXT(_StringType, sqltypes.TEXT): """ super(TEXT, self).__init__(length=length, **kw) + class TINYTEXT(_StringType): """MySQL TINYTEXT type, for text up to 2^8 characters.""" @@ -788,6 +804,7 @@ class TINYTEXT(_StringType): """ super(TINYTEXT, self).__init__(**kwargs) + class MEDIUMTEXT(_StringType): """MySQL MEDIUMTEXT type, for text up to 2^24 characters.""" @@ -819,6 +836,7 @@ class MEDIUMTEXT(_StringType): """ super(MEDIUMTEXT, self).__init__(**kwargs) + class LONGTEXT(_StringType): """MySQL LONGTEXT type, for text up to 2^32 characters.""" @@ -882,6 +900,7 @@ class VARCHAR(_StringType, sqltypes.VARCHAR): """ super(VARCHAR, self).__init__(length=length, **kwargs) + class CHAR(_StringType, sqltypes.CHAR): """MySQL CHAR type, for fixed-length character data.""" @@ -902,6 +921,7 @@ class CHAR(_StringType, sqltypes.CHAR): """ super(CHAR, self).__init__(length=length, **kwargs) + class NVARCHAR(_StringType, sqltypes.NVARCHAR): """MySQL NVARCHAR type. @@ -954,23 +974,24 @@ class NCHAR(_StringType, sqltypes.NCHAR): super(NCHAR, self).__init__(length=length, **kwargs) - - class TINYBLOB(sqltypes._Binary): """MySQL TINYBLOB type, for binary data up to 2^8 bytes.""" __visit_name__ = 'TINYBLOB' + class MEDIUMBLOB(sqltypes._Binary): """MySQL MEDIUMBLOB type, for binary data up to 2^24 bytes.""" __visit_name__ = 'MEDIUMBLOB' + class LONGBLOB(sqltypes._Binary): """MySQL LONGBLOB type, for binary data up to 2^32 bytes.""" __visit_name__ = 'LONGBLOB' + class ENUM(sqltypes.Enum, _StringType): """MySQL ENUM type.""" @@ -1086,6 +1107,7 @@ class ENUM(sqltypes.Enum, _StringType): kw['strict'] = self.strict return sqltypes.Enum.adapt(self, impltype, **kw) + class SET(_StringType): """MySQL SET type.""" @@ -1250,11 +1272,13 @@ ischema_names = { 'year': YEAR, } + class MySQLExecutionContext(default.DefaultExecutionContext): def should_autocommit_text(self, statement): return AUTOCOMMIT_RE.match(statement) + class MySQLCompiler(compiler.SQLCompiler): render_table_with_column_in_update_from = True @@ -1569,6 +1593,7 @@ class MySQLDDLCompiler(compiler.DDLCompiler): (self.preparer.format_table(constraint.table), qual, const) + class MySQLTypeCompiler(compiler.GenericTypeCompiler): def _extend_numeric(self, type_, spec): "Extend a numeric-type declaration with MySQL specific extensions." @@ -1843,6 +1868,7 @@ class MySQLIdentifierPreparer(compiler.IdentifierPreparer): return tuple([self.quote_identifier(i) for i in ids if i is not None]) + class MySQLDialect(default.DefaultDialect): """Details of the MySQL dialect. Not used directly in application code.""" @@ -2325,6 +2351,7 @@ class MySQLDialect(default.DefaultDialect): rp.close() return rows + class ReflectedState(object): """Stores raw information about a SHOW CREATE TABLE statement.""" @@ -2335,6 +2362,7 @@ class ReflectedState(object): self.keys = [] self.constraints = [] + class MySQLTableDefinitionParser(object): """Parses the results of a SHOW CREATE TABLE statement.""" @@ -2790,6 +2818,7 @@ def _pr_compile(regex, cleanup=None): return (_re_compile(regex), cleanup) + def _re_compile(regex): """Compile a string to regex, I and UNICODE.""" diff --git a/lib/sqlalchemy/dialects/mysql/mysqlconnector.py b/lib/sqlalchemy/dialects/mysql/mysqlconnector.py index 82d9067855..cfaabb0458 100644 --- a/lib/sqlalchemy/dialects/mysql/mysqlconnector.py +++ b/lib/sqlalchemy/dialects/mysql/mysqlconnector.py @@ -20,6 +20,7 @@ from .base import (MySQLDialect, from ... import util + class MySQLExecutionContext_mysqlconnector(MySQLExecutionContext): def get_lastrowid(self): @@ -34,18 +35,21 @@ class MySQLCompiler_mysqlconnector(MySQLCompiler): def post_process_text(self, text): return text.replace('%', '%%') + class MySQLIdentifierPreparer_mysqlconnector(MySQLIdentifierPreparer): def _escape_identifier(self, value): value = value.replace(self.escape_quote, self.escape_to_quote) return value.replace("%", "%%") + class _myconnpyBIT(BIT): def result_processor(self, dialect, coltype): """MySQL-connector already converts mysql bits, so.""" return None + class MySQLDialect_mysqlconnector(MySQLDialect): driver = 'mysqlconnector' supports_unicode_statements = True diff --git a/lib/sqlalchemy/dialects/mysql/mysqldb.py b/lib/sqlalchemy/dialects/mysql/mysqldb.py index 7385f6e60d..d4938540b1 100644 --- a/lib/sqlalchemy/dialects/mysql/mysqldb.py +++ b/lib/sqlalchemy/dialects/mysql/mysqldb.py @@ -57,6 +57,7 @@ from ...connectors.mysqldb import ( MySQLDBConnector ) + class MySQLExecutionContext_mysqldb(MySQLDBExecutionContext, MySQLExecutionContext): pass @@ -68,6 +69,7 @@ class MySQLCompiler_mysqldb(MySQLDBCompiler, MySQLCompiler): class MySQLIdentifierPreparer_mysqldb(MySQLDBIdentifierPreparer, MySQLIdentifierPreparer): pass + class MySQLDialect_mysqldb(MySQLDBConnector, MySQLDialect): execution_ctx_cls = MySQLExecutionContext_mysqldb statement_compiler = MySQLCompiler_mysqldb diff --git a/lib/sqlalchemy/dialects/mysql/oursql.py b/lib/sqlalchemy/dialects/mysql/oursql.py index cc4e3b5f23..25c0a7e84d 100644 --- a/lib/sqlalchemy/dialects/mysql/oursql.py +++ b/lib/sqlalchemy/dialects/mysql/oursql.py @@ -53,6 +53,7 @@ class MySQLExecutionContext_oursql(MySQLExecutionContext): def plain_query(self): return self.execution_options.get('_oursql_plain_query', False) + class MySQLDialect_oursql(MySQLDialect): driver = 'oursql' # Py2K diff --git a/lib/sqlalchemy/dialects/mysql/pymysql.py b/lib/sqlalchemy/dialects/mysql/pymysql.py index 36b49ba3b8..818bb7e3b4 100644 --- a/lib/sqlalchemy/dialects/mysql/pymysql.py +++ b/lib/sqlalchemy/dialects/mysql/pymysql.py @@ -23,6 +23,7 @@ the pymysql driver as well. from .mysqldb import MySQLDialect_mysqldb + class MySQLDialect_pymysql(MySQLDialect_mysqldb): driver = 'pymysql' diff --git a/lib/sqlalchemy/dialects/mysql/pyodbc.py b/lib/sqlalchemy/dialects/mysql/pyodbc.py index 2736ef7a4b..f1dcae6d1d 100644 --- a/lib/sqlalchemy/dialects/mysql/pyodbc.py +++ b/lib/sqlalchemy/dialects/mysql/pyodbc.py @@ -29,6 +29,7 @@ from ...connectors.pyodbc import PyODBCConnector from ... import util import re + class MySQLExecutionContext_pyodbc(MySQLExecutionContext): def get_lastrowid(self): @@ -38,6 +39,7 @@ class MySQLExecutionContext_pyodbc(MySQLExecutionContext): cursor.close() return lastrowid + class MySQLDialect_pyodbc(PyODBCConnector, MySQLDialect): supports_unicode_statements = False execution_ctx_cls = MySQLExecutionContext_pyodbc diff --git a/lib/sqlalchemy/dialects/mysql/zxjdbc.py b/lib/sqlalchemy/dialects/mysql/zxjdbc.py index 955044a587..743eac7706 100644 --- a/lib/sqlalchemy/dialects/mysql/zxjdbc.py +++ b/lib/sqlalchemy/dialects/mysql/zxjdbc.py @@ -28,6 +28,7 @@ from ... import types as sqltypes, util from ...connectors.zxJDBC import ZxJDBCConnector from .base import BIT, MySQLDialect, MySQLExecutionContext + class _ZxJDBCBit(BIT): def result_processor(self, dialect, coltype): """Converts boolean or byte arrays from MySQL Connector/J to longs.""" diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py index 7a4d835c9a..5956a04b67 100644 --- a/lib/sqlalchemy/dialects/oracle/base.py +++ b/lib/sqlalchemy/dialects/oracle/base.py @@ -164,18 +164,22 @@ RESERVED_WORDS = \ NO_ARG_FNS = set('UID CURRENT_DATE SYSDATE USER ' 'CURRENT_TIME CURRENT_TIMESTAMP'.split()) + class RAW(sqltypes._Binary): __visit_name__ = 'RAW' OracleRaw = RAW + class NCLOB(sqltypes.Text): __visit_name__ = 'NCLOB' + class VARCHAR2(VARCHAR): __visit_name__ = 'VARCHAR2' NVARCHAR2 = NVARCHAR + class NUMBER(sqltypes.Numeric, sqltypes.Integer): __visit_name__ = 'NUMBER' @@ -207,12 +211,15 @@ class DOUBLE_PRECISION(sqltypes.Numeric): super(DOUBLE_PRECISION, self).__init__(precision=precision, scale=scale, asdecimal=asdecimal) + class BFILE(sqltypes.LargeBinary): __visit_name__ = 'BFILE' + class LONG(sqltypes.Text): __visit_name__ = 'LONG' + class INTERVAL(sqltypes.TypeEngine): __visit_name__ = 'INTERVAL' @@ -243,6 +250,7 @@ class INTERVAL(sqltypes.TypeEngine): def _type_affinity(self): return sqltypes.Interval + class ROWID(sqltypes.TypeEngine): """Oracle ROWID type. @@ -388,6 +396,7 @@ class OracleTypeCompiler(compiler.GenericTypeCompiler): def visit_ROWID(self, type_): return "ROWID" + class OracleCompiler(compiler.SQLCompiler): """Oracle compiler modifies the lexical structure of Select statements to work under non-ANSI configured Oracle databases, if @@ -613,6 +622,7 @@ class OracleCompiler(compiler.SQLCompiler): else: return super(OracleCompiler, self).for_update_clause(select) + class OracleDDLCompiler(compiler.DDLCompiler): def define_constraint_cascades(self, constraint): @@ -634,6 +644,7 @@ class OracleDDLCompiler(compiler.DDLCompiler): return super(OracleDDLCompiler, self).\ visit_create_index(create, include_schema=True) + class OracleIdentifierPreparer(compiler.IdentifierPreparer): reserved_words = set([x.lower() for x in RESERVED_WORDS]) @@ -658,6 +669,7 @@ class OracleExecutionContext(default.DefaultExecutionContext): self.dialect.identifier_preparer.format_sequence(seq) + ".nextval FROM DUAL", type_) + class OracleDialect(default.DefaultDialect): name = 'oracle' supports_alter = True diff --git a/lib/sqlalchemy/dialects/oracle/cx_oracle.py b/lib/sqlalchemy/dialects/oracle/cx_oracle.py index 233f3cb271..50c8550ed5 100644 --- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py +++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py @@ -155,12 +155,12 @@ from .base import OracleCompiler, OracleDialect, \ from . import base as oracle from ...engine import result as _result from sqlalchemy import types as sqltypes, util, exc, processors -from datetime import datetime import random import collections from sqlalchemy.util.compat import decimal import re + class _OracleNumeric(sqltypes.Numeric): def bind_processor(self, dialect): # cx_oracle accepts Decimal objects and floats @@ -204,6 +204,7 @@ class _OracleNumeric(sqltypes.Numeric): return super(_OracleNumeric, self).\ result_processor(dialect, coltype) + class _OracleDate(sqltypes.Date): def bind_processor(self, dialect): return None @@ -216,6 +217,7 @@ class _OracleDate(sqltypes.Date): return value return process + class _LOBMixin(object): def result_processor(self, dialect, coltype): if not dialect.auto_convert_lobs: @@ -229,6 +231,7 @@ class _LOBMixin(object): return value return process + class _NativeUnicodeMixin(object): # Py3K #pass @@ -249,21 +252,26 @@ class _NativeUnicodeMixin(object): # unicode in all cases, so the "native_unicode" flag # will be set for the default String.result_processor. + class _OracleChar(_NativeUnicodeMixin, sqltypes.CHAR): def get_dbapi_type(self, dbapi): return dbapi.FIXED_CHAR + class _OracleNVarChar(_NativeUnicodeMixin, sqltypes.NVARCHAR): def get_dbapi_type(self, dbapi): return getattr(dbapi, 'UNICODE', dbapi.STRING) + class _OracleText(_LOBMixin, sqltypes.Text): def get_dbapi_type(self, dbapi): return dbapi.CLOB + class _OracleString(_NativeUnicodeMixin, sqltypes.String): pass + class _OracleUnicodeText(_LOBMixin, _NativeUnicodeMixin, sqltypes.UnicodeText): def get_dbapi_type(self, dbapi): return dbapi.NCLOB @@ -282,6 +290,7 @@ class _OracleUnicodeText(_LOBMixin, _NativeUnicodeMixin, sqltypes.UnicodeText): return string_processor(lob_processor(value)) return process + class _OracleInteger(sqltypes.Integer): def result_processor(self, dialect, coltype): def to_int(val): @@ -290,6 +299,7 @@ class _OracleInteger(sqltypes.Integer): return val return to_int + class _OracleBinary(_LOBMixin, sqltypes.LargeBinary): def get_dbapi_type(self, dbapi): return dbapi.BLOB @@ -297,17 +307,21 @@ class _OracleBinary(_LOBMixin, sqltypes.LargeBinary): def bind_processor(self, dialect): return None + class _OracleInterval(oracle.INTERVAL): def get_dbapi_type(self, dbapi): return dbapi.INTERVAL + class _OracleRaw(oracle.RAW): pass + class _OracleRowid(oracle.ROWID): def get_dbapi_type(self, dbapi): return dbapi.ROWID + class OracleCompiler_cx_oracle(OracleCompiler): def bindparam_string(self, name, quote=None, **kw): if quote is True or quote is not False and \ @@ -421,6 +435,7 @@ class OracleExecutionContext_cx_oracle(OracleExecutionContext): return result + class OracleExecutionContext_cx_oracle_with_unicode(OracleExecutionContext_cx_oracle): """Support WITH_UNICODE in Python 2.xx. @@ -442,6 +457,7 @@ class OracleExecutionContext_cx_oracle_with_unicode(OracleExecutionContext_cx_or return super(OracleExecutionContext_cx_oracle_with_unicode, self).\ _execute_scalar(unicode(stmt)) + class ReturningResultProxy(_result.FullyBufferedResultProxy): """Result proxy which stuffs the _returning clause + outparams into the fetch.""" @@ -461,6 +477,7 @@ class ReturningResultProxy(_result.FullyBufferedResultProxy): return collections.deque([tuple(self._returning_params["ret_%d" % i] for i, c in enumerate(self._returning_params))]) + class OracleDialect_cx_oracle(OracleDialect): execution_ctx_cls = OracleExecutionContext_cx_oracle statement_compiler = OracleCompiler_cx_oracle diff --git a/lib/sqlalchemy/dialects/oracle/zxjdbc.py b/lib/sqlalchemy/dialects/oracle/zxjdbc.py index 54608969bb..7c828331b1 100644 --- a/lib/sqlalchemy/dialects/oracle/zxjdbc.py +++ b/lib/sqlalchemy/dialects/oracle/zxjdbc.py @@ -24,6 +24,7 @@ import collections SQLException = zxJDBC = None + class _ZxJDBCDate(sqltypes.Date): def result_processor(self, dialect, coltype): diff --git a/lib/sqlalchemy/testing/plugin/noseplugin.py b/lib/sqlalchemy/testing/plugin/noseplugin.py index 37f7b29f55..c104c46143 100644 --- a/lib/sqlalchemy/testing/plugin/noseplugin.py +++ b/lib/sqlalchemy/testing/plugin/noseplugin.py @@ -41,6 +41,7 @@ db_opts = {} options = None _existing_engine = None + def _log(option, opt_str, value, parser): global logging if not logging: @@ -59,34 +60,42 @@ def _list_dbs(*args): print "%20s\t%s" % (macro, file_config.get('db', macro)) sys.exit(0) + def _server_side_cursors(options, opt_str, value, parser): db_opts['server_side_cursors'] = True + def _engine_strategy(options, opt_str, value, parser): if value: db_opts['strategy'] = value pre_configure = [] post_configure = [] + + def pre(fn): pre_configure.append(fn) return fn + + def post(fn): post_configure.append(fn) return fn + @pre def _setup_options(opt, file_config): global options options = opt + @pre def _monkeypatch_cdecimal(options, file_config): if options.cdecimal: - import sys import cdecimal sys.modules['decimal'] = cdecimal + @post def _engine_uri(options, file_config): global db_label, db_url @@ -105,6 +114,7 @@ def _engine_uri(options, file_config): % db_label) db_url = file_config.get('db', db_label) + @post def _require(options, file_config): if not(options.require or @@ -131,12 +141,14 @@ def _require(options, file_config): continue pkg_resources.require(requirement) + @post def _engine_pool(options, file_config): if options.mockpool: from sqlalchemy import pool db_opts['poolclass'] = pool.AssertionPool + @post def _create_testing_engine(options, file_config): from sqlalchemy.testing import engines, config @@ -199,6 +211,7 @@ def _set_table_options(options, file_config): if options.mysql_engine: table_options['mysql_engine'] = options.mysql_engine + @post def _reverse_topological(options, file_config): if options.reversetop: @@ -208,6 +221,7 @@ def _reverse_topological(options, file_config): topological.set = unitofwork.set = session.set = mapper.set = \ dependency.set = RandomSet + @post def _requirements(options, file_config): from sqlalchemy.testing import config @@ -230,6 +244,7 @@ def _post_setup_options(opt, file_config): from sqlalchemy.testing import config config.options = options + @post def _setup_profiling(options, file_config): from sqlalchemy.testing import profiling -- 2.47.2