schema_plus 1.8.6 → 1.8.7
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 +4 -4
- data/CHANGELOG.md +9 -2
- data/MIT-LICENSE +1 -1
- data/README.md +1 -1
- data/gemfiles/Gemfile.base +0 -2
- data/lib/schema_plus/active_record/connection_adapters/foreign_key_definition.rb +1 -1
- data/lib/schema_plus/active_record/connection_adapters/index_definition.rb +2 -2
- data/lib/schema_plus/active_record/connection_adapters/mysql_adapter.rb +1 -1
- data/lib/schema_plus/active_record/connection_adapters/postgresql_adapter.rb +2 -2
- data/lib/schema_plus/active_record/connection_adapters/schema_statements.rb +1 -1
- data/lib/schema_plus/active_record/connection_adapters/sqlite3_adapter.rb +1 -1
- data/lib/schema_plus/active_record/connection_adapters/table_definition.rb +2 -2
- data/lib/schema_plus/active_record/db_default.rb +1 -1
- data/lib/schema_plus/active_record/foreign_keys.rb +3 -3
- data/lib/schema_plus/active_record/migration/command_recorder.rb +2 -2
- data/lib/schema_plus/active_record/schema_dumper.rb +2 -2
- data/lib/schema_plus/version.rb +1 -1
- data/spec/column_default_spec.rb +1 -1
- data/spec/column_spec.rb +4 -4
- data/spec/index_definition_spec.rb +1 -1
- data/spec/schema/auto_schema.rb +1 -1
- data/spec/schema_dumper_spec.rb +99 -2
- data/spec/support/matchers/reference.rb +5 -5
- data/spec/views_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dceee81f9c7bd38bbbc3f07765b6cc0318d13efe
|
4
|
+
data.tar.gz: dbccc00e2a96548bd1a1aee0650dea2f07cbb791
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 952c02e9cafdc50a2ae72221ec1f8a2011b9bc96541a85f02265100c9cfca51a3fc83dbde3d4a6bc11683aa440ff8ed7d8cc6b70829effca31d9cb4425d24b07
|
7
|
+
data.tar.gz: 01cd8a88036ce14e328b6754a51eb4b44f6ae2384e05b11ea01843033301cb0e2fab2cf32a1013e27b55e7a38bc2043f40c5fb519712acc534d9eb6a8351a446
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
## Change Log
|
4
4
|
|
5
|
+
## 1.8.7
|
6
|
+
|
7
|
+
* Bug fix: Postgres schema dump failed when using case_sensitive => false and operator_class together (#204). Thanks to [@mikeauclair](https://github.com/mikeauclair)
|
8
|
+
|
9
|
+
* Bug fix: With complex cyclic foreign key dependencies, schema dump would issue constraint before table definition (#203). Thanks to [@konjoot](https://github.com/konjoot)
|
10
|
+
|
11
|
+
|
5
12
|
## 1.8.6
|
6
13
|
|
7
14
|
* Bug fix: Don't drop column `array: true` for ActiveRecord 4.2. (#199)
|
@@ -119,7 +126,7 @@
|
|
119
126
|
* Add support for :deferrable => :initially_deferred (thanks to
|
120
127
|
[@bhavinkamani](https://github.com/bhavinkamani))
|
121
128
|
* Works with PostGIS (thanks to [@pete](https://github.com/pete))
|
122
|
-
* Bug fix: Circular Reference/Stack Level Too Deep in Column#to_json.
|
129
|
+
* Bug fix: Circular Reference/Stack Level Too Deep in Column#to_json.
|
123
130
|
Thanks to [@robdimarco](https://github.com/robdimarco) for tracking down the problem
|
124
131
|
* Bug fix: More robust handling of foreign keys with schema namespaces
|
125
132
|
|
@@ -170,7 +177,7 @@
|
|
170
177
|
by [@betelgeuse](https://github.com/betelgeuse)
|
171
178
|
* 0.3.4 - Bug fix: regression causing :default => false to be ignored
|
172
179
|
* 0.3.3 - Bug fix: properly handle boolean defaults in mysql
|
173
|
-
* 0.3.2 - Bug fix: make sure rake db:schema:load initializes schema_plus
|
180
|
+
* 0.3.2 - Bug fix: make sure rake db:schema:load initializes schema_plus
|
174
181
|
* 0.3.1 - Bug fix for PostgreSQL schema dump after change_column_default(...
|
175
182
|
nil)
|
176
183
|
* 0.3.0 - Add :default => expressions (Thanks to Luke Saunders). support
|
data/MIT-LICENSE
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
Copyright (c) 2006 RedHill Consulting, Pty. Ltd.
|
2
|
-
Copyright (c) 2009 Michal Lomnicki & Ronen Barzel
|
2
|
+
Copyright (c) 2009 Michal Lomnicki & Ronen Barzel
|
3
3
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining
|
5
5
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -258,7 +258,7 @@ resolves to:
|
|
258
258
|
NOW() # PostgreSQL
|
259
259
|
(DATETIME('now')) # SQLite3
|
260
260
|
invalid # MySQL
|
261
|
-
|
261
|
+
|
262
262
|
If you are using Postgresql with a `json` column, the default value may be an unadorned hash. A hash having just one key `:expr` or `:value` will be taken as schema_plus syntax; i.e, these two are equivalent:
|
263
263
|
|
264
264
|
t.json :fields, default: { field1: 'a', field2: 'b' }
|
data/gemfiles/Gemfile.base
CHANGED
@@ -65,7 +65,7 @@ module SchemaPlus
|
|
65
65
|
|
66
66
|
ACTIONS = { :cascade => "CASCADE", :restrict => "RESTRICT", :set_null => "SET NULL", :set_default => "SET DEFAULT", :no_action => "NO ACTION" }.freeze
|
67
67
|
|
68
|
-
def initialize(from_table, to_table, options)
|
68
|
+
def initialize(from_table, to_table, options)
|
69
69
|
super
|
70
70
|
@from_table = unquote(from_table)
|
71
71
|
@to_table = unquote(to_table)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module SchemaPlus
|
2
2
|
module ActiveRecord
|
3
3
|
module ConnectionAdapters
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# SchemaPlus extends the IndexDefinition object to return information
|
6
6
|
# about partial indexes and case sensitivity (i.e. Postgresql
|
7
7
|
# support).
|
@@ -9,7 +9,7 @@ module SchemaPlus
|
|
9
9
|
def self.included(base) #:nodoc:
|
10
10
|
base.alias_method_chain :initialize, :schema_plus
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
attr_accessor :conditions
|
14
14
|
attr_reader :expression
|
15
15
|
attr_reader :kind
|
@@ -218,8 +218,8 @@ module SchemaPlus
|
|
218
218
|
opclass_name[oid.to_s] = opcname
|
219
219
|
end
|
220
220
|
operator_classes = {}
|
221
|
-
|
222
|
-
operator_classes[
|
221
|
+
column_names.zip(opclasses).each do |column_name, opclass|
|
222
|
+
operator_classes[column_name] = opclass_name[opclass]
|
223
223
|
end
|
224
224
|
operator_classes.delete_if{|k,v| v.nil?}
|
225
225
|
|
@@ -63,7 +63,7 @@ module SchemaPlus::ActiveRecord::ConnectionAdapters
|
|
63
63
|
raise unless e.message.match(/["']([^"']+)["'].*already exists/)
|
64
64
|
name = $1
|
65
65
|
existing = connection.indexes(table).find{|i| i.name == name}
|
66
|
-
attempted = ::ActiveRecord::ConnectionAdapters::IndexDefinition.new(table, columns, options.merge(:name => name))
|
66
|
+
attempted = ::ActiveRecord::ConnectionAdapters::IndexDefinition.new(table, columns, options.merge(:name => name))
|
67
67
|
raise if attempted != existing
|
68
68
|
::ActiveRecord::Base.logger.warn "[schema_plus] Index name #{name.inspect}' on table #{table.inspect} already exists. Skipping."
|
69
69
|
end
|
@@ -34,7 +34,7 @@ module SchemaPlus::ActiveRecord::ConnectionAdapters
|
|
34
34
|
# SchemaPlus also supports creation of foreign key constraints analogously, using Migration::ClassMethods#add_foreign_key or TableDefinition#foreign_key or as part of the column definition, for example:
|
35
35
|
#
|
36
36
|
# create_table :posts do |t| # not DRY
|
37
|
-
# t.integer :author_id
|
37
|
+
# t.integer :author_id
|
38
38
|
# end
|
39
39
|
# add_foreign_key :posts, :author_id, :references => :authors
|
40
40
|
#
|
@@ -144,7 +144,7 @@ module SchemaPlus::ActiveRecord::ConnectionAdapters
|
|
144
144
|
sql
|
145
145
|
end
|
146
146
|
|
147
|
-
# Define an index for the current
|
147
|
+
# Define an index for the current
|
148
148
|
if ::ActiveRecord::VERSION::MAJOR.to_i < 4
|
149
149
|
def index(column_name, options={})
|
150
150
|
@indexes << ::ActiveRecord::ConnectionAdapters::IndexDefinition.new(self.name, column_name, options)
|
@@ -9,7 +9,7 @@ module SchemaPlus::ActiveRecord
|
|
9
9
|
# The <tt>:index</tt> option takes a hash of parameters to pass to ActiveRecord::Migration.add_index. Thus
|
10
10
|
#
|
11
11
|
# add_column('books', 'isbn', :string, :index => {:name => "ISBN-index", :unique => true })
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# is equivalent to:
|
14
14
|
#
|
15
15
|
# add_column('books', 'isbn', :string)
|
@@ -19,7 +19,7 @@ module SchemaPlus::ActiveRecord
|
|
19
19
|
# In order to support multi-column indexes, an special parameter <tt>:with</tt> may be specified, which takes another column name or an array of column names to include in the index. Thus
|
20
20
|
#
|
21
21
|
# add_column('contacts', 'phone_number', :string, :index => { :with => [:country_code, :area_code], :unique => true })
|
22
|
-
#
|
22
|
+
#
|
23
23
|
# is equivalent to:
|
24
24
|
#
|
25
25
|
# add_column('contacts', 'phone_number', :string)
|
@@ -111,7 +111,7 @@ module SchemaPlus::ActiveRecord
|
|
111
111
|
# add_column('widgets', 'color', :integer, :references => 'colors', :index => true)
|
112
112
|
#
|
113
113
|
# If you want to pass options to the index, you can explcitly pass
|
114
|
-
# index options, such as <tt>:index => :unique</tt>.
|
114
|
+
# index options, such as <tt>:index => :unique</tt>.
|
115
115
|
#
|
116
116
|
# If you don't want an index to be created, specify
|
117
117
|
# <tt>:index => nil</tt>.
|
@@ -23,7 +23,7 @@ module SchemaPlus
|
|
23
23
|
end
|
24
24
|
|
25
25
|
# seems like this is fixing a rails bug:
|
26
|
-
# change_table foo, :bulk => true { |t| t.references :bar }
|
26
|
+
# change_table foo, :bulk => true { |t| t.references :bar }
|
27
27
|
# results in an 'unknown method :add_reference_sql' (with mysql2)
|
28
28
|
#
|
29
29
|
# should track it down separately and submit a patch/fix to rails
|
@@ -66,7 +66,7 @@ module SchemaPlus
|
|
66
66
|
def add_foreign_key(*args)
|
67
67
|
record(:add_foreign_key, args)
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
def invert_add_foreign_key(args)
|
71
71
|
table_name, column_names, references_table_name, references_column_names, options = args
|
72
72
|
[:remove_foreign_key, [table_name, column_names, references_table_name, references_column_names, (options||{}).merge(if_exists: true)]]
|
@@ -39,7 +39,7 @@ module SchemaPlus
|
|
39
39
|
|
40
40
|
def break_fk_cycles #:nodoc:
|
41
41
|
strongly_connected_components.select{|component| component.size > 1}.each do |tables|
|
42
|
-
table = tables.sort.
|
42
|
+
table = tables.sort.last
|
43
43
|
backref_fks = @inline_fks[table].select{|fk| tables.include?(fk.references_table_name)}
|
44
44
|
@inline_fks[table] -= backref_fks
|
45
45
|
@dump_dependencies[table] -= backref_fks.collect(&:references_table_name)
|
@@ -149,7 +149,7 @@ module SchemaPlus
|
|
149
149
|
dump << " :name => #{index.name.inspect}"
|
150
150
|
dump << ", :unique => true" if index.unique
|
151
151
|
dump << ", :kind => \"#{index.kind}\"" unless index.kind.blank?
|
152
|
-
unless index.columns.blank?
|
152
|
+
unless index.columns.blank?
|
153
153
|
dump << ", :case_sensitive => false" unless index.case_sensitive?
|
154
154
|
dump << ", :conditions => #{index.conditions.inspect}" unless index.conditions.blank?
|
155
155
|
index_lengths = index.lengths.compact if index.lengths.is_a?(Array)
|
data/lib/schema_plus/version.rb
CHANGED
data/spec/column_default_spec.rb
CHANGED
data/spec/column_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe "Column" do
|
|
5
5
|
before(:all) do
|
6
6
|
class User < ::ActiveRecord::Base ; end
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
let(:migration) { ::ActiveRecord::Migration }
|
10
10
|
|
11
11
|
context "JSON serialization" do
|
@@ -32,7 +32,7 @@ describe "Column" do
|
|
32
32
|
|
33
33
|
context "if not unique" do
|
34
34
|
|
35
|
-
before(:each) do
|
35
|
+
before(:each) do
|
36
36
|
create_table(User, :login => { :index => true})
|
37
37
|
@login = User.columns.find{|column| column.name == "login"}
|
38
38
|
end
|
@@ -48,7 +48,7 @@ describe "Column" do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
context "if unique single column" do
|
51
|
-
before(:each) do
|
51
|
+
before(:each) do
|
52
52
|
create_table(User, :login => { :index => :unique})
|
53
53
|
@login = User.columns.find{|column| column.name == "login"}
|
54
54
|
end
|
@@ -64,7 +64,7 @@ describe "Column" do
|
|
64
64
|
|
65
65
|
context "if unique multicolumn" do
|
66
66
|
|
67
|
-
before(:each) do
|
67
|
+
before(:each) do
|
68
68
|
create_table(User, :first => {}, :middle => {}, :last => { :index => {:with => [:first, :middle], :unique => true}})
|
69
69
|
@first = User.columns.find{|column| column.name == "first"}
|
70
70
|
@middle = User.columns.find{|column| column.name == "middle"}
|
data/spec/schema/auto_schema.rb
CHANGED
data/spec/schema_dumper_spec.rb
CHANGED
@@ -160,7 +160,7 @@ describe "Schema dump" do
|
|
160
160
|
expect(dump_posts).to match(to_regexp(%q{t.index ["user_id"], :name => "custom_name"}))
|
161
161
|
end
|
162
162
|
end
|
163
|
-
|
163
|
+
|
164
164
|
it "should define unique index" do
|
165
165
|
with_index Post, :user_id, :name => "posts_user_id_index", :unique => true do
|
166
166
|
expect(dump_posts).to match(to_regexp(%q{t.index ["user_id"], :name => "posts_user_id_index", :unique => true}))
|
@@ -229,6 +229,12 @@ describe "Schema dump" do
|
|
229
229
|
end
|
230
230
|
end
|
231
231
|
|
232
|
+
it 'should dump proper operator_class with case_sensitive => false' do
|
233
|
+
with_index Post, :body, :operator_class => 'text_pattern_ops', :case_sensitive => false do
|
234
|
+
expect(dump_posts).to match(to_regexp(%q{t.index ["body"], :name => "index_posts_on_body", :case_sensitive => false, :operator_class => {"body" => "text_pattern_ops"}}))
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
232
238
|
it "should dump unique: true with expression (Issue #142)" do
|
233
239
|
with_index Post, :name => "posts_user_body_index", :unique => true, :expression => "BTRIM(LOWER(body))" do
|
234
240
|
expect(dump_posts).to match(%r{#{to_regexp(%q{t.index :name => "posts_user_body_index", :unique => true, :expression => "btrim(lower(body))"})}$})
|
@@ -278,6 +284,97 @@ describe "Schema dump" do
|
|
278
284
|
expect(dump_schema).to match(%r{create_table "users".*foreign_key.*\["commenter_id"\], "users", \["id"\]}m)
|
279
285
|
expect(dump_schema).to match(%r{create_table "users".*foreign_key.*\["user_id"\], "users", \["id"\]}m)
|
280
286
|
end
|
287
|
+
|
288
|
+
context 'with complicated schemas' do
|
289
|
+
before(:all) do
|
290
|
+
|
291
|
+
SchemaPlus.setup do |config|
|
292
|
+
config.foreign_keys.auto_create = false
|
293
|
+
end
|
294
|
+
ActiveRecord::Migration.suppress_messages do
|
295
|
+
ActiveRecord::Schema.define do
|
296
|
+
connection.tables.each do |table| drop_table table, :cascade => true end
|
297
|
+
|
298
|
+
create_table :period_types, force: true do |t|
|
299
|
+
t.string :name
|
300
|
+
end
|
301
|
+
|
302
|
+
create_table :grade_systems, force: true do |t|
|
303
|
+
t.string :name
|
304
|
+
t.integer :school_id
|
305
|
+
t.integer :parent_id
|
306
|
+
t.integer :profile_id
|
307
|
+
end
|
308
|
+
|
309
|
+
create_table :schools, force: true do |t|
|
310
|
+
t.string :name
|
311
|
+
t.integer :default_grade_system_id
|
312
|
+
end
|
313
|
+
|
314
|
+
create_table :academic_years, force: true do |t|
|
315
|
+
t.string :name
|
316
|
+
t.integer :school_id
|
317
|
+
t.integer :period_type_id
|
318
|
+
end
|
319
|
+
|
320
|
+
create_table :buildings, force: true do |t|
|
321
|
+
t.string :name
|
322
|
+
t.integer :school_id
|
323
|
+
end
|
324
|
+
|
325
|
+
create_table :publishing_houses, force: true do |t|
|
326
|
+
t.string :name
|
327
|
+
end
|
328
|
+
|
329
|
+
create_table :profiles, force: true do |t|
|
330
|
+
t.integer :school_id
|
331
|
+
t.integer :publishing_house_id
|
332
|
+
t.integer :building_id
|
333
|
+
end
|
334
|
+
|
335
|
+
create_table :class_units, force: true do |t|
|
336
|
+
t.string :name
|
337
|
+
t.integer :school_id
|
338
|
+
t.integer :mentor_id
|
339
|
+
t.integer :building_id
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
class ::AcademicYear < ActiveRecord::Base ; end
|
345
|
+
class ::Building < ActiveRecord::Base ; end
|
346
|
+
class ::ClassUnit < ActiveRecord::Base ; end
|
347
|
+
class ::GradeSystem < ActiveRecord::Base ; end
|
348
|
+
class ::Profile < ActiveRecord::Base ; end
|
349
|
+
class ::PublishingHouse < ActiveRecord::Base ; end
|
350
|
+
class ::PeriodType < ActiveRecord::Base ; end
|
351
|
+
class ::School < ActiveRecord::Base ; end
|
352
|
+
|
353
|
+
ActiveRecord::Base.connection.add_foreign_key(School.table_name, :default_grade_system_id, GradeSystem.table_name, :id)
|
354
|
+
ActiveRecord::Base.connection.add_foreign_key(GradeSystem.table_name, :school_id, School.table_name, :id)
|
355
|
+
ActiveRecord::Base.connection.add_foreign_key(GradeSystem.table_name, :parent_id, GradeSystem.table_name, :id)
|
356
|
+
ActiveRecord::Base.connection.add_foreign_key(GradeSystem.table_name, :profile_id, Profile.table_name, :id)
|
357
|
+
ActiveRecord::Base.connection.add_foreign_key(Profile.table_name, :building_id, Building.table_name, :id)
|
358
|
+
ActiveRecord::Base.connection.add_foreign_key(Profile.table_name, :school_id, School.table_name, :id)
|
359
|
+
ActiveRecord::Base.connection.add_foreign_key(ClassUnit.table_name, :school_id, School.table_name, :id)
|
360
|
+
ActiveRecord::Base.connection.add_foreign_key(ClassUnit.table_name, :building_id, Building.table_name, :id)
|
361
|
+
ActiveRecord::Base.connection.add_foreign_key(ClassUnit.table_name, :mentor_id, Profile.table_name, :id)
|
362
|
+
ActiveRecord::Base.connection.add_foreign_key(Building.table_name, :school_id, School.table_name, :id)
|
363
|
+
ActiveRecord::Base.connection.add_foreign_key(AcademicYear.table_name, :school_id, School.table_name, :id)
|
364
|
+
ActiveRecord::Base.connection.add_foreign_key(AcademicYear.table_name, :period_type_id, PeriodType.table_name, :id)
|
365
|
+
ActiveRecord::Base.connection.add_foreign_key(Profile.table_name, :publishing_house_id, PublishingHouse.table_name, :id)
|
366
|
+
end
|
367
|
+
|
368
|
+
it "should not raise an error" do
|
369
|
+
expect { dump_schema }.to_not raise_error
|
370
|
+
end
|
371
|
+
|
372
|
+
it "should dump each constraint after both related tables were defined" do
|
373
|
+
expect(dump_schema.scan(%r{add_foreign_key}m).count).to eq 1
|
374
|
+
expect(dump_schema).to match(%r{create_table "schools".*add_foreign_key\s+"schools".*\["default_grade_system_id"\], "grade_systems", \["id"\]}m)
|
375
|
+
expect(dump_schema).to match(%r{create_table "grade_systems".*add_foreign_key\s+"schools".*\["default_grade_system_id"\], "grade_systems", \["id"\]}m)
|
376
|
+
end
|
377
|
+
end
|
281
378
|
end
|
282
379
|
|
283
380
|
context 'with enum', :postgresql => :only do
|
@@ -372,7 +469,7 @@ describe "Schema dump" do
|
|
372
469
|
end
|
373
470
|
|
374
471
|
def determine_foreign_key_name(model, columns, options)
|
375
|
-
name = options[:name]
|
472
|
+
name = options[:name]
|
376
473
|
name ||= model.foreign_keys.detect { |fk| fk.table_name == model.table_name.to_s && fk.column_names == Array(columns).collect(&:to_s) }.name
|
377
474
|
end
|
378
475
|
|
@@ -5,7 +5,7 @@ module SchemaPlusMatchers
|
|
5
5
|
@column_names = @on_update = @on_delete = @deferrable = @name = @references_table_name = @references_column_names = nil
|
6
6
|
unless expected.empty?
|
7
7
|
@references_column_names = Array(expected).collect(&:to_s)
|
8
|
-
@references_table_name = @references_column_names.shift
|
8
|
+
@references_table_name = @references_column_names.shift
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -13,8 +13,8 @@ module SchemaPlusMatchers
|
|
13
13
|
@model = model
|
14
14
|
if @references_table_name
|
15
15
|
@result = @model.foreign_keys.select do |fk|
|
16
|
-
fk.references_table_name == @references_table_name &&
|
17
|
-
@references_column_names.empty? ? true : fk.references_column_names == @references_column_names
|
16
|
+
fk.references_table_name == @references_table_name &&
|
17
|
+
@references_column_names.empty? ? true : fk.references_column_names == @references_column_names
|
18
18
|
end
|
19
19
|
else
|
20
20
|
@result = @model.foreign_keys
|
@@ -28,7 +28,7 @@ module SchemaPlusMatchers
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def failure_message(should_not = false)
|
31
|
-
target_column_names = @column_names.present? ? "(#{@column_names.join(', ')})" : ""
|
31
|
+
target_column_names = @column_names.present? ? "(#{@column_names.join(', ')})" : ""
|
32
32
|
destinantion_column_names = @references_table_name ? "#{@references_table_name}(#{@references_column_names.join(', ')})" : "anything"
|
33
33
|
invert = should_not ? 'not' : ''
|
34
34
|
msg = "Expected #{@model.table_name}#{target_column_names} to #{invert} reference #{destinantion_column_names}"
|
@@ -44,7 +44,7 @@ module SchemaPlusMatchers
|
|
44
44
|
def failure_message_when_negated
|
45
45
|
failure_message(true)
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
def on(*column_names)
|
49
49
|
@column_names = column_names.collect(&:to_s)
|
50
50
|
self
|
data/spec/views_spec.rb
CHANGED
@@ -49,7 +49,7 @@ describe ActiveRecord do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should be included in schema dump in dependency order" do
|
52
|
-
expect(dump).to match(%r{create_table "items".*create_view "a_ones".*create_view "ab_ones"}m)
|
52
|
+
expect(dump).to match(%r{create_table "items".*create_view "a_ones".*create_view "ab_ones"}m)
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should not be included in schema if listed in ignore_tables" do
|
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.
|
4
|
+
version: 1.8.7
|
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-
|
12
|
+
date: 2015-02-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|