schema_plus_core 2.1.1 → 2.2.0
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/.travis.yml +5 -1
- data/README.md +7 -3
- data/gemfiles/activerecord-5.2/Gemfile.base +3 -0
- data/gemfiles/activerecord-5.2/Gemfile.mysql2 +10 -0
- data/gemfiles/activerecord-5.2/Gemfile.postgresql +10 -0
- data/gemfiles/activerecord-5.2/Gemfile.sqlite3 +10 -0
- data/lib/schema_plus/core.rb +4 -0
- data/lib/schema_plus/core/active_record/base.rb +3 -3
- data/lib/schema_plus/core/active_record/connection_adapters/mysql2_adapter.rb +3 -4
- data/lib/schema_plus/core/active_record/connection_adapters/postgresql/schema_dumper.rb +40 -0
- data/lib/schema_plus/core/active_record/connection_adapters/postgresql_adapter.rb +4 -4
- data/lib/schema_plus/core/active_record/connection_adapters/sqlite3_adapter.rb +3 -5
- data/lib/schema_plus/core/version.rb +1 -1
- data/schema_dev.yml +3 -1
- data/schema_plus_core.gemspec +1 -1
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e8e79d68457a1e4ce6d7ff39807855e36cd2e9a
|
4
|
+
data.tar.gz: 5155f4e1926b764f3170c699eafb3e4cb789ecf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb5a7d23d7ab4f2fbb0c750386f4c5b721f9d8f4f72331290368569bbeba44e0da640c56b30c96728aa410e81bf9b39997fa9c214b835ca3e07ed62519da604e
|
7
|
+
data.tar.gz: 6e4369733968625498dcf83a73748640f2af0e9456fd9a2b045bc9052977850b3b597f1d00240af92001e163370e3556480d853103768a52ead5e4ed5b746ae7
|
data/.travis.yml
CHANGED
@@ -5,7 +5,8 @@
|
|
5
5
|
---
|
6
6
|
sudo: false
|
7
7
|
rvm:
|
8
|
-
- 2.
|
8
|
+
- 2.4.4
|
9
|
+
- 2.5.1
|
9
10
|
gemfile:
|
10
11
|
- gemfiles/activerecord-5.0/Gemfile.mysql2
|
11
12
|
- gemfiles/activerecord-5.0/Gemfile.postgresql
|
@@ -13,6 +14,9 @@ gemfile:
|
|
13
14
|
- gemfiles/activerecord-5.1/Gemfile.mysql2
|
14
15
|
- gemfiles/activerecord-5.1/Gemfile.postgresql
|
15
16
|
- gemfiles/activerecord-5.1/Gemfile.sqlite3
|
17
|
+
- gemfiles/activerecord-5.2/Gemfile.mysql2
|
18
|
+
- gemfiles/activerecord-5.2/Gemfile.postgresql
|
19
|
+
- gemfiles/activerecord-5.2/Gemfile.sqlite3
|
16
20
|
env: POSTGRESQL_DB_USER=postgres MYSQL_DB_USER=travis
|
17
21
|
addons:
|
18
22
|
postgresql: '9.4'
|
data/README.md
CHANGED
@@ -23,8 +23,12 @@ SchemaPlus::Core is tested on:
|
|
23
23
|
|
24
24
|
<!-- SCHEMA_DEV: MATRIX - begin -->
|
25
25
|
<!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
|
26
|
-
* ruby **2.
|
27
|
-
* ruby **2.
|
26
|
+
* ruby **2.4.4** with activerecord **5.0**, using **mysql2**, **sqlite3** or **postgresql**
|
27
|
+
* ruby **2.4.4** with activerecord **5.1**, using **mysql2**, **sqlite3** or **postgresql**
|
28
|
+
* ruby **2.4.4** with activerecord **5.2**, using **mysql2**, **sqlite3** or **postgresql**
|
29
|
+
* ruby **2.5.1** with activerecord **5.0**, using **mysql2**, **sqlite3** or **postgresql**
|
30
|
+
* ruby **2.5.1** with activerecord **5.1**, using **mysql2**, **sqlite3** or **postgresql**
|
31
|
+
* ruby **2.5.1** with activerecord **5.2**, using **mysql2**, **sqlite3** or **postgresql**
|
28
32
|
|
29
33
|
<!-- SCHEMA_DEV: MATRIX - end -->
|
30
34
|
|
@@ -127,7 +131,6 @@ Stacks for general operations queries pertaining to the entire database schema:
|
|
127
131
|
`:index_definitions` | The result of the lookup | `[]`
|
128
132
|
`:connection` | The current ActiveRecord connection | *context*
|
129
133
|
`:table_name` | The name of the table to query | *arg*
|
130
|
-
`:query_name` | Label sometimes used by ActiveRecord logging | *arg*
|
131
134
|
|
132
135
|
The base implementation appends its results to `env.index_definitions`
|
133
136
|
|
@@ -441,6 +444,7 @@ SchemaPlus::Core provides a state object and of callbacks to various phases of t
|
|
441
444
|
|
442
445
|
## Release Notes
|
443
446
|
|
447
|
+
* 2.2.0 Added AR5.2 support. Thanks to [@jeremyyap](https://github.com/jeremyyap)
|
444
448
|
* 2.1.1 Bug fix: Don't lose habtm options. Thanks to [@iagopiimenta ](https://github.com/iagopiimenta)
|
445
449
|
* 2.1.0 Added AR5.1 support. Thanks to [@iagopiimenta ](https://github.com/iagopiimenta)
|
446
450
|
* 2.0.1 Tighten up AR dependency. Thanks to [@myabc](https://github.com/myabc).
|
data/lib/schema_plus/core.rb
CHANGED
@@ -26,4 +26,8 @@ require_relative "core/schema_dump"
|
|
26
26
|
require_relative "core/sql_struct"
|
27
27
|
require_relative "core/version"
|
28
28
|
|
29
|
+
if ActiveRecord.version >= Gem::Version.new('5.2.0.rc1')
|
30
|
+
require_relative "core/active_record/connection_adapters/postgresql/schema_dumper"
|
31
|
+
end
|
32
|
+
|
29
33
|
SchemaMonkey.register(SchemaPlus::Core)
|
@@ -20,13 +20,13 @@ module SchemaPlus
|
|
20
20
|
# don't have a documented return value. But at least one gem
|
21
21
|
# (https://github.com/hzamani/active_record-acts_as/blob/master/lib/active_record/acts_as/relation.rb#L14)
|
22
22
|
# relies on the undocumented return value.
|
23
|
-
def has_many(name, scope = nil, options
|
23
|
+
def has_many(name, scope = nil, **options, &extension)
|
24
24
|
SchemaMonkey::Middleware::Model::Association::Declaration.start(model: self, name: name, scope: scope, options: options, extension: extension) do |env|
|
25
25
|
env.result = super(env.name, env.scope, env.options, &env.extension)
|
26
26
|
end.result
|
27
27
|
end
|
28
28
|
|
29
|
-
def has_one(name, scope = nil, options
|
29
|
+
def has_one(name, scope = nil, **options, &extension)
|
30
30
|
SchemaMonkey::Middleware::Model::Association::Declaration.start(model: self, name: name, scope: scope, options: options, extension: extension) do |env|
|
31
31
|
env.result = super(env.name, env.scope, env.options, &env.extension)
|
32
32
|
end.result
|
@@ -38,7 +38,7 @@ module SchemaPlus
|
|
38
38
|
end.result
|
39
39
|
end
|
40
40
|
|
41
|
-
def belongs_to(name, scope = nil, options
|
41
|
+
def belongs_to(name, scope = nil, **options, &extension)
|
42
42
|
SchemaMonkey::Middleware::Model::Association::Declaration.start(model: self, name: name, scope: scope, options: options, extension: extension) do |env|
|
43
43
|
env.result = super(env.name, env.scope, env.options, &env.extension)
|
44
44
|
end.result
|
@@ -28,9 +28,9 @@ module SchemaPlus
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def indexes(table_name
|
32
|
-
SchemaMonkey::Middleware::Schema::Indexes.start(connection: self, table_name: table_name,
|
33
|
-
env.index_definitions += super env.table_name
|
31
|
+
def indexes(table_name)
|
32
|
+
SchemaMonkey::Middleware::Schema::Indexes.start(connection: self, table_name: table_name, index_definitions: []) { |env|
|
33
|
+
env.index_definitions += super env.table_name
|
34
34
|
}.index_definitions
|
35
35
|
end
|
36
36
|
|
@@ -73,4 +73,3 @@ module SchemaPlus
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
76
|
-
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module SchemaPlus
|
2
|
+
module Core
|
3
|
+
module ActiveRecord
|
4
|
+
module ConnectionAdapters
|
5
|
+
module PostgreSQL
|
6
|
+
module PostgreSQL # need two PostgreSQLs because the first gets stripped by schema_monkey
|
7
|
+
module SchemaDumper
|
8
|
+
|
9
|
+
# quick hack fix quoting of column default functions to allow eval() when we
|
10
|
+
# capture the stream.
|
11
|
+
#
|
12
|
+
# AR's PostgresqlAdapter#prepare_column_options wraps the
|
13
|
+
# function in double quotes, which doesn't work because the
|
14
|
+
# function itself may have doublequotes in it which don't get
|
15
|
+
# escaped properly.
|
16
|
+
#
|
17
|
+
# Arguably that's a bug in AR, but then again default function
|
18
|
+
# expressions don't work well in AR anyway. (hence
|
19
|
+
# schema_plus_default_expr )
|
20
|
+
#
|
21
|
+
def prepare_column_options(column, *) # :nodoc:
|
22
|
+
spec = super
|
23
|
+
spec[:default] = "%q{#{column.default_function}}" if column.default_function
|
24
|
+
spec
|
25
|
+
end
|
26
|
+
|
27
|
+
def extensions(_)
|
28
|
+
SchemaMonkey::Middleware::Dumper::Initial.start(dumper: self, connection: @connection, dump: @dump, initial: @dump.initial) do |env|
|
29
|
+
stream = StringIO.new
|
30
|
+
super stream
|
31
|
+
env.dump.initial << stream.string unless stream.string.blank?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -10,7 +10,7 @@ module SchemaPlus
|
|
10
10
|
# AR's PostgresqlAdapter#prepare_column_options wraps the
|
11
11
|
# function in double quotes, which doesn't work because the
|
12
12
|
# function itself may have doublequotes in it which don't get
|
13
|
-
# escaped properly.
|
13
|
+
# escaped properly.
|
14
14
|
#
|
15
15
|
# Arguably that's a bug in AR, but then again default function
|
16
16
|
# expressions don't work well in AR anyway. (hence
|
@@ -58,9 +58,9 @@ module SchemaPlus
|
|
58
58
|
}.result
|
59
59
|
end
|
60
60
|
|
61
|
-
def indexes(table_name
|
62
|
-
SchemaMonkey::Middleware::Schema::Indexes.start(connection: self, table_name: table_name,
|
63
|
-
env.index_definitions += super env.table_name
|
61
|
+
def indexes(table_name)
|
62
|
+
SchemaMonkey::Middleware::Schema::Indexes.start(connection: self, table_name: table_name, index_definitions: []) { |env|
|
63
|
+
env.index_definitions += super env.table_name
|
64
64
|
}.index_definitions
|
65
65
|
end
|
66
66
|
|
@@ -28,9 +28,9 @@ module SchemaPlus
|
|
28
28
|
}.result
|
29
29
|
end
|
30
30
|
|
31
|
-
def indexes(table_name
|
32
|
-
SchemaMonkey::Middleware::Schema::Indexes.start(connection: self, table_name: table_name,
|
33
|
-
env.index_definitions += super env.table_name
|
31
|
+
def indexes(table_name)
|
32
|
+
SchemaMonkey::Middleware::Schema::Indexes.start(connection: self, table_name: table_name, index_definitions: []) { |env|
|
33
|
+
env.index_definitions += super env.table_name
|
34
34
|
}.index_definitions
|
35
35
|
end
|
36
36
|
|
@@ -44,5 +44,3 @@ module SchemaPlus
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
47
|
-
|
48
|
-
|
data/schema_dev.yml
CHANGED
data/schema_plus_core.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |gem|
|
|
26
26
|
gem.add_development_dependency "rake", "~> 10.0"
|
27
27
|
gem.add_development_dependency "rspec", "~> 3.0.0"
|
28
28
|
gem.add_development_dependency "rspec-given"
|
29
|
-
gem.add_development_dependency "schema_dev", "~> 3.
|
29
|
+
gem.add_development_dependency "schema_dev", "~> 3.11"
|
30
30
|
gem.add_development_dependency "simplecov"
|
31
31
|
gem.add_development_dependency "simplecov-gem-profile"
|
32
32
|
gem.add_development_dependency "its-it"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_plus_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ronen barzel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '3.
|
117
|
+
version: '3.11'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '3.
|
124
|
+
version: '3.11'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: simplecov
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -187,10 +187,15 @@ files:
|
|
187
187
|
- gemfiles/activerecord-5.1/Gemfile.mysql2
|
188
188
|
- gemfiles/activerecord-5.1/Gemfile.postgresql
|
189
189
|
- gemfiles/activerecord-5.1/Gemfile.sqlite3
|
190
|
+
- gemfiles/activerecord-5.2/Gemfile.base
|
191
|
+
- gemfiles/activerecord-5.2/Gemfile.mysql2
|
192
|
+
- gemfiles/activerecord-5.2/Gemfile.postgresql
|
193
|
+
- gemfiles/activerecord-5.2/Gemfile.sqlite3
|
190
194
|
- lib/schema_plus/core.rb
|
191
195
|
- lib/schema_plus/core/active_record/base.rb
|
192
196
|
- lib/schema_plus/core/active_record/connection_adapters/abstract_adapter.rb
|
193
197
|
- lib/schema_plus/core/active_record/connection_adapters/mysql2_adapter.rb
|
198
|
+
- lib/schema_plus/core/active_record/connection_adapters/postgresql/schema_dumper.rb
|
194
199
|
- lib/schema_plus/core/active_record/connection_adapters/postgresql_adapter.rb
|
195
200
|
- lib/schema_plus/core/active_record/connection_adapters/sqlite3_adapter.rb
|
196
201
|
- lib/schema_plus/core/active_record/connection_adapters/table_definition.rb
|