提交 1fc9ddbd 编写于 作者: A Abdelkader Boudih

Freeze ADAPTER_NAME in adapters

上级 a8827cb9
...@@ -66,6 +66,7 @@ module ConnectionAdapters # :nodoc: ...@@ -66,6 +66,7 @@ module ConnectionAdapters # :nodoc:
# Most of the methods in the adapter are useful during migrations. Most # Most of the methods in the adapter are useful during migrations. Most
# notably, the instance methods provided by SchemaStatement are very useful. # notably, the instance methods provided by SchemaStatement are very useful.
class AbstractAdapter class AbstractAdapter
ADAPTER_NAME = 'Abstract'.freeze
include Quoting, DatabaseStatements, SchemaStatements include Quoting, DatabaseStatements, SchemaStatements
include DatabaseLimits include DatabaseLimits
include QueryCache include QueryCache
...@@ -167,7 +168,7 @@ def unprepared_statement ...@@ -167,7 +168,7 @@ def unprepared_statement
# Returns the human-readable name of the adapter. Use mixed case - one # Returns the human-readable name of the adapter. Use mixed case - one
# can always use downcase if needed. # can always use downcase if needed.
def adapter_name def adapter_name
'Abstract' self.class::ADAPTER_NAME
end end
# Does this adapter support migrations? # Does this adapter support migrations?
......
...@@ -162,10 +162,6 @@ def initialize(connection, logger, connection_options, config) ...@@ -162,10 +162,6 @@ def initialize(connection, logger, connection_options, config)
end end
end end
def adapter_name #:nodoc:
self.class::ADAPTER_NAME
end
# Returns true, since this connection adapter supports migrations. # Returns true, since this connection adapter supports migrations.
def supports_migrations? def supports_migrations?
true true
......
...@@ -29,7 +29,7 @@ def mysql2_connection(config) ...@@ -29,7 +29,7 @@ def mysql2_connection(config)
module ConnectionAdapters module ConnectionAdapters
class Mysql2Adapter < AbstractMysqlAdapter class Mysql2Adapter < AbstractMysqlAdapter
ADAPTER_NAME = 'Mysql2' ADAPTER_NAME = 'Mysql2'.freeze
def initialize(connection, logger, connection_options, config) def initialize(connection, logger, connection_options, config)
super super
......
...@@ -66,7 +66,7 @@ module ConnectionAdapters ...@@ -66,7 +66,7 @@ module ConnectionAdapters
# * <tt>:sslcipher</tt> - Necessary to use MySQL with an SSL connection. # * <tt>:sslcipher</tt> - Necessary to use MySQL with an SSL connection.
# #
class MysqlAdapter < AbstractMysqlAdapter class MysqlAdapter < AbstractMysqlAdapter
ADAPTER_NAME = 'MySQL' ADAPTER_NAME = 'MySQL'.freeze
class StatementPool < ConnectionAdapters::StatementPool class StatementPool < ConnectionAdapters::StatementPool
def initialize(connection, max = 1000) def initialize(connection, max = 1000)
......
...@@ -74,7 +74,7 @@ module ConnectionAdapters ...@@ -74,7 +74,7 @@ module ConnectionAdapters
# In addition, default connection parameters of libpq can be set per environment variables. # In addition, default connection parameters of libpq can be set per environment variables.
# See http://www.postgresql.org/docs/9.1/static/libpq-envars.html . # See http://www.postgresql.org/docs/9.1/static/libpq-envars.html .
class PostgreSQLAdapter < AbstractAdapter class PostgreSQLAdapter < AbstractAdapter
ADAPTER_NAME = 'PostgreSQL' ADAPTER_NAME = 'PostgreSQL'.freeze
NATIVE_DATABASE_TYPES = { NATIVE_DATABASE_TYPES = {
primary_key: "serial primary key", primary_key: "serial primary key",
...@@ -118,11 +118,6 @@ class PostgreSQLAdapter < AbstractAdapter ...@@ -118,11 +118,6 @@ class PostgreSQLAdapter < AbstractAdapter
include PostgreSQL::DatabaseStatements include PostgreSQL::DatabaseStatements
include Savepoints include Savepoints
# Returns 'PostgreSQL' as adapter name for identification purposes.
def adapter_name
ADAPTER_NAME
end
def schema_creation # :nodoc: def schema_creation # :nodoc:
PostgreSQL::SchemaCreation.new self PostgreSQL::SchemaCreation.new self
end end
......
...@@ -67,6 +67,7 @@ def type_cast_for_database(value) ...@@ -67,6 +67,7 @@ def type_cast_for_database(value)
# #
# * <tt>:database</tt> - Path to the database file. # * <tt>:database</tt> - Path to the database file.
class SQLite3Adapter < AbstractAdapter class SQLite3Adapter < AbstractAdapter
ADAPTER_NAME = 'SQLite'.freeze
include Savepoints include Savepoints
NATIVE_DATABASE_TYPES = { NATIVE_DATABASE_TYPES = {
...@@ -147,10 +148,6 @@ def initialize(connection, logger, connection_options, config) ...@@ -147,10 +148,6 @@ def initialize(connection, logger, connection_options, config)
end end
end end
def adapter_name #:nodoc:
'SQLite'
end
def supports_ddl_transactions? def supports_ddl_transactions?
true true
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册