Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
e4108fc6
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e4108fc6
编写于
2月 17, 2017
作者:
R
Ryuta Kamizono
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make internal methods to private
上级
40ba03ad
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
181 addition
and
185 deletion
+181
-185
activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
...lib/active_record/connection_adapters/abstract/quoting.rb
+4
-11
activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb
...ve_record/connection_adapters/abstract/schema_creation.rb
+1
-0
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
..._record/connection_adapters/abstract/schema_statements.rb
+46
-23
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
...lib/active_record/connection_adapters/abstract_adapter.rb
+13
-27
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
...tive_record/connection_adapters/abstract_mysql_adapter.rb
+2
-35
activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb
...ive_record/connection_adapters/mysql/schema_statements.rb
+36
-0
activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
...b/active_record/connection_adapters/postgresql/quoting.rb
+3
-0
activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
...ecord/connection_adapters/postgresql/schema_statements.rb
+46
-39
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
...b/active_record/connection_adapters/postgresql_adapter.rb
+2
-15
activerecord/lib/active_record/connection_adapters/sqlite3/schema_statements.rb
...e_record/connection_adapters/sqlite3/schema_statements.rb
+25
-0
activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
.../lib/active_record/connection_adapters/sqlite3_adapter.rb
+2
-34
activerecord/test/cases/column_definition_test.rb
activerecord/test/cases/column_definition_test.rb
+1
-1
未找到文件。
activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
浏览文件 @
e4108fc6
...
...
@@ -61,17 +61,6 @@ def lookup_cast_type_from_column(column) # :nodoc:
lookup_cast_type
(
column
.
sql_type
)
end
def
fetch_type_metadata
(
sql_type
)
cast_type
=
lookup_cast_type
(
sql_type
)
SqlTypeMetadata
.
new
(
sql_type:
sql_type
,
type:
cast_type
.
type
,
limit:
cast_type
.
limit
,
precision:
cast_type
.
precision
,
scale:
cast_type
.
scale
,
)
end
# Quotes a string, escaping any ' (single quote) and \ (backslash)
# characters.
def
quote_string
(
s
)
...
...
@@ -161,6 +150,10 @@ def type_casted_binds(binds) # :nodoc:
end
private
def
lookup_cast_type
(
sql_type
)
type_map
.
lookup
(
sql_type
)
end
def
id_value_for_database
(
value
)
if
primary_key
=
value
.
class
.
primary_key
value
.
instance_variable_get
(
:@attributes
)[
primary_key
].
value_for_database
...
...
activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb
浏览文件 @
e4108fc6
...
...
@@ -133,5 +133,6 @@ def action_sql(action, dependency)
end
end
end
SchemaCreation
=
AbstractAdapter
::
SchemaCreation
# :nodoc:
end
end
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
浏览文件 @
e4108fc6
...
...
@@ -976,16 +976,6 @@ def foreign_key_exists?(from_table, options_or_to_table = {})
foreign_key_for
(
from_table
,
options_or_to_table
).
present?
end
def
foreign_key_for
(
from_table
,
options_or_to_table
=
{})
# :nodoc:
return
unless
supports_foreign_keys?
foreign_keys
(
from_table
).
detect
{
|
fk
|
fk
.
defined_for?
options_or_to_table
}
end
def
foreign_key_for!
(
from_table
,
options_or_to_table
=
{})
# :nodoc:
foreign_key_for
(
from_table
,
options_or_to_table
)
||
\
raise
(
ArgumentError
,
"Table '
#{
from_table
}
' has no foreign key for
#{
options_or_to_table
}
"
)
end
def
foreign_key_column_for
(
table_name
)
# :nodoc:
prefix
=
Base
.
table_name_prefix
suffix
=
Base
.
table_name_suffix
...
...
@@ -1005,19 +995,6 @@ def dump_schema_information #:nodoc:
insert_versions_sql
(
versions
)
end
def
insert_versions_sql
(
versions
)
# :nodoc:
sm_table
=
quote_table_name
(
ActiveRecord
::
SchemaMigration
.
table_name
)
if
versions
.
is_a?
(
Array
)
sql
=
"INSERT INTO
#{
sm_table
}
(version) VALUES
\n
"
sql
<<
versions
.
map
{
|
v
|
"(
#{
quote
(
v
)
}
)"
}.
join
(
",
\n
"
)
sql
<<
";
\n\n
"
sql
else
"INSERT INTO
#{
sm_table
}
(version) VALUES (
#{
quote
(
versions
)
}
);"
end
end
def
initialize_schema_migrations_table
# :nodoc:
ActiveRecord
::
SchemaMigration
.
create_table
end
...
...
@@ -1263,6 +1240,10 @@ def rename_column_indexes(table_name, column_name, new_column_name)
end
end
def
schema_creation
SchemaCreation
.
new
(
self
)
end
def
create_table_definition
(
*
args
)
TableDefinition
.
new
(
*
args
)
end
...
...
@@ -1271,6 +1252,17 @@ def create_alter_table(name)
AlterTable
.
new
create_table_definition
(
name
)
end
def
fetch_type_metadata
(
sql_type
)
cast_type
=
lookup_cast_type
(
sql_type
)
SqlTypeMetadata
.
new
(
sql_type:
sql_type
,
type:
cast_type
.
type
,
limit:
cast_type
.
limit
,
precision:
cast_type
.
precision
,
scale:
cast_type
.
scale
,
)
end
def
index_column_names
(
column_names
)
if
column_names
.
is_a?
(
String
)
&&
/\W/
.
match?
(
column_names
)
column_names
...
...
@@ -1295,6 +1287,24 @@ def foreign_key_name(table_name, options)
end
end
def
foreign_key_for
(
from_table
,
options_or_to_table
=
{})
return
unless
supports_foreign_keys?
foreign_keys
(
from_table
).
detect
{
|
fk
|
fk
.
defined_for?
options_or_to_table
}
end
def
foreign_key_for!
(
from_table
,
options_or_to_table
=
{})
foreign_key_for
(
from_table
,
options_or_to_table
)
||
\
raise
(
ArgumentError
,
"Table '
#{
from_table
}
' has no foreign key for
#{
options_or_to_table
}
"
)
end
def
extract_foreign_key_action
(
specifier
)
case
specifier
when
"CASCADE"
;
:cascade
when
"SET NULL"
;
:nullify
when
"RESTRICT"
;
:restrict
end
end
def
validate_index_length!
(
table_name
,
new_name
,
internal
=
false
)
max_index_length
=
internal
?
index_name_length
:
allowed_index_name_length
...
...
@@ -1315,6 +1325,19 @@ def can_remove_index_by_name?(options)
options
.
is_a?
(
Hash
)
&&
options
.
key?
(
:name
)
&&
options
.
except
(
:name
,
:algorithm
).
empty?
end
def
insert_versions_sql
(
versions
)
sm_table
=
quote_table_name
(
ActiveRecord
::
SchemaMigration
.
table_name
)
if
versions
.
is_a?
(
Array
)
sql
=
"INSERT INTO
#{
sm_table
}
(version) VALUES
\n
"
sql
<<
versions
.
map
{
|
v
|
"(
#{
quote
(
v
)
}
)"
}.
join
(
",
\n
"
)
sql
<<
";
\n\n
"
sql
else
"INSERT INTO
#{
sm_table
}
(version) VALUES (
#{
quote
(
versions
)
}
);"
end
end
def
data_source_sql
(
name
=
nil
,
type:
nil
)
raise
NotImplementedError
end
...
...
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
浏览文件 @
e4108fc6
...
...
@@ -74,7 +74,7 @@ class AbstractAdapter
SIMPLE_INT
=
/\A\d+\z/
attr_accessor
:visitor
,
:pool
attr_reader
:schema_cache
,
:owner
,
:logger
attr_reader
:schema_cache
,
:owner
,
:logger
,
:prepared_statements
alias
:in_use?
:owner
def
self
.
type_cast_config_to_integer
(
config
)
...
...
@@ -93,8 +93,6 @@ def self.type_cast_config_to_boolean(config)
end
end
attr_reader
:prepared_statements
def
initialize
(
connection
,
logger
=
nil
,
config
=
{})
# :nodoc:
super
()
...
...
@@ -142,26 +140,10 @@ def compile(bvs, conn)
end
end
def
collector
if
prepared_statements
SQLString
.
new
else
BindCollector
.
new
end
end
def
arel_visitor
# :nodoc:
Arel
::
Visitors
::
ToSql
.
new
(
self
)
end
def
valid_type?
(
type
)
# :nodoc:
!
native_database_types
[
type
].
nil?
end
def
schema_creation
SchemaCreation
.
new
self
end
# this method must only be called while holding connection pool's mutex
def
lease
if
in_use?
...
...
@@ -475,14 +457,6 @@ def type_map # :nodoc:
end
end
def
new_column
(
name
,
default
,
sql_type_metadata
,
null
,
table_name
,
default_function
=
nil
,
collation
=
nil
)
# :nodoc:
Column
.
new
(
name
,
default
,
sql_type_metadata
,
null
,
table_name
,
default_function
,
collation
)
end
def
lookup_cast_type
(
sql_type
)
# :nodoc:
type_map
.
lookup
(
sql_type
)
end
def
column_name_for_operation
(
operation
,
node
)
# :nodoc:
visitor
.
accept
(
node
,
collector
).
value
end
...
...
@@ -629,6 +603,18 @@ def column_for(table_name, column_name)
columns
(
table_name
).
detect
{
|
c
|
c
.
name
==
column_name
}
||
raise
(
ActiveRecordError
,
"No such column:
#{
table_name
}
.
#{
column_name
}
"
)
end
def
collector
if
prepared_statements
SQLString
.
new
else
BindCollector
.
new
end
end
def
arel_visitor
Arel
::
Visitors
::
ToSql
.
new
(
self
)
end
end
end
end
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
浏览文件 @
e4108fc6
...
...
@@ -22,14 +22,6 @@ def update_table_definition(table_name, base) # :nodoc:
MySQL
::
Table
.
new
(
table_name
,
base
)
end
def
schema_creation
# :nodoc:
MySQL
::
SchemaCreation
.
new
(
self
)
end
def
arel_visitor
# :nodoc:
Arel
::
Visitors
::
MySQL
.
new
(
self
)
end
##
# :singleton-method:
# By default, the Mysql2Adapter will consider all columns of type <tt>tinyint(1)</tt>
...
...
@@ -171,10 +163,6 @@ def each_hash(result) # :nodoc:
raise
NotImplementedError
end
def
new_column
(
*
args
)
#:nodoc:
MySQL
::
Column
.
new
(
*
args
)
end
# Must return the MySQL error number from the exception, if the exception has an
# error number.
def
error_number
(
exception
)
# :nodoc:
...
...
@@ -346,16 +334,6 @@ def indexes(table_name, name = nil) #:nodoc:
indexes
end
def
new_column_from_field
(
table_name
,
field
)
# :nodoc:
type_metadata
=
fetch_type_metadata
(
field
[
:Type
],
field
[
:Extra
])
if
type_metadata
.
type
==
:datetime
&&
field
[
:Default
]
==
"CURRENT_TIMESTAMP"
default
,
default_function
=
nil
,
field
[
:Default
]
else
default
,
default_function
=
field
[
:Default
],
nil
end
new_column
(
field
[
:Field
],
default
,
type_metadata
,
field
[
:Null
]
==
"YES"
,
table_name
,
default_function
,
field
[
:Collation
],
comment:
field
[
:Comment
].
presence
)
end
def
table_comment
(
table_name
)
# :nodoc:
scope
=
quoted_scope
(
table_name
)
...
...
@@ -658,10 +636,6 @@ def extract_precision(sql_type)
end
end
def
fetch_type_metadata
(
sql_type
,
extra
=
""
)
MySQL
::
TypeMetadata
.
new
(
super
(
sql_type
),
extra:
extra
)
end
def
add_index_length
(
quoted_columns
,
**
options
)
if
length
=
options
[
:length
]
case
length
...
...
@@ -864,19 +838,12 @@ def column_definitions(table_name) # :nodoc:
end
end
def
extract_foreign_key_action
(
specifier
)
# :nodoc:
case
specifier
when
"CASCADE"
;
:cascade
when
"SET NULL"
;
:nullify
end
end
def
create_table_info
(
table_name
)
# :nodoc:
select_one
(
"SHOW CREATE TABLE
#{
quote_table_name
(
table_name
)
}
"
)[
"Create Table"
]
end
def
create_table_definition
(
*
args
)
# :nodoc:
MySQL
::
TableDefinition
.
new
(
*
args
)
def
arel_visitor
Arel
::
Visitors
::
MySQL
.
new
(
self
)
end
def
mismatched_foreign_key
(
message
)
...
...
activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb
浏览文件 @
e4108fc6
...
...
@@ -3,6 +3,42 @@ module ConnectionAdapters
module
MySQL
module
SchemaStatements
# :nodoc:
private
def
schema_creation
MySQL
::
SchemaCreation
.
new
(
self
)
end
def
create_table_definition
(
*
args
)
MySQL
::
TableDefinition
.
new
(
*
args
)
end
def
new_column_from_field
(
table_name
,
field
)
type_metadata
=
fetch_type_metadata
(
field
[
:Type
],
field
[
:Extra
])
if
type_metadata
.
type
==
:datetime
&&
field
[
:Default
]
==
"CURRENT_TIMESTAMP"
default
,
default_function
=
nil
,
field
[
:Default
]
else
default
,
default_function
=
field
[
:Default
],
nil
end
MySQL
::
Column
.
new
(
field
[
:Field
],
default
,
type_metadata
,
field
[
:Null
]
==
"YES"
,
table_name
,
default_function
,
field
[
:Collation
],
comment:
field
[
:Comment
].
presence
)
end
def
fetch_type_metadata
(
sql_type
,
extra
=
""
)
MySQL
::
TypeMetadata
.
new
(
super
(
sql_type
),
extra:
extra
)
end
def
extract_foreign_key_action
(
specifier
)
super
unless
specifier
==
"RESTRICT"
end
def
data_source_sql
(
name
=
nil
,
type:
nil
)
scope
=
quoted_scope
(
name
,
type:
type
)
...
...
activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
浏览文件 @
e4108fc6
...
...
@@ -77,6 +77,9 @@ def lookup_cast_type_from_column(column) # :nodoc:
end
private
def
lookup_cast_type
(
sql_type
)
super
(
select_value
(
"SELECT
#{
quote
(
sql_type
)
}
::regtype::oid"
,
"SCHEMA"
).
to_i
)
end
def
_quote
(
value
)
case
value
...
...
activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
浏览文件 @
e4108fc6
...
...
@@ -144,25 +144,6 @@ def indexes(table_name, name = nil) # :nodoc:
end
.
compact
end
def
new_column_from_field
(
table_name
,
field
)
# :nondoc:
column_name
,
type
,
default
,
notnull
,
oid
,
fmod
,
collation
,
comment
=
field
oid
=
oid
.
to_i
fmod
=
fmod
.
to_i
type_metadata
=
fetch_type_metadata
(
column_name
,
type
,
oid
,
fmod
)
default_value
=
extract_value_from_default
(
default
)
default_function
=
extract_default_function
(
default_value
,
default
)
PostgreSQLColumn
.
new
(
column_name
,
default_value
,
type_metadata
,
!
notnull
,
table_name
,
default_function
,
collation
,
comment:
comment
.
presence
)
end
def
table_options
(
table_name
)
# :nodoc:
if
comment
=
table_comment
(
table_name
)
{
comment:
comment
}
...
...
@@ -538,14 +519,6 @@ def foreign_keys(table_name)
end
end
def
extract_foreign_key_action
(
specifier
)
# :nodoc:
case
specifier
when
"c"
;
:cascade
when
"n"
;
:nullify
when
"r"
;
:restrict
end
end
# Maps logical Rails types to PostgreSQL-specific data types.
def
type_to_sql
(
type
,
limit:
nil
,
precision:
nil
,
scale:
nil
,
array:
nil
,
**
)
# :nodoc:
sql
=
\
...
...
@@ -593,19 +566,53 @@ def columns_for_distinct(columns, orders) #:nodoc:
[
super
,
*
order_columns
].
join
(
", "
)
end
def
fetch_type_metadata
(
column_name
,
sql_type
,
oid
,
fmod
)
cast_type
=
get_oid_type
(
oid
,
fmod
,
column_name
,
sql_type
)
simple_type
=
SqlTypeMetadata
.
new
(
sql_type:
sql_type
,
type:
cast_type
.
type
,
limit:
cast_type
.
limit
,
precision:
cast_type
.
precision
,
scale:
cast_type
.
scale
,
)
PostgreSQLTypeMetadata
.
new
(
simple_type
,
oid:
oid
,
fmod:
fmod
)
end
private
def
schema_creation
PostgreSQL
::
SchemaCreation
.
new
(
self
)
end
def
create_table_definition
(
*
args
)
PostgreSQL
::
TableDefinition
.
new
(
*
args
)
end
def
new_column_from_field
(
table_name
,
field
)
column_name
,
type
,
default
,
notnull
,
oid
,
fmod
,
collation
,
comment
=
field
type_metadata
=
fetch_type_metadata
(
column_name
,
type
,
oid
.
to_i
,
fmod
.
to_i
)
default_value
=
extract_value_from_default
(
default
)
default_function
=
extract_default_function
(
default_value
,
default
)
PostgreSQLColumn
.
new
(
column_name
,
default_value
,
type_metadata
,
!
notnull
,
table_name
,
default_function
,
collation
,
comment:
comment
.
presence
)
end
def
fetch_type_metadata
(
column_name
,
sql_type
,
oid
,
fmod
)
cast_type
=
get_oid_type
(
oid
,
fmod
,
column_name
,
sql_type
)
simple_type
=
SqlTypeMetadata
.
new
(
sql_type:
sql_type
,
type:
cast_type
.
type
,
limit:
cast_type
.
limit
,
precision:
cast_type
.
precision
,
scale:
cast_type
.
scale
,
)
PostgreSQLTypeMetadata
.
new
(
simple_type
,
oid:
oid
,
fmod:
fmod
)
end
def
extract_foreign_key_action
(
specifier
)
case
specifier
when
"c"
;
:cascade
when
"n"
;
:nullify
when
"r"
;
:restrict
end
end
def
data_source_sql
(
name
=
nil
,
type:
nil
)
scope
=
quoted_scope
(
name
,
type:
type
)
scope
[
:type
]
||=
"'r','v','m'"
# (r)elation/table, (v)iew, (m)aterialized view
...
...
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
浏览文件 @
e4108fc6
...
...
@@ -121,14 +121,6 @@ class PostgreSQLAdapter < AbstractAdapter
include
PostgreSQL
::
DatabaseStatements
include
PostgreSQL
::
ColumnDumper
def
schema_creation
# :nodoc:
PostgreSQL
::
SchemaCreation
.
new
self
end
def
arel_visitor
# :nodoc:
Arel
::
Visitors
::
PostgreSQL
.
new
(
self
)
end
# Returns true, since this connection adapter supports prepared statement
# caching.
def
supports_statement_cache?
...
...
@@ -376,11 +368,6 @@ def update_table_definition(table_name, base) #:nodoc:
PostgreSQL
::
Table
.
new
(
table_name
,
base
)
end
def
lookup_cast_type
(
sql_type
)
# :nodoc:
oid
=
execute
(
"SELECT
#{
quote
(
sql_type
)
}
::regtype::oid"
,
"SCHEMA"
).
first
[
"oid"
].
to_i
super
(
oid
)
end
def
column_name_for_operation
(
operation
,
node
)
# :nodoc:
OPERATION_ALIASES
.
fetch
(
operation
)
{
operation
.
downcase
}
end
...
...
@@ -777,8 +764,8 @@ def extract_table_ref_from_insert_sql(sql)
$1
.
strip
if
$1
end
def
create_table_definition
(
*
args
)
PostgreSQL
::
TableDefinition
.
new
(
*
args
)
def
arel_visitor
Arel
::
Visitors
::
PostgreSQL
.
new
(
self
)
end
def
can_perform_case_insensitive_comparison_for?
(
column
)
...
...
activerecord/lib/active_record/connection_adapters/sqlite3/schema_statements.rb
浏览文件 @
e4108fc6
...
...
@@ -3,6 +3,31 @@ module ConnectionAdapters
module
SQLite3
module
SchemaStatements
# :nodoc:
private
def
schema_creation
SQLite3
::
SchemaCreation
.
new
(
self
)
end
def
create_table_definition
(
*
args
)
SQLite3
::
TableDefinition
.
new
(
*
args
)
end
def
new_column_from_field
(
table_name
,
field
)
default
=
\
case
field
[
"dflt_value"
]
when
/^null$/i
nil
when
/^'(.*)'$/m
$1
.
gsub
(
"''"
,
"'"
)
when
/^"(.*)"$/m
$1
.
gsub
(
'""'
,
'"'
)
else
field
[
"dflt_value"
]
end
type_metadata
=
fetch_type_metadata
(
field
[
"type"
])
Column
.
new
(
field
[
"name"
],
default
,
type_metadata
,
field
[
"notnull"
].
to_i
==
0
,
table_name
,
nil
,
field
[
"collation"
])
end
def
data_source_sql
(
name
=
nil
,
type:
nil
)
scope
=
quoted_scope
(
name
,
type:
type
)
scope
[
:type
]
||=
"'table','view'"
...
...
activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
浏览文件 @
e4108fc6
...
...
@@ -84,14 +84,6 @@ def update_table_definition(table_name, base) # :nodoc:
SQLite3
::
Table
.
new
(
table_name
,
base
)
end
def
schema_creation
# :nodoc:
SQLite3
::
SchemaCreation
.
new
self
end
def
arel_visitor
# :nodoc:
Arel
::
Visitors
::
SQLite
.
new
(
self
)
end
def
initialize
(
connection
,
logger
,
connection_options
,
config
)
super
(
connection
,
logger
,
config
)
...
...
@@ -267,22 +259,6 @@ def exec_rollback_db_transaction #:nodoc:
# SCHEMA STATEMENTS ========================================
def
new_column_from_field
(
table_name
,
field
)
# :nondoc:
case
field
[
"dflt_value"
]
when
/^null$/i
field
[
"dflt_value"
]
=
nil
when
/^'(.*)'$/m
field
[
"dflt_value"
]
=
$1
.
gsub
(
"''"
,
"'"
)
when
/^"(.*)"$/m
field
[
"dflt_value"
]
=
$1
.
gsub
(
'""'
,
'"'
)
end
collation
=
field
[
"collation"
]
sql_type
=
field
[
"type"
]
type_metadata
=
fetch_type_metadata
(
sql_type
)
new_column
(
field
[
"name"
],
field
[
"dflt_value"
],
type_metadata
,
field
[
"notnull"
].
to_i
==
0
,
table_name
,
nil
,
collation
)
end
# Returns an array of indexes for the given table.
def
indexes
(
table_name
,
name
=
nil
)
#:nodoc:
if
name
...
...
@@ -559,16 +535,8 @@ def table_structure_with_collation(table_name, basic_structure)
end
end
def
create_table_definition
(
*
args
)
SQLite3
::
TableDefinition
.
new
(
*
args
)
end
def
extract_foreign_key_action
(
specifier
)
case
specifier
when
"CASCADE"
;
:cascade
when
"SET NULL"
;
:nullify
when
"RESTRICT"
;
:restrict
end
def
arel_visitor
Arel
::
Visitors
::
SQLite
.
new
(
self
)
end
def
configure_connection
...
...
activerecord/test/cases/column_definition_test.rb
浏览文件 @
e4108fc6
...
...
@@ -8,7 +8,7 @@ def setup
def
@adapter
.
native_database_types
{
string:
"varchar"
}
end
@viz
=
@adapter
.
s
chema_creation
@viz
=
@adapter
.
s
end
(
:schema_creation
)
end
# Avoid column definitions in create table statements like:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录