aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/mysql2
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2015-02-14 15:59:33 +0900
committerRyuta Kamizono <kamipo@gmail.com>2015-09-18 20:22:32 +0900
commitdfeb3ee78a44b630ef414a7ce6e93265b2cc4f28 (patch)
treef48fc57752bc45c297ef9c195f6b3d09afb5f9ed /activerecord/test/cases/adapters/mysql2
parentf3772f729c72d098156b35eb105d3ffdd928c5eb (diff)
downloadrails-dfeb3ee78a44b630ef414a7ce6e93265b2cc4f28.tar.gz
rails-dfeb3ee78a44b630ef414a7ce6e93265b2cc4f28.tar.bz2
rails-dfeb3ee78a44b630ef414a7ce6e93265b2cc4f28.zip
Add `unsigned` types for numeric data types in MySQL
In the case of using `unsigned` as the type: create_table :foos do |t| t.unsigned_integer :unsigned_integer t.unsigned_bigint :unsigned_bigint t.unsigned_float :unsigned_float t.unsigned_decimal :unsigned_decimal, precision: 10, scale: 2 end
Diffstat (limited to 'activerecord/test/cases/adapters/mysql2')
-rw-r--r--activerecord/test/cases/adapters/mysql2/unsigned_type_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/mysql2/unsigned_type_test.rb b/activerecord/test/cases/adapters/mysql2/unsigned_type_test.rb
index aea2ef4af5..a6f6dd21bb 100644
--- a/activerecord/test/cases/adapters/mysql2/unsigned_type_test.rb
+++ b/activerecord/test/cases/adapters/mysql2/unsigned_type_test.rb
@@ -42,6 +42,19 @@ class Mysql2UnsignedTypeTest < ActiveRecord::Mysql2TestCase
end
end
+ test "schema definition can use unsigned as the type" do
+ @connection.change_table("unsigned_types") do |t|
+ t.unsigned_integer :unsigned_integer_t
+ t.unsigned_bigint :unsigned_bigint_t
+ t.unsigned_float :unsigned_float_t
+ t.unsigned_decimal :unsigned_decimal_t, precision: 10, scale: 2
+ end
+
+ @connection.columns("unsigned_types").select { |c| /^unsigned_/ === c.name }.each do |column|
+ assert column.unsigned?
+ end
+ end
+
test "schema dump includes unsigned option" do
schema = dump_table_schema "unsigned_types"
assert_match %r{t.integer\s+"unsigned_integer",\s+limit: 4,\s+unsigned: true$}, schema