mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
add table.bigint support
In the DSL you can now do: create_table(:foos) do |t| t.bigint :hi end
This commit is contained in:
parent
e01f1b3406
commit
574234be06
3 changed files with 21 additions and 1 deletions
|
@ -270,7 +270,7 @@ module ActiveRecord
|
|||
@columns_hash.delete name.to_s
|
||||
end
|
||||
|
||||
[:string, :text, :integer, :float, :decimal, :datetime, :timestamp, :time, :date, :binary, :boolean].each do |column_type|
|
||||
[:string, :text, :integer, :bigint, :float, :decimal, :datetime, :timestamp, :time, :date, :binary, :boolean].each do |column_type|
|
||||
define_method column_type do |*args|
|
||||
options = args.extract_options!
|
||||
column_names = args
|
||||
|
|
|
@ -94,6 +94,7 @@ module ActiveRecord
|
|||
int8range: { name: "int8range" },
|
||||
binary: { name: "bytea" },
|
||||
boolean: { name: "boolean" },
|
||||
bigint: { name: "bigint" },
|
||||
xml: { name: "xml" },
|
||||
tsvector: { name: "tsvector" },
|
||||
hstore: { name: "hstore" },
|
||||
|
|
|
@ -97,6 +97,25 @@ module ActiveRecord
|
|||
end
|
||||
end
|
||||
|
||||
def test_create_table_with_bigint
|
||||
connection.create_table :testings do |t|
|
||||
t.bigint :eight_int
|
||||
end
|
||||
columns = connection.columns(:testings)
|
||||
eight = columns.detect { |c| c.name == "eight_int" }
|
||||
|
||||
if current_adapter?(:OracleAdapter)
|
||||
assert_equal 'NUMBER(8)', eight.sql_type
|
||||
elsif current_adapter?(:SQLite3Adapter)
|
||||
assert_equal 'bigint', eight.sql_type
|
||||
else
|
||||
assert_equal :integer, eight.type
|
||||
assert_equal 8, eight.limit
|
||||
end
|
||||
ensure
|
||||
connection.drop_table :testings
|
||||
end
|
||||
|
||||
def test_create_table_with_limits
|
||||
connection.create_table :testings do |t|
|
||||
t.column :foo, :string, :limit => 255
|
||||
|
|
Loading…
Reference in a new issue