schema_plus_foreign_keys 0.1.2 → 0.1.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: b2ffa8e1095bb42bec9a1caf9c6a90048964a771
4
- data.tar.gz: d184941dfb77d130e6420bad3018466e984104c5
3
+ metadata.gz: 161f26b7a83ca42ce9fa30a6132447bbf1ca000e
4
+ data.tar.gz: 1393641fbdd4843d42558e12cf97d4792a9b3d18
5
5
  SHA512:
6
- metadata.gz: dcac94e7194fda6a55479f573be6250191f2f1d47ed5e7c6e29c6f4c3772348fe297b8b07349a2c7abaa3c58fb294c1a6e1e232c65dbfbbd84079c71e53173d2
7
- data.tar.gz: ec5104854ab13660508d486d661216e0d56bbeda754c65108eeb3b0d37be8a0ebcd46af8f216b5e68e5949dd7243eb96fb5d0db827746aa231db5af48e2d7f73
6
+ metadata.gz: 9b0d962d24372f0fa68a9dd6775cb930d929a3dea94a438fc689a52628b1e0d5c24eefe1aefab160137d0355ac230cf15742e27cbce8186658a96e352ad59d35
7
+ data.tar.gz: 2db8b15e9be4c76bdef4b356882d00abce638585fc613c258ab8d77706ddf9d41dfdf4b455b23b5e738607687e25f13498e44a606a215a807d5a9bf3abd593d6
data/.travis.yml CHANGED
@@ -5,7 +5,7 @@
5
5
  ---
6
6
  sudo: false
7
7
  rvm:
8
- - 2.1.5
8
+ - 2.1.8
9
9
  gemfile:
10
10
  - gemfiles/activerecord-4.2.0/Gemfile.mysql2
11
11
  - gemfiles/activerecord-4.2.0/Gemfile.postgresql
@@ -13,6 +13,9 @@ gemfile:
13
13
  - gemfiles/activerecord-4.2.1/Gemfile.mysql2
14
14
  - gemfiles/activerecord-4.2.1/Gemfile.postgresql
15
15
  - gemfiles/activerecord-4.2.1/Gemfile.sqlite3
16
+ - gemfiles/activerecord-4.2.6/Gemfile.mysql2
17
+ - gemfiles/activerecord-4.2.6/Gemfile.postgresql
18
+ - gemfiles/activerecord-4.2.6/Gemfile.sqlite3
16
19
  env: POSTGRESQL_DB_USER=postgres MYSQL_DB_USER=travis
17
20
  addons:
18
21
  postgresql: '9.4'
data/README.md CHANGED
@@ -102,7 +102,7 @@ constraint, they normally default to whatever the DBMS's default behavior is.
102
102
  But you can also configure a global default (e.g. in a Rails initializer):
103
103
 
104
104
  ```ruby
105
- SchemaPlus::ForeignKey.setup do |config|
105
+ SchemaPlus::ForeignKeys.setup do |config|
106
106
  config.on_update = :cascade # default is nil, meaning use default dbms behavior
107
107
  config.on_delete = :nullify # default is nil, meaning use default dbms behavior
108
108
  end
@@ -142,13 +142,15 @@ SchemaPlus::ForeignKeys is tested on:
142
142
 
143
143
  <!-- SCHEMA_DEV: MATRIX - begin -->
144
144
  <!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
145
- * ruby **2.1.5** with activerecord **4.2.0**, using **mysql2**, **sqlite3** or **postgresql**
146
- * ruby **2.1.5** with activerecord **4.2.1**, using **mysql2**, **sqlite3** or **postgresql**
145
+ * ruby **2.1.8** with activerecord **4.2.0**, using **mysql2**, **sqlite3** or **postgresql**
146
+ * ruby **2.1.8** with activerecord **4.2.1**, using **mysql2**, **sqlite3** or **postgresql**
147
+ * ruby **2.1.8** with activerecord **4.2.6**, using **mysql2**, **sqlite3** or **postgresql**
147
148
 
148
149
  <!-- SCHEMA_DEV: MATRIX - end -->
149
150
 
150
151
  ## History
151
152
 
153
+ * 0.1.3 - Support aciverecord 4.2.6. Thanks to [@btsuhako](https://github.com/SchemaPlus/schema_plus_foreign_keys/issues?q=is%3Apr+is%3Aopen+author%3Abtsuhako) and [@dholdren](https://github.com/SchemaPlus/schema_plus_foreign_keys/issues?q=is%3Apr+is%3Aopen+author%3Adholdren)
152
154
  * 0.1.2 - Handle very long names
153
155
  * 0.1.1 - Cleanup; use (new) core Migration::RenameTable stack rather than monkey patching.
154
156
  * 0.1.0 - Initial release, brought over from schema_plus 1.x via 2.0.0.pre*
@@ -2,9 +2,9 @@ require "pathname"
2
2
  eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
3
 
4
4
  platform :ruby do
5
- gem "mysql2"
5
+ gem 'mysql2', '~> 0.3.13'
6
6
  end
7
7
 
8
8
  platform :jruby do
9
9
  gem 'activerecord-jdbcmysql-adapter'
10
- end
10
+ end
@@ -2,9 +2,9 @@ require "pathname"
2
2
  eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
3
 
4
4
  platform :ruby do
5
- gem "mysql2"
5
+ gem 'mysql2', '~> 0.3.13'
6
6
  end
7
7
 
8
8
  platform :jruby do
9
9
  gem 'activerecord-jdbcmysql-adapter'
10
- end
10
+ end
@@ -0,0 +1,3 @@
1
+ eval File.read File.expand_path('../../Gemfile.base', __FILE__)
2
+
3
+ gem "activerecord", "4.2.6"
@@ -0,0 +1,10 @@
1
+ require "pathname"
2
+ eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
+
4
+ platform :ruby do
5
+ gem "mysql2", '>= 0.3.18', '< 0.5'
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcmysql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ require "pathname"
2
+ eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
+
4
+ platform :ruby do
5
+ gem "pg"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcpostgresql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ require "pathname"
2
+ eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
+
4
+ platform :ruby do
5
+ gem "sqlite3"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
+ end
@@ -67,7 +67,7 @@ module SchemaPlus::ForeignKeys::ActiveRecord::ConnectionAdapters
67
67
 
68
68
  attr_accessor :schema_plus_foreign_keys_config #:nodoc:
69
69
 
70
- if ActiveRecord.version == Gem::Version.new("4.2.0")
70
+ if Gem::Requirement.new('= 4.2.0').satisfied_by?(::ActiveRecord.version)
71
71
  def foreign_keys
72
72
  @foreign_keys ||= []
73
73
  end
@@ -75,10 +75,14 @@ module SchemaPlus::ForeignKeys::ActiveRecord::ConnectionAdapters
75
75
  def foreign_keys_for_table(*)
76
76
  foreign_keys
77
77
  end
78
- else
78
+ elsif Gem::Requirement.new('< 4.2.6').satisfied_by?(::ActiveRecord.version)
79
79
  def foreign_keys_for_table(table)
80
80
  foreign_keys[table] ||= []
81
81
  end
82
+ else
83
+ def foreign_keys_for_table(*)
84
+ foreign_keys
85
+ end
82
86
  end
83
87
 
84
88
  def foreign_key(*args) # (column_names, to_table, primary_key=nil, options=nil)
@@ -3,14 +3,15 @@ module SchemaPlus::ForeignKeys
3
3
  module Sql
4
4
  module Table
5
5
  def after(env)
6
- foreign_keys = case ::ActiveRecord.version
7
- when Gem::Version.new("4.2.0") then env.table_definition.foreign_keys
8
- else env.table_definition.foreign_keys.values.tap { |v| v.flatten! }
6
+ foreign_keys = if env.table_definition.foreign_keys.is_a? Array
7
+ env.table_definition.foreign_keys
8
+ else
9
+ env.table_definition.foreign_keys.values.tap { |v| v.flatten! }
9
10
  end
10
11
 
11
12
  # create foreign key constraints inline in table definition
12
13
  env.sql.body = ([env.sql.body] + foreign_keys.map(&:to_sql)).join(', ')
13
-
14
+
14
15
  # prevents AR >= 4.2.1 from emitting add_foreign_key after the table
15
16
  env.table_definition.foreign_keys.clear
16
17
  end
@@ -1,5 +1,5 @@
1
1
  module SchemaPlus
2
2
  module ForeignKeys
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
data/schema_dev.yml CHANGED
@@ -1,8 +1,9 @@
1
1
  ruby:
2
- - 2.1.5
2
+ - 2.1.8
3
3
  activerecord:
4
4
  - 4.2.0
5
5
  - 4.2.1
6
+ - 4.2.6
6
7
  db:
7
8
  - mysql2
8
9
  - sqlite3
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_plus_foreign_keys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ronen barzel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-22 00:00:00.000000000 Z
11
+ date: 2016-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -160,6 +160,10 @@ files:
160
160
  - gemfiles/activerecord-4.2.1/Gemfile.mysql2
161
161
  - gemfiles/activerecord-4.2.1/Gemfile.postgresql
162
162
  - gemfiles/activerecord-4.2.1/Gemfile.sqlite3
163
+ - gemfiles/activerecord-4.2.6/Gemfile.base
164
+ - gemfiles/activerecord-4.2.6/Gemfile.mysql2
165
+ - gemfiles/activerecord-4.2.6/Gemfile.postgresql
166
+ - gemfiles/activerecord-4.2.6/Gemfile.sqlite3
163
167
  - lib/schema_plus/foreign_keys.rb
164
168
  - lib/schema_plus/foreign_keys/active_record/base.rb
165
169
  - lib/schema_plus/foreign_keys/active_record/connection_adapters/abstract_adapter.rb