schema_plus 2.0.0.pre1 → 2.0.0.pre2

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: 090fdf5adb8715e2bb78a10c58b7f5f5d4e9b219
4
- data.tar.gz: 8950e08cdd6cbf912cb8508e40ce4b2449f914a0
3
+ metadata.gz: 7b7cafb63e57f4fa258f90908feff00e0e2b7dc0
4
+ data.tar.gz: 64c3b8e806e0ea043cf452f0b4e76cf29284d86c
5
5
  SHA512:
6
- metadata.gz: fcd75a62438cf8a1feb618f37a2e7e99bdc30a6691bf0131908978af5e8410ae330f537692f97e64b1a3f10f9588faeafc6c16860213d1d9dafeb9ac1bef7395
7
- data.tar.gz: 6088b9ddf4b227aa4fa021c3ebed7be1369c881efcc392a5942d692a82ca5ba8e5058d35387d1794afecbde9e4ed1b143caa435aab7f09cff5d47fb81ec502af
6
+ metadata.gz: c30f67be8321db51e354b2f143dfd80b7f07fdb09f4dd61545e52e62d55586b8a91cc473d33dd55236c44a73155285681ab918fc36fc81038e3f285768eb84e7
7
+ data.tar.gz: 0fe7149f1e8dcf69ff94b80966da3227f765ca2df725883b40af5f224b39ebc58c443bdb95acc44c08bbf6c7324fb41b1e4634a111249a17359d40a828420706
data/README.md CHANGED
@@ -13,12 +13,12 @@
13
13
 
14
14
  Starting with version 2.0.0, schema_plus is a wrapper that pulls in a collection of individual feature gems:
15
15
 
16
- * [schema_plus_indexes](https://github.com/SchemaPlus/schema_plus_indexes) -- Convenience and consistency in defining and manipulting indexes
16
+ * [schema_plus_indexes](https://github.com/SchemaPlus/schema_plus_indexes) -- Convenience and consistency in defining and manipulating indexes
17
17
  * [schema_plus_pg_indexes](https://github.com/SchemaPlus/schema_plus_pg_indexes) -- Support for PostgreSQL index features: `case_insenstive`, `expression` and `operator_class`
18
18
 
19
19
  See detailed documentation in each feature gem's README. You can of course just use whichever of those gems you want individually, rather than this wrapper.
20
20
 
21
- > **IN PROGRESS:** In the prerelease versions of SchemaPlus 2.0, more feature gems have yet to be stripped out, and the code is still in the body of schema_plus. Anticipated features gems include:
21
+ > **IN PROGRESS:** In the prerelease versions of SchemaPlus 2.0, more feature gems have yet to be cleaned up and stripped out, and their code is still in the body of schema_plus. Anticipated features gems include:
22
22
  >
23
23
  > * schema_plus_columns -- Extra Column features, including `column.indexes` and `column.unique?`
24
24
  > * schema_plus_db_default -- Supports `update_attributes!(my_attr: ActiveRecord::DB_DEFAULT)` to set a column back to the default in the database schema.
@@ -29,6 +29,8 @@ See detailed documentation in each feature gem's README. You can of course just
29
29
  > * schema_plus_views -- Adds support for creating and manipulating views
30
30
  >
31
31
  > The documentation for these features is at the end of this README
32
+ >
33
+ > If you'd like to follow or contribute to the discussion of this refactoring, take a look at issue SchemaPlus/schema_plus/197
32
34
 
33
35
 
34
36
  ## Upgrading from SchemaPlus 1.8.x
@@ -38,9 +40,9 @@ SchemaPlus 2.0.x intends to be a completely backwards-compatible drop-in replace
38
40
  If you find any incompatibilities, please report an issue!
39
41
 
40
42
  ### Deprecations
41
- In cases where rails 4.2 has introduced features previously supported only by SchemaPlus, but using different names, SchemaPlus 2.0 now issues deprecation warnings in favor of the rails form. The complete list of deprecations:
43
+ In cases where rails 4.2 has introduced features previously supported only by SchemaPlus, but using different names, the SchemaPlus 2.0 family of gems now issue deprecation warnings in favor of the rails form. The complete list of deprecations:
42
44
 
43
- * Index definitions deprecate these options:
45
+ * Index definition deprecates these options:
44
46
  * `:conditions` => `:where`
45
47
  * `:kind` => `:using`
46
48
 
@@ -52,13 +54,13 @@ In cases where rails 4.2 has introduced features previously supported only by Sc
52
54
 
53
55
  * `ForeignKeyDefinition` deprecates accessors:
54
56
  * `#table_name` in favor of `#from_table`
55
- * `#column_names` in favor of `#column`
57
+ * `#column_names` in favor of `Array.wrap(#column)`
56
58
  * `#references_column_names` in favor of `#primary_key`
57
59
  * `#references_table_name in favor of `#to_table`
58
60
 
59
61
  * `IndexDefinition` deprecates accessors:
60
62
  * `#conditions` in favor of `#where`
61
- * `#kind` in favor of `#using`
63
+ * `#kind` in favor of `#using.to_s`
62
64
 
63
65
  ## Compatibility
64
66
 
@@ -90,7 +92,7 @@ or in a Gemfile
90
92
 
91
93
  * SchemaPlus was created in 2011 by [@mlomnicki](https://github.com/mlomnicki) and [@ronen](https://github.com/ronen)
92
94
 
93
- * And [lots of contributors](https://github.com/SchemaPlus/schema_plus/graphs/contributors) since then
95
+ * And [lots of contributors](https://github.com/SchemaPlus/schema_plus/graphs/contributors) since then.
94
96
 
95
97
  ## Development & Testing
96
98
 
@@ -22,7 +22,7 @@ module SchemaDefaultExpr
22
22
  # Currently, the only function to support is :now, which should
23
23
  # return a DATETIME object for the current time.
24
24
  #
25
- autoload :MysqlAdapter, 'schema_default_expr/active_record/connection_adapters/mysql_adapter'
25
+ autoload :Mysql2Adapter, 'schema_default_expr/active_record/connection_adapters/mysql2_adapter'
26
26
  autoload :PostgresqlAdapter, 'schema_default_expr/active_record/connection_adapters/postgresql_adapter'
27
27
  autoload :Sqlite3Adapter, 'schema_default_expr/active_record/connection_adapters/sqlite3_adapter'
28
28
  end
@@ -1,7 +1,7 @@
1
1
  module SchemaDefaultExpr
2
2
  module ActiveRecord
3
3
  module ConnectionAdapters
4
- module MysqlAdapter
4
+ module Mysql2Adapter
5
5
  def default_expr_valid?(expr)
6
6
  false # only the TIMESTAMP column accepts SQL column defaults and rails uses DATETIME
7
7
  end
@@ -28,7 +28,7 @@ module SchemaPlus
28
28
  module ActiveRecord
29
29
 
30
30
  module ConnectionAdapters
31
- autoload :MysqlAdapter, 'schema_plus/active_record/connection_adapters/mysql_adapter'
31
+ autoload :Mysql2Adapter, 'schema_plus/active_record/connection_adapters/mysql2_adapter'
32
32
  autoload :PostgresqlAdapter, 'schema_plus/active_record/connection_adapters/postgresql_adapter'
33
33
  autoload :Sqlite3Adapter, 'schema_plus/active_record/connection_adapters/sqlite3_adapter'
34
34
  end
@@ -3,7 +3,7 @@ module SchemaPlus
3
3
  module ConnectionAdapters
4
4
  # SchemaPlus includes a MySQL implementation of the AbstractAdapter
5
5
  # extensions.
6
- module MysqlAdapter
6
+ module Mysql2Adapter
7
7
 
8
8
  #:enddoc:
9
9
 
@@ -74,6 +74,9 @@ module SchemaPlus::ActiveRecord::ConnectionAdapters
74
74
  def foreign_key(*args) # (column_names, to_table, primary_key=nil, options=nil)
75
75
  options = args.extract_options!
76
76
  case args.length
77
+ when 1
78
+ to_table = args[0]
79
+ column_names = "#{to_table.to_s.singularize}_id"
77
80
  when 2
78
81
  column_names, to_table = args
79
82
  when 3
@@ -1,3 +1,3 @@
1
1
  module SchemaPlus
2
- VERSION = "2.0.0.pre1"
2
+ VERSION = "2.0.0.pre2"
3
3
  end
@@ -5,7 +5,7 @@ require_relative 'schema_plus_tables/active_record/connection_adapters/abstract_
5
5
  module SchemaPlusTables
6
6
  module ActiveRecord
7
7
  module ConnectionAdapters
8
- autoload :MysqlAdapter, 'schema_plus_tables/active_record/connection_adapters/mysql_adapter'
8
+ autoload :Mysql2Adapter, 'schema_plus_tables/active_record/connection_adapters/mysql2_adapter'
9
9
  autoload :PostgresqlAdapter, 'schema_plus_tables/active_record/connection_adapters/postgresql_adapter'
10
10
  autoload :Sqlite3Adapter, 'schema_plus_tables/active_record/connection_adapters/sqlite3_adapter'
11
11
  end
@@ -1,7 +1,7 @@
1
1
  module SchemaPlusTables
2
2
  module ActiveRecord
3
3
  module ConnectionAdapters
4
- module MysqlAdapter
4
+ module Mysql2Adapter
5
5
 
6
6
  # implement cascade by removing foreign keys
7
7
  def drop_table(name, options={})
@@ -6,7 +6,7 @@ require_relative 'schema_views/middleware'
6
6
  module SchemaViews
7
7
  module ActiveRecord
8
8
  module ConnectionAdapters
9
- autoload :MysqlAdapter, 'schema_views/active_record/connection_adapters/mysql_adapter'
9
+ autoload :Mysql2Adapter, 'schema_views/active_record/connection_adapters/mysql2_adapter'
10
10
  autoload :PostgresqlAdapter, 'schema_views/active_record/connection_adapters/postgresql_adapter'
11
11
  autoload :Sqlite3Adapter, 'schema_views/active_record/connection_adapters/sqlite3_adapter'
12
12
  end
@@ -1,7 +1,7 @@
1
1
  module SchemaViews
2
2
  module ActiveRecord
3
3
  module ConnectionAdapters
4
- module MysqlAdapter
4
+ module Mysql2Adapter
5
5
 
6
6
  def views(name = nil)
7
7
  views = []
@@ -21,9 +21,9 @@ Gem::Specification.new do |s|
21
21
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
22
  s.require_paths = ["lib"]
23
23
 
24
- s.add_dependency "activerecord", ">= 3.2", "< 4.3"
24
+ s.add_dependency "activerecord", "~> 4.2"
25
25
  s.add_dependency "valuable"
26
- s.add_dependency "schema_monkey", "~> 0.1"
26
+ s.add_dependency "schema_monkey", "~> 0.4"
27
27
  s.add_dependency "schema_plus_indexes", "~> 0.1"
28
28
  s.add_dependency "schema_plus_pg_indexes", "~> 0.1"
29
29
 
@@ -128,6 +128,18 @@ describe "Column" do
128
128
 
129
129
  end
130
130
 
131
+ context "Postgresql array", :postgresql => :only do
132
+
133
+ before(:each) do
134
+ create_table(User, :alpha => { :default => [], :array => true })
135
+ end
136
+
137
+ it "respects array: true" do
138
+ column = User.columns.find(&its.name == "alpha")
139
+ expect(column.array).to be_truthy
140
+ end
141
+ end
142
+
131
143
  protected
132
144
 
133
145
  def create_table(model, columns_with_options)
@@ -31,9 +31,8 @@ describe ActiveRecord::Schema do
31
31
  expect(connection.tables.collect { |table| connection.foreign_keys(table) }.flatten.size).to eq(2)
32
32
  end
33
33
 
34
- end
35
-
36
34
  protected
35
+
37
36
  def do_schema
38
37
  define_schema do
39
38
 
@@ -54,6 +53,29 @@ describe ActiveRecord::Schema do
54
53
  end
55
54
  end
56
55
 
56
+ end
57
+
58
+ it "handles explicit foreign keys" do
59
+ expect {
60
+ with_auto_create(false) do
61
+ define_schema do
62
+ create_table :users, :force => :cascade do
63
+ end
64
+
65
+ create_table :posts, :force => :cascade do |t|
66
+ t.integer :user_id
67
+ t.foreign_key :users
68
+ end
69
+ end
70
+ end
71
+ }.not_to raise_error
72
+ expect(connection.foreign_keys("posts").first.to_table).to eq "users"
73
+ end
74
+
75
+
76
+ protected
77
+
78
+
57
79
  def with_auto_index(value = true)
58
80
  old_value = SchemaPlus.config.foreign_keys.auto_index
59
81
  SchemaPlus.config.foreign_keys.auto_index = value
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: 2.0.0.pre1
4
+ version: 2.0.0.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ronen Barzel
@@ -9,28 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-26 00:00:00.000000000 Z
12
+ date: 2015-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
19
- - !ruby/object:Gem::Version
20
- version: '3.2'
21
- - - "<"
18
+ - - "~>"
22
19
  - !ruby/object:Gem::Version
23
- version: '4.3'
20
+ version: '4.2'
24
21
  type: :runtime
25
22
  prerelease: false
26
23
  version_requirements: !ruby/object:Gem::Requirement
27
24
  requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- version: '3.2'
31
- - - "<"
25
+ - - "~>"
32
26
  - !ruby/object:Gem::Version
33
- version: '4.3'
27
+ version: '4.2'
34
28
  - !ruby/object:Gem::Dependency
35
29
  name: valuable
36
30
  requirement: !ruby/object:Gem::Requirement
@@ -51,14 +45,14 @@ dependencies:
51
45
  requirements:
52
46
  - - "~>"
53
47
  - !ruby/object:Gem::Version
54
- version: '0.1'
48
+ version: '0.4'
55
49
  type: :runtime
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
52
  requirements:
59
53
  - - "~>"
60
54
  - !ruby/object:Gem::Version
61
- version: '0.1'
55
+ version: '0.4'
62
56
  - !ruby/object:Gem::Dependency
63
57
  name: schema_plus_indexes
64
58
  requirement: !ruby/object:Gem::Requirement
@@ -202,7 +196,6 @@ files:
202
196
  - gemfiles/rails-4.2/Gemfile.postgresql
203
197
  - gemfiles/rails-4.2/Gemfile.sqlite3
204
198
  - init.rb
205
- - lib/rails/tasks/database.rake
206
199
  - lib/schema_column_plus.rb
207
200
  - lib/schema_column_plus/active_record/connection_adapters/column.rb
208
201
  - lib/schema_column_plus/middleware/model.rb
@@ -211,7 +204,7 @@ files:
211
204
  - lib/schema_db_default/db_default.rb
212
205
  - lib/schema_db_default/middleware.rb
213
206
  - lib/schema_default_expr.rb
214
- - lib/schema_default_expr/active_record/connection_adapters/mysql_adapter.rb
207
+ - lib/schema_default_expr/active_record/connection_adapters/mysql2_adapter.rb
215
208
  - lib/schema_default_expr/active_record/connection_adapters/postgresql_adapter.rb
216
209
  - lib/schema_default_expr/active_record/connection_adapters/sqlite3_adapter.rb
217
210
  - lib/schema_default_expr/middleware.rb
@@ -222,7 +215,7 @@ files:
222
215
  - lib/schema_plus/active_record/base.rb
223
216
  - lib/schema_plus/active_record/connection_adapters/abstract_adapter.rb
224
217
  - lib/schema_plus/active_record/connection_adapters/foreign_key_definition.rb
225
- - lib/schema_plus/active_record/connection_adapters/mysql_adapter.rb
218
+ - lib/schema_plus/active_record/connection_adapters/mysql2_adapter.rb
226
219
  - lib/schema_plus/active_record/connection_adapters/postgresql_adapter.rb
227
220
  - lib/schema_plus/active_record/connection_adapters/schema_statements.rb
228
221
  - lib/schema_plus/active_record/connection_adapters/sqlite3_adapter.rb
@@ -235,12 +228,12 @@ files:
235
228
  - lib/schema_plus/version.rb
236
229
  - lib/schema_plus_tables.rb
237
230
  - lib/schema_plus_tables/active_record/connection_adapters/abstract_adapter.rb
238
- - lib/schema_plus_tables/active_record/connection_adapters/mysql_adapter.rb
231
+ - lib/schema_plus_tables/active_record/connection_adapters/mysql2_adapter.rb
239
232
  - lib/schema_plus_tables/active_record/connection_adapters/postgresql_adapter.rb
240
233
  - lib/schema_plus_tables/active_record/connection_adapters/sqlite3_adapter.rb
241
234
  - lib/schema_views.rb
242
235
  - lib/schema_views/active_record/connection_adapters/abstract_adapter.rb
243
- - lib/schema_views/active_record/connection_adapters/mysql_adapter.rb
236
+ - lib/schema_views/active_record/connection_adapters/mysql2_adapter.rb
244
237
  - lib/schema_views/active_record/connection_adapters/postgresql_adapter.rb
245
238
  - lib/schema_views/active_record/connection_adapters/sqlite3_adapter.rb
246
239
  - lib/schema_views/middleware.rb
@@ -1,5 +0,0 @@
1
- namespace :schema_plus do
2
- task :load do
3
- SchemaPlus.insert
4
- end
5
- end