activerecord-mysql-unsigned 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fc6191d31871ae48741ed325d6bc3540ebc7ee2
|
4
|
+
data.tar.gz: b40d32872ba7ddec346904003b3a609d53feffaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e731e9b545386d2e1d7137311fa5f82a518930493a052dc385a5d70873bdb4d09b0a7d7aee86cff1c0047232c70089d0c9e07dc7a80a1b69c082af836b8322df
|
7
|
+
data.tar.gz: f97831d2ca2f5cd753baf50deff5443a5c4b2155d95165b71a948e9b6e0b3a4ddedb2e7b5d61937f1683d9cafca544f23183d2e343a413350fd37de74af160f2
|
data/lib/activerecord-mysql-unsigned/active_record/v4/connection_adapters/abstract_mysql_adapter.rb
CHANGED
@@ -10,9 +10,11 @@ module ActiveRecord
|
|
10
10
|
class SchemaCreation < AbstractAdapter::SchemaCreation
|
11
11
|
def visit_AddColumn(o)
|
12
12
|
sql_type = type_to_sql(o.type.to_sym, o.limit, o.precision, o.scale, o.unsigned)
|
13
|
-
|
14
|
-
add_column_options!(
|
15
|
-
add_column_position!(
|
13
|
+
add_column_sql = "ADD #{quote_column_name(o.name)} #{sql_type}"
|
14
|
+
add_column_options!(add_column_sql, column_options(o)) unless o.type.to_sym == :primary_key
|
15
|
+
add_column_position!(add_column_sql, column_options(o))
|
16
|
+
|
17
|
+
add_column_sql
|
16
18
|
end
|
17
19
|
|
18
20
|
def visit_ChangeColumnDefinition(o)
|
@@ -22,12 +24,15 @@ module ActiveRecord
|
|
22
24
|
change_column_sql = "CHANGE #{quote_column_name(column.name)} #{quote_column_name(options[:name])} #{sql_type}"
|
23
25
|
add_column_options!(change_column_sql, options.merge(column: column)) unless o.type.to_sym == :primary_key
|
24
26
|
add_column_position!(change_column_sql, options)
|
27
|
+
|
28
|
+
change_column_sql
|
25
29
|
end
|
26
30
|
|
27
31
|
def visit_ColumnDefinition(o)
|
28
32
|
sql_type = type_to_sql(o.type.to_sym, o.limit, o.precision, o.scale, o.unsigned)
|
29
33
|
column_sql = "#{quote_column_name(o.name)} #{sql_type}"
|
30
34
|
add_column_options!(column_sql, column_options(o)) unless o.type.to_sym == :primary_key
|
35
|
+
|
31
36
|
column_sql
|
32
37
|
end
|
33
38
|
|
data/spec/unsigned_spec.rb
CHANGED
@@ -52,6 +52,16 @@ describe "INT/Decimal column" do
|
|
52
52
|
expect(unsigned_int_col.unsigned?).to be_truthy
|
53
53
|
end
|
54
54
|
|
55
|
+
it "signed column has 'unsigned' attribute after changed" do
|
56
|
+
will_unsigned_int_col = User.columns[4]
|
57
|
+
expect(will_unsigned_int_col.unsigned?).to be_truthy
|
58
|
+
end
|
59
|
+
|
60
|
+
it "unsigned column has 'signed' attribute after changed" do
|
61
|
+
will_signed_int_col = User.columns[5]
|
62
|
+
expect(will_signed_int_col.unsigned?).to be_falsey
|
63
|
+
end
|
64
|
+
|
55
65
|
it "allowed minus value of signed decimal" do
|
56
66
|
@user.signed_decimal = -10.0
|
57
67
|
@user.save
|