mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #27978 from kamipo/add_blob_short_hand_method
Add `blob` short-hand method for schema creation
This commit is contained in:
commit
8695b02826
4 changed files with 12 additions and 2 deletions
|
@ -249,6 +249,7 @@ module ActiveRecord
|
||||||
define_column_methods :bigint, :binary, :boolean, :date, :datetime, :decimal,
|
define_column_methods :bigint, :binary, :boolean, :date, :datetime, :decimal,
|
||||||
:float, :integer, :json, :string, :text, :time, :timestamp, :virtual
|
:float, :integer, :json, :string, :text, :time, :timestamp, :virtual
|
||||||
|
|
||||||
|
alias :blob :binary
|
||||||
alias :numeric :decimal
|
alias :numeric :decimal
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -564,6 +565,7 @@ module ActiveRecord
|
||||||
# t.time
|
# t.time
|
||||||
# t.date
|
# t.date
|
||||||
# t.binary
|
# t.binary
|
||||||
|
# t.blob
|
||||||
# t.boolean
|
# t.boolean
|
||||||
# t.foreign_key
|
# t.foreign_key
|
||||||
# t.json
|
# t.json
|
||||||
|
|
|
@ -523,7 +523,7 @@ module ActiveRecord
|
||||||
# <tt>:primary_key</tt>, <tt>:string</tt>, <tt>:text</tt>,
|
# <tt>:primary_key</tt>, <tt>:string</tt>, <tt>:text</tt>,
|
||||||
# <tt>:integer</tt>, <tt>:bigint</tt>, <tt>:float</tt>, <tt>:decimal</tt>, <tt>:numeric</tt>,
|
# <tt>:integer</tt>, <tt>:bigint</tt>, <tt>:float</tt>, <tt>:decimal</tt>, <tt>:numeric</tt>,
|
||||||
# <tt>:datetime</tt>, <tt>:time</tt>, <tt>:date</tt>,
|
# <tt>:datetime</tt>, <tt>:time</tt>, <tt>:date</tt>,
|
||||||
# <tt>:binary</tt>, <tt>:boolean</tt>.
|
# <tt>:binary</tt>, <tt>:blob</tt>, <tt>:boolean</tt>.
|
||||||
#
|
#
|
||||||
# You may use a type not in this list as long as it is supported by your
|
# You may use a type not in this list as long as it is supported by your
|
||||||
# database (for example, "polygon" in MySQL), but this will not be database
|
# database (for example, "polygon" in MySQL), but this will not be database
|
||||||
|
@ -532,7 +532,7 @@ module ActiveRecord
|
||||||
# Available options are (none of these exists by default):
|
# Available options are (none of these exists by default):
|
||||||
# * <tt>:limit</tt> -
|
# * <tt>:limit</tt> -
|
||||||
# Requests a maximum column length. This is the number of characters for a <tt>:string</tt> column
|
# Requests a maximum column length. This is the number of characters for a <tt>:string</tt> column
|
||||||
# and number of bytes for <tt>:text</tt>, <tt>:binary</tt>, and <tt>:integer</tt> columns.
|
# and number of bytes for <tt>:text</tt>, <tt>:binary</tt>, <tt>:blob</tt>, and <tt>:integer</tt> columns.
|
||||||
# This option is ignored by some backends.
|
# This option is ignored by some backends.
|
||||||
# * <tt>:default</tt> -
|
# * <tt>:default</tt> -
|
||||||
# The column's default value. Use +nil+ for +NULL+.
|
# The column's default value. Use +nil+ for +NULL+.
|
||||||
|
|
|
@ -238,6 +238,12 @@ class SchemaDumperTest < ActiveRecord::TestCase
|
||||||
assert_match %r{t\.float\s+"temperature"$}, output
|
assert_match %r{t\.float\s+"temperature"$}, output
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_schema_dump_aliased_types
|
||||||
|
output = standard_dump
|
||||||
|
assert_match %r{t\.binary\s+"blob_data"$}, output
|
||||||
|
assert_match %r{t\.decimal\s+"numeric_number"}, output
|
||||||
|
end
|
||||||
|
|
||||||
if ActiveRecord::Base.connection.supports_expression_index?
|
if ActiveRecord::Base.connection.supports_expression_index?
|
||||||
def test_schema_dump_expression_indices
|
def test_schema_dump_expression_indices
|
||||||
index_definition = dump_table_schema("companies").split(/\n/).grep(/t\.index.*company_expression_index/).first.strip
|
index_definition = dump_table_schema("companies").split(/\n/).grep(/t\.index.*company_expression_index/).first.strip
|
||||||
|
|
|
@ -86,6 +86,7 @@ ActiveRecord::Schema.define do
|
||||||
t.string :name
|
t.string :name
|
||||||
t.binary :data
|
t.binary :data
|
||||||
t.binary :short_data, limit: 2048
|
t.binary :short_data, limit: 2048
|
||||||
|
t.blob :blob_data
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table :birds, force: true do |t|
|
create_table :birds, force: true do |t|
|
||||||
|
@ -652,6 +653,7 @@ ActiveRecord::Schema.define do
|
||||||
t.decimal :my_house_population, precision: 2, scale: 0
|
t.decimal :my_house_population, precision: 2, scale: 0
|
||||||
t.decimal :decimal_number
|
t.decimal :decimal_number
|
||||||
t.decimal :decimal_number_with_default, precision: 3, scale: 2, default: 2.78
|
t.decimal :decimal_number_with_default, precision: 3, scale: 2, default: 2.78
|
||||||
|
t.numeric :numeric_number
|
||||||
t.float :temperature
|
t.float :temperature
|
||||||
t.decimal :decimal_number_big_precision, precision: 20
|
t.decimal :decimal_number_big_precision, precision: 20
|
||||||
# Oracle/SQLServer supports precision up to 38
|
# Oracle/SQLServer supports precision up to 38
|
||||||
|
|
Loading…
Reference in a new issue