schema_plus 1.8.2 → 1.8.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0fa513513788b541ef9a1f0f9bc50ca6f3360e5
4
- data.tar.gz: 26caef3cbcf5b870bd4484e903d57d33ff999b15
3
+ metadata.gz: 7a5f207e0ebe6cbe96157c4762ac33335023a439
4
+ data.tar.gz: 024b7be47e963277cc5a673cc5639bede4348d58
5
5
  SHA512:
6
- metadata.gz: cd84595cfdb830f928a4f06bb6dc13960ca144121b5f4dd88d29415a540807f36e0b7d5abe1f5f34d34e2421b482755ec42a0111a4a5ed67f072836fb6f4f881
7
- data.tar.gz: 1d7350d3629ae83ace5180dd907c6dbf76fe6b33ffc31d3196888530bfe3fb5e89a4cb1545df110ab67457a552c58ccd1365f579dc1fe8865fcda96ff80480cb
6
+ metadata.gz: 4e40fb778ee431cac5b5393f417036f62be5b256ad63dd98ea67cab6c7414e9a6abf7ac4a3b591a72f484c4b547cc1e8d727b27b7b8e993873e7b28c941d7e25
7
+ data.tar.gz: 18eee79285313cef82db8533032862e9662c9c8ac74c454afc2b80fd137a6081aa97594636becb63d56f260c4a213d98b49501da243c31c6ef1df196ce40330c
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Change Log
4
4
 
5
+ ## 1.8.3
6
+
7
+ * Don't modifiy migration column options hashes (#191). Thanks to [@lowjoel](https://github.com/lowjoel)
8
+
5
9
  ## 1.8.2
6
10
 
7
11
  * Bug fix when using t.references in change_table (#194). Thanks to [@boone](https://github.com/boone)
@@ -54,6 +54,7 @@ module SchemaPlus::ActiveRecord
54
54
 
55
55
  if column_options.has_key?(:foreign_key)
56
56
  args = column_options[:foreign_key]
57
+ args = args.dup if args.is_a?(Hash)
57
58
  return :none unless args
58
59
  args = {} if args == true
59
60
  return :none if args.has_key?(:references) and not args[:references]
@@ -98,6 +99,7 @@ module SchemaPlus::ActiveRecord
98
99
 
99
100
 
100
101
  def column_index(table_name, column_name, options) #:nodoc:
102
+ options = options.dup
101
103
  column_name = [column_name] + Array.wrap(options.delete(:with)).compact
102
104
  add_index(table_name, column_name, options)
103
105
  end
@@ -54,6 +54,7 @@ module SchemaPlus::ActiveRecord::ConnectionAdapters
54
54
  end
55
55
 
56
56
  def add_index_options_with_schema_plus(table_name, column_name, options = {})
57
+ options = options.dup
57
58
  with_columns = options.delete(:with) { |_| [] }
58
59
  add_index_options_without_schema_plus(table_name, Array(column_name).concat(Array(with_columns).map(&:to_s)), options)
59
60
  end
@@ -1,3 +1,3 @@
1
1
  module SchemaPlus
2
- VERSION = "1.8.2"
2
+ VERSION = "1.8.3"
3
3
  end
@@ -70,6 +70,24 @@ describe ActiveRecord::Migration do
70
70
  expect(@model).to reference(:users, :id).on(:author_id)
71
71
  end
72
72
 
73
+ it "should create foreign key without modifying input hash" do
74
+ hash = { :references => :users }
75
+ hash_original = hash.dup
76
+ recreate_table(@model) do |t|
77
+ t.integer :author_id, :foreign_key => hash
78
+ end
79
+ expect(hash).to eq(hash_original)
80
+ end
81
+
82
+ it "should create foreign key without modifying input hash" do
83
+ hash = { :references => :users }
84
+ hash_original = hash.dup
85
+ recreate_table(@model) do |t|
86
+ t.references :author, :foreign_key => hash
87
+ end
88
+ expect(hash).to eq(hash_original)
89
+ end
90
+
73
91
  it "should create foreign key with different reference using shortcut" do
74
92
  recreate_table(@model) do |t|
75
93
  t.integer :author_id, :references => :users
@@ -250,6 +268,16 @@ describe ActiveRecord::Migration do
250
268
  expect(@model).to have_index.on([:state, :city])
251
269
  end
252
270
 
271
+ it "should create the index without modifying the input hash" do
272
+ hash = { :with => :foo, :length => { :foo => 8, :bar => 12 }}
273
+ hash_original = hash.dup
274
+ recreate_table(@model) do |t|
275
+ t.string :foo
276
+ t.string :bar, :index => hash
277
+ end
278
+ expect(hash).to eq(hash_original)
279
+ end
280
+
253
281
  it "should auto-index foreign keys only" do
254
282
  recreate_table(@model) do |t|
255
283
  t.integer :user_id
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.2
4
+ version: 1.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ronen Barzel
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-01 00:00:00.000000000 Z
12
+ date: 2015-01-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord