schema_plus_core 3.0.0 → 3.1.0.beta.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7652a3a8995b2ceb95a9c67ed8e03dc2f5281414b2495c5dbb715b7ca5946fb
4
- data.tar.gz: 225bc856147f2e0cb1bdf32571d4e36d3cd4fd181a1dd2e7b385d8203383fef4
3
+ metadata.gz: 4586a053807f1a6935ef1198491c6ab3c9ea3a1a11869f18b042ca4b380d20b3
4
+ data.tar.gz: 89c538ce9a32abf2150e5cea263fbbfe8c526e5b225494be653e09a03bbe3525
5
5
  SHA512:
6
- metadata.gz: 369dca1de7a89d21963f3de3ba8b045b7c09c4f80188e63981c2c0b9cc0ed1d82618d372e42070390e75ca778a3b7d107a3d3991d6907ce05a6b0d00022f5508
7
- data.tar.gz: a1be30796efe7e9d767168a686b723f482f525df6ab19108eba7a64df1c07207a4dddde7ba2991d3e583174fd488f06b605d2a95c35cbbad6a442e16de7d5bd6
6
+ metadata.gz: cf582e7744f5d17225ae48033a912cc0b2f27e3c9bea09cf5fe02334dc794b821281bc5c5ae89391a6385c4aca407f1a31d0a54076396b337ac8e3e5c68fd2c2
7
+ data.tar.gz: 2d9cd2b0b7ee4f326cf98366b3f20fb1acf7fd37f40614ac6e66e9c7379493afbcf68757f511e90663b4ccb64cb0acefb6225ec61ad8408407b8c1448bb88aac
@@ -22,9 +22,12 @@ jobs:
22
22
  - '2.5'
23
23
  - '2.7'
24
24
  - '3.0'
25
+ - '3.1'
25
26
  activerecord:
26
27
  - '5.2'
27
28
  - '6.0'
29
+ - '6.1'
30
+ - '7.0'
28
31
  db:
29
32
  - mysql2
30
33
  - sqlite3
@@ -34,6 +37,10 @@ jobs:
34
37
  exclude:
35
38
  - ruby: '3.0'
36
39
  activerecord: '5.2'
40
+ - ruby: '3.1'
41
+ activerecord: '5.2'
42
+ - ruby: '2.5'
43
+ activerecord: '7.0'
37
44
  - db: skip
38
45
  dbversion: skip
39
46
  include:
@@ -45,6 +52,10 @@ jobs:
45
52
  activerecord: '6.0'
46
53
  db: postgresql
47
54
  dbversion: '9.6'
55
+ - ruby: '2.5'
56
+ activerecord: '6.1'
57
+ db: postgresql
58
+ dbversion: '9.6'
48
59
  - ruby: '2.7'
49
60
  activerecord: '5.2'
50
61
  db: postgresql
@@ -53,10 +64,38 @@ jobs:
53
64
  activerecord: '6.0'
54
65
  db: postgresql
55
66
  dbversion: '9.6'
67
+ - ruby: '2.7'
68
+ activerecord: '6.1'
69
+ db: postgresql
70
+ dbversion: '9.6'
71
+ - ruby: '2.7'
72
+ activerecord: '7.0'
73
+ db: postgresql
74
+ dbversion: '9.6'
75
+ - ruby: '3.0'
76
+ activerecord: '6.0'
77
+ db: postgresql
78
+ dbversion: '9.6'
79
+ - ruby: '3.0'
80
+ activerecord: '6.1'
81
+ db: postgresql
82
+ dbversion: '9.6'
56
83
  - ruby: '3.0'
84
+ activerecord: '7.0'
85
+ db: postgresql
86
+ dbversion: '9.6'
87
+ - ruby: '3.1'
57
88
  activerecord: '6.0'
58
89
  db: postgresql
59
90
  dbversion: '9.6'
91
+ - ruby: '3.1'
92
+ activerecord: '6.1'
93
+ db: postgresql
94
+ dbversion: '9.6'
95
+ - ruby: '3.1'
96
+ activerecord: '7.0'
97
+ db: postgresql
98
+ dbversion: '9.6'
60
99
  env:
61
100
  BUNDLE_GEMFILE: "${{ github.workspace }}/gemfiles/activerecord-${{ matrix.activerecord }}/Gemfile.${{ matrix.db }}"
62
101
  POSTGRESQL_DB_HOST: 127.0.0.1
data/Gemfile CHANGED
@@ -4,4 +4,5 @@ source "http://rubygems.org"
4
4
 
5
5
  gemspec
6
6
 
7
- File.exist?(gemfile_local = File.expand_path('../Gemfile.local', __FILE__)) and eval File.read(gemfile_local), binding, gemfile_local
7
+ gemfile_local = File.expand_path '../Gemfile.local', __FILE__
8
+ eval File.read(gemfile_local), binding, gemfile_local if File.exist? gemfile_local
data/README.md CHANGED
@@ -25,9 +25,17 @@ SchemaPlus::Core is tested on:
25
25
  <!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
26
26
  * ruby **2.5** with activerecord **5.2**, using **postgresql:9.6**, **mysql2** or **sqlite3**
27
27
  * ruby **2.5** with activerecord **6.0**, using **postgresql:9.6**, **mysql2** or **sqlite3**
28
+ * ruby **2.5** with activerecord **6.1**, using **postgresql:9.6**, **mysql2** or **sqlite3**
28
29
  * ruby **2.7** with activerecord **5.2**, using **postgresql:9.6**, **mysql2** or **sqlite3**
29
30
  * ruby **2.7** with activerecord **6.0**, using **postgresql:9.6**, **mysql2** or **sqlite3**
31
+ * ruby **2.7** with activerecord **6.1**, using **postgresql:9.6**, **mysql2** or **sqlite3**
32
+ * ruby **2.7** with activerecord **7.0**, using **postgresql:9.6**, **mysql2** or **sqlite3**
30
33
  * ruby **3.0** with activerecord **6.0**, using **postgresql:9.6**, **mysql2** or **sqlite3**
34
+ * ruby **3.0** with activerecord **6.1**, using **postgresql:9.6**, **mysql2** or **sqlite3**
35
+ * ruby **3.0** with activerecord **7.0**, using **postgresql:9.6**, **mysql2** or **sqlite3**
36
+ * ruby **3.1** with activerecord **6.0**, using **postgresql:9.6**, **mysql2** or **sqlite3**
37
+ * ruby **3.1** with activerecord **6.1**, using **postgresql:9.6**, **mysql2** or **sqlite3**
38
+ * ruby **3.1** with activerecord **7.0**, using **postgresql:9.6**, **mysql2** or **sqlite3**
31
39
 
32
40
  <!-- SCHEMA_DEV: MATRIX - end -->
33
41
 
@@ -0,0 +1,4 @@
1
+ base_gemfile = File.expand_path('../../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile)
3
+
4
+ gem "activerecord", ">= 6.1", "< 6.2"
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "mysql2"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcmysql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
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
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
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
@@ -0,0 +1,4 @@
1
+ base_gemfile = File.expand_path('../../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile)
3
+
4
+ gem "activerecord", ">= 7.0", "< 7.1"
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "mysql2"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcmysql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
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
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
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
@@ -5,7 +5,6 @@ module SchemaPlus
5
5
  module ActiveRecord
6
6
  module ConnectionAdapters
7
7
  module AbstractAdapter
8
-
9
8
  def add_column(table_name, name, type, **options)
10
9
  options = options.deep_dup
11
10
  SchemaMonkey::Middleware::Migration::Column.start(caller: self, operation: :add, table_name: table_name, column_name: name, type: type, implements_reference: options.delete(:_implements_reference), options: options) do |env|
@@ -36,27 +35,65 @@ module SchemaPlus
36
35
  super env.table_name, **env.options
37
36
  end
38
37
  end
38
+ end
39
+ end
39
40
 
40
- # replaced version to handle array of columns with expressions
41
- def quoted_columns_for_index(column_names, **options)
42
- output_columns = []
41
+ if Gem::Version.new(::ActiveRecord::VERSION::STRING) < Gem::Version.new('6.1')
42
+ module ConnectionAdapters
43
+ module AbstractAdapter
44
+ # replaced version to handle array of columns with expressions
45
+ def quoted_columns_for_index(column_names, **options)
46
+ output_columns = []
43
47
 
44
- column_names.each do |column|
45
- if column.is_a?(String) && column.include?('(')
46
- output_columns << column
47
- else
48
- quoted = {column.to_sym => quote_column_name(column).dup}
49
- output_columns.concat add_options_for_index_columns(quoted, **options).values
48
+ column_names.each do |column|
49
+ if column.is_a?(String) && column.include?('(')
50
+ output_columns << column
51
+ else
52
+ quoted = {column.to_sym => quote_column_name(column).dup}
53
+ output_columns.concat add_options_for_index_columns(quoted, **options).values
54
+ end
50
55
  end
56
+
57
+ output_columns
51
58
  end
52
59
 
53
- output_columns
54
- end
55
- private :quoted_columns_for_index
60
+ private :quoted_columns_for_index
56
61
 
62
+ module SchemaCreation
57
63
 
58
- module SchemaCreation
64
+ def add_column_options!(sql, options)
65
+ sql << +" " + SchemaMonkey::Middleware::Sql::ColumnOptions.start(caller: self, connection: self.instance_variable_get('@conn'), sql: +"", column: options[:column], options: options.except(:column)) { |env|
66
+ super env.sql, env.options.merge(column: env.column)
67
+ }.sql.lstrip
68
+ end
59
69
 
70
+ def visit_TableDefinition(o)
71
+ SchemaMonkey::Middleware::Sql::Table.start(caller: self, connection: self.instance_variable_get('@conn'), table_definition: o, sql: SqlStruct::Table.new) { |env|
72
+ env.sql.parse! super env.table_definition
73
+ }.sql.assemble
74
+ end
75
+ end
76
+ end
77
+ end
78
+ else
79
+ # In AR 6.1+ quoted_columns_for_index has slightly different paramater style and a different return type
80
+ # Also SchemaCreation is no longer nested beneath AbstractAdapter
81
+ module ConnectionAdapters
82
+ module AbstractAdapter
83
+ # replaced version to handle array of columns with expressions
84
+ def quoted_columns_for_index(column_names, options)
85
+ column_names.each_with_object([]) do |column, output_columns|
86
+ if column.is_a?(String) && column.include?('(')
87
+ output_columns << column
88
+ else
89
+ quoted = {column.to_sym => quote_column_name(column).dup}
90
+ output_columns.concat add_options_for_index_columns(quoted, **options).values
91
+ end
92
+ end.join(', ')
93
+ end
94
+ end
95
+
96
+ module SchemaCreation
60
97
  def add_column_options!(sql, options)
61
98
  sql << +" " + SchemaMonkey::Middleware::Sql::ColumnOptions.start(caller: self, connection: self.instance_variable_get('@conn'), sql: +"", column: options[:column], options: options.except(:column)) { |env|
62
99
  super env.sql, env.options.merge(column: env.column)
@@ -12,9 +12,17 @@ module SchemaPlus
12
12
  end
13
13
  end
14
14
 
15
- def add_index(table_name, column_names, options = {})
16
- SchemaMonkey::Middleware::Migration::Index.start(caller: self, operation: :add, table_name: table_name, column_names: column_names, options: options.deep_dup) do |env|
17
- super env.table_name, env.column_names, **env.options
15
+ if Gem::Version.new(::ActiveRecord::VERSION::STRING) < Gem::Version.new('6.1')
16
+ def add_index(table_name, column_names, options = {})
17
+ SchemaMonkey::Middleware::Migration::Index.start(caller: self, operation: :add, table_name: table_name, column_names: column_names, options: options.deep_dup) do |env|
18
+ super env.table_name, env.column_names, env.options
19
+ end
20
+ end
21
+ else
22
+ def add_index(table_name, column_names, **options)
23
+ SchemaMonkey::Middleware::Migration::Index.start(caller: self, operation: :add, table_name: table_name, column_names: column_names, options: options.deep_dup) do |env|
24
+ super env.table_name, env.column_names, **env.options
25
+ end
18
26
  end
19
27
  end
20
28
 
@@ -26,11 +26,15 @@ module SchemaPlus
26
26
  end
27
27
 
28
28
  def extensions(_)
29
- SchemaMonkey::Middleware::Dumper::Initial.start(dumper: self, connection: @connection, dump: @dump, initial: @dump.initial) do |env|
30
- stream = StringIO.new
31
- super stream
32
- env.dump.initial << stream.string unless stream.string.blank?
33
- end
29
+ stream = StringIO.new
30
+ super stream
31
+ @dump.extensions << stream.string unless stream.string.blank?
32
+ end
33
+
34
+ def types(_)
35
+ stream = StringIO.new
36
+ super stream
37
+ @dump.types << stream.string unless stream.string.blank?
34
38
  end
35
39
  end
36
40
  end
@@ -12,9 +12,17 @@ module SchemaPlus
12
12
  end
13
13
  end
14
14
 
15
- def add_index(table_name, column_names, options = {})
16
- SchemaMonkey::Middleware::Migration::Index.start(caller: self, operation: :add, table_name: table_name, column_names: column_names, options: options.deep_dup) do |env|
17
- super env.table_name, env.column_names, **env.options
15
+ if Gem::Version.new(::ActiveRecord::VERSION::STRING) < Gem::Version.new('6.1')
16
+ def add_index(table_name, column_names, options = {})
17
+ SchemaMonkey::Middleware::Migration::Index.start(caller: self, operation: :add, table_name: table_name, column_names: column_names, options: options.deep_dup) do |env|
18
+ super env.table_name, env.column_names, env.options
19
+ end
20
+ end
21
+ else
22
+ def add_index(table_name, column_names, **options)
23
+ SchemaMonkey::Middleware::Migration::Index.start(caller: self, operation: :add, table_name: table_name, column_names: column_names, options: options.deep_dup) do |env|
24
+ super env.table_name, env.column_names, **env.options
25
+ end
18
26
  end
19
27
  end
20
28
 
@@ -30,15 +38,15 @@ module SchemaPlus
30
38
  end
31
39
  end
32
40
 
33
- def exec_cache(sql, name, binds)
34
- SchemaMonkey::Middleware::Query::Exec.start(connection: self, sql: sql, query_name: name, binds: binds) { |env|
35
- env.result = super env.sql, env.query_name, env.binds
41
+ def exec_cache(sql, name, binds, **options)
42
+ SchemaMonkey::Middleware::Query::Exec.start(connection: self, sql: sql, query_name: name, binds: binds, options: options) { |env|
43
+ env.result = super env.sql, env.query_name, env.binds, **env.options
36
44
  }.result
37
45
  end
38
46
 
39
- def exec_no_cache(sql, name, binds)
40
- SchemaMonkey::Middleware::Query::Exec.start(connection: self, sql: sql, query_name: name, binds: binds) { |env|
41
- env.result = super env.sql, env.query_name, env.binds
47
+ def exec_no_cache(sql, name, binds, **options)
48
+ SchemaMonkey::Middleware::Query::Exec.start(connection: self, sql: sql, query_name: name, binds: binds, options: options) { |env|
49
+ env.result = super env.sql, env.query_name, env.binds, **env.options
42
50
  }.result
43
51
  end
44
52
 
@@ -18,9 +18,17 @@ module SchemaPlus
18
18
  end
19
19
  end
20
20
 
21
- def add_index(table_name, column_names, options = {})
22
- SchemaMonkey::Middleware::Migration::Index.start(caller: self, operation: :add, table_name: table_name, column_names: column_names, options: options.deep_dup) do |env|
23
- super env.table_name, env.column_names, **env.options
21
+ if Gem::Version.new(::ActiveRecord::VERSION::STRING) < Gem::Version.new('6.1')
22
+ def add_index(table_name, column_names, options = {})
23
+ SchemaMonkey::Middleware::Migration::Index.start(caller: self, operation: :add, table_name: table_name, column_names: column_names, options: options.deep_dup) do |env|
24
+ super env.table_name, env.column_names, env.options
25
+ end
26
+ end
27
+ else
28
+ def add_index(table_name, column_names, **options)
29
+ SchemaMonkey::Middleware::Migration::Index.start(caller: self, operation: :add, table_name: table_name, column_names: column_names, options: options.deep_dup) do |env|
30
+ super env.table_name, env.column_names, **env.options
31
+ end
24
32
  end
25
33
  end
26
34
 
@@ -27,9 +27,17 @@ module SchemaPlus
27
27
  end
28
28
  end
29
29
 
30
- def index(column_name, options = {})
31
- SchemaMonkey::Middleware::Migration::Index.start(caller: self, operation: :define, table_name: self.name, column_names: column_name, options: options.deep_dup) do |env|
32
- super env.column_names, env.options
30
+ if Gem::Version.new(::ActiveRecord::VERSION::STRING) < Gem::Version.new('6.1')
31
+ def index(column_name, options = {})
32
+ SchemaMonkey::Middleware::Migration::Index.start(caller: self, operation: :define, table_name: self.name, column_names: column_name, options: options.deep_dup) do |env|
33
+ super env.column_names, env.options
34
+ end
35
+ end
36
+ else
37
+ def index(column_name, **options)
38
+ SchemaMonkey::Middleware::Migration::Index.start(caller: self, operation: :define, table_name: self.name, column_names: column_name, options: options.deep_dup) do |env|
39
+ super env.column_names, **env.options
40
+ end
33
41
  end
34
42
  end
35
43
  end
@@ -32,14 +32,26 @@ module SchemaPlus
32
32
  @dump.trailer = stream.string
33
33
  end
34
34
 
35
- def extensions(_)
35
+ def header(_)
36
36
  SchemaMonkey::Middleware::Dumper::Initial.start(dumper: self, connection: @connection, dump: @dump, initial: @dump.initial) do |env|
37
37
  stream = StringIO.new
38
38
  super stream
39
- env.dump.initial << stream.string unless stream.string.blank?
39
+ env.dump.header = stream.string
40
40
  end
41
41
  end
42
42
 
43
+ def extensions(_)
44
+ stream = StringIO.new
45
+ super stream
46
+ @dump.extensions << stream.string unless stream.string.blank?
47
+ end
48
+
49
+ def types(_)
50
+ stream = StringIO.new
51
+ super stream
52
+ @dump.types << stream.string unless stream.string.blank?
53
+ end
54
+
43
55
  def tables(_)
44
56
  SchemaMonkey::Middleware::Dumper::Tables.start(dumper: self, connection: @connection, dump: @dump) do |env|
45
57
  super nil
@@ -5,7 +5,7 @@ module SchemaPlus
5
5
  module Middleware
6
6
  module Query
7
7
  module Exec
8
- ENV = [:connection, :sql, :query_name, :binds, :prepare, :result]
8
+ ENV = [:connection, :sql, :query_name, :binds, :options, :prepare, :result]
9
9
  end
10
10
  end
11
11
 
@@ -5,13 +5,16 @@ module SchemaPlus
5
5
  class SchemaDump
6
6
  include TSort
7
7
 
8
- attr_reader :initial, :tables, :dependencies, :data
9
- attr_accessor :final, :trailer
8
+ attr_reader :initial, :extensions, :types, :tables, :dependencies, :data
9
+ attr_accessor :header, :final, :trailer
10
10
 
11
11
  def initialize(dumper)
12
12
  @dumper = dumper
13
13
  @dependencies = Hash.new { |h, k| h[k] = [] }
14
+ @header = ''
14
15
  @initial = []
16
+ @extensions = []
17
+ @types = []
15
18
  @tables = {}
16
19
  @final = []
17
20
  @data = OpenStruct.new # a place for middleware to leave data
@@ -23,7 +26,10 @@ module SchemaPlus
23
26
  end
24
27
 
25
28
  def assemble(stream)
29
+ stream.puts @header
26
30
  stream.puts @initial.join("\n") if initial.any?
31
+ stream.puts @extensions.join("\n") if extensions.any?
32
+ stream.puts @types.join("\n") if types.any?
27
33
  assemble_tables(stream)
28
34
  final.each do |statement|
29
35
  stream.puts " #{statement}"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SchemaPlus
4
4
  module Core
5
- VERSION = "3.0.0"
5
+ VERSION = "3.1.0.beta.3"
6
6
  end
7
7
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "schema_monkey"
4
+ require 'active_support/core_ext/array/wrap'
4
5
  require "pathname"
5
6
 
6
7
  module SchemaPlus
data/schema_dev.yml CHANGED
@@ -2,9 +2,12 @@ ruby:
2
2
  - 2.5
3
3
  - 2.7
4
4
  - 3.0
5
+ - 3.1
5
6
  activerecord:
6
7
  - 5.2
7
8
  - 6.0
9
+ - 6.1
10
+ - 7.0
8
11
  db:
9
12
  - postgresql
10
13
  - mysql2
@@ -21,12 +21,12 @@ Gem::Specification.new do |gem|
21
21
 
22
22
  gem.required_ruby_version = ">= 2.5.0"
23
23
 
24
- gem.add_dependency "activerecord", ">= 5.2", "< 6.1"
25
- gem.add_dependency "schema_monkey", "~> 3.0.1"
24
+ gem.add_dependency "activerecord", ">= 5.2", "< 7.1"
25
+ gem.add_dependency "schema_monkey", "~> 3.0.2.beta.1"
26
26
 
27
27
  gem.add_development_dependency "bundler"
28
28
  gem.add_development_dependency "rake", "~> 13.0.0"
29
29
  gem.add_development_dependency "rspec", "~> 3.0"
30
30
  gem.add_development_dependency "rspec-given"
31
- gem.add_development_dependency "schema_dev", "~> 4.1"
31
+ gem.add_development_dependency "schema_dev", "~> 4.2.beta.1"
32
32
  end
data/spec/dumper_spec.rb CHANGED
@@ -46,16 +46,14 @@ describe SchemaMonkey::Middleware::Dumper do
46
46
 
47
47
  let(:migration) { ::ActiveRecord::Migration }
48
48
 
49
- TestCustomType = SchemaDev::Rspec::Helpers.postgresql?
50
-
51
- around(:each) do |example|
49
+ around(postgresql: :only) do |example|
52
50
  begin
53
- migration.execute "CREATE TYPE custom_type AS ENUM ('a', 'b')";
51
+ migration.execute "CREATE TYPE custom_type AS ENUM ('a', 'b')"
54
52
  example.run
55
53
  ensure
56
54
  migration.execute "DROP TYPE IF EXISTS custom_type CASCADE";
57
55
  end
58
- end if TestCustomType
56
+ end
59
57
 
60
58
  before(:each) do
61
59
  migration.create_table "things" do |t|
@@ -66,7 +64,10 @@ describe SchemaMonkey::Middleware::Dumper do
66
64
  t.references :thing
67
65
  end
68
66
  migration.add_foreign_key("other", "things")
69
- migration.execute "CREATE TABLE custom_table ( my_column custom_type DEFAULT 'a'::custom_type NOT NULL)" if TestCustomType
67
+ end
68
+
69
+ before(postgresql: :only) do
70
+ migration.execute "CREATE TABLE custom_table ( my_column custom_type DEFAULT 'a'::custom_type NOT NULL)"
70
71
  end
71
72
 
72
73
  context "column default expressions", postgresql: :only do
@@ -79,7 +80,7 @@ describe SchemaMonkey::Middleware::Dumper do
79
80
  end
80
81
 
81
82
  context TestDumper::Middleware::Dumper::Initial do
82
- Then { expect(dump).to match(/Schema[.]define.*do\s+#{middleware}/) }
83
+ Then { expect(dump).to match(/Schema([\[\].0-9]+)?[.]define.*do\s+#{middleware}/) }
83
84
  end
84
85
 
85
86
  context TestDumper::Middleware::Dumper::Tables do
@@ -112,7 +113,14 @@ describe SchemaMonkey::Middleware::Dumper do
112
113
  context TestDumper::Middleware::Dumper::Table do
113
114
  Then { expect(dump).to match(/t[.]integer.*:option=>"#{middleware}" \# comment: #{middleware}/) }
114
115
  Then { expect(dump).to match(/statement: #{middleware}\s+end\s+(add_index.*)?\s+trailer: #{middleware}/) }
115
- Then { expect(dump).to match(/could not dump table.*custom_table.*unknown type.*custom_type/mi) } if TestCustomType
116
+
117
+ Then(postgresql: :only, rails: '< 7.0') {
118
+ expect(dump).to match(/could not dump table.*custom_table.*unknown type.*custom_type/mi)
119
+ }
120
+ Then(postgresql: :only, rails: '>= 7.0') {
121
+ expect(dump).to match(/create_enum.+custom_type/mi)
122
+ }
123
+
116
124
  Then { expect(dump).to match(/t[.]index.*:option=>"#{middleware}"/) }
117
125
  end
118
126
 
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'simplecov'
4
- SimpleCov.start
4
+ SimpleCov.start unless SimpleCov.running
5
5
 
6
6
  $LOAD_PATH.unshift(File.dirname(__FILE__))
7
7
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
@@ -39,4 +39,3 @@ RSpec.configure do |config|
39
39
  end
40
40
 
41
41
  SimpleCov.command_name "[ruby #{RUBY_VERSION} - ActiveRecord #{::ActiveRecord::VERSION::STRING} - #{ActiveRecord::Base.connection.adapter_name}]"
42
-
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: 3.0.0
4
+ version: 3.1.0.beta.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: 2022-04-22 00:00:00.000000000 Z
11
+ date: 2022-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '5.2'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6.1'
22
+ version: '7.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,21 +29,21 @@ dependencies:
29
29
  version: '5.2'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6.1'
32
+ version: '7.1'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: schema_monkey
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 3.0.1
39
+ version: 3.0.2.beta.1
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 3.0.1
46
+ version: 3.0.2.beta.1
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -106,14 +106,14 @@ dependencies:
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: '4.1'
109
+ version: 4.2.beta.1
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
- version: '4.1'
116
+ version: 4.2.beta.1
117
117
  description: Provides an internal extension API to ActiveRecord, in the form of middleware-style
118
118
  callback stacks
119
119
  email:
@@ -138,6 +138,14 @@ files:
138
138
  - gemfiles/activerecord-6.0/Gemfile.mysql2
139
139
  - gemfiles/activerecord-6.0/Gemfile.postgresql
140
140
  - gemfiles/activerecord-6.0/Gemfile.sqlite3
141
+ - gemfiles/activerecord-6.1/Gemfile.base
142
+ - gemfiles/activerecord-6.1/Gemfile.mysql2
143
+ - gemfiles/activerecord-6.1/Gemfile.postgresql
144
+ - gemfiles/activerecord-6.1/Gemfile.sqlite3
145
+ - gemfiles/activerecord-7.0/Gemfile.base
146
+ - gemfiles/activerecord-7.0/Gemfile.mysql2
147
+ - gemfiles/activerecord-7.0/Gemfile.postgresql
148
+ - gemfiles/activerecord-7.0/Gemfile.sqlite3
141
149
  - lib/schema_plus/core.rb
142
150
  - lib/schema_plus/core/active_record/base.rb
143
151
  - lib/schema_plus/core/active_record/connection_adapters/abstract_adapter.rb
@@ -178,11 +186,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
178
186
  version: 2.5.0
179
187
  required_rubygems_version: !ruby/object:Gem::Requirement
180
188
  requirements:
181
- - - ">="
189
+ - - ">"
182
190
  - !ruby/object:Gem::Version
183
- version: '0'
191
+ version: 1.3.1
184
192
  requirements: []
185
- rubygems_version: 3.0.8
193
+ rubygems_version: 3.1.6
186
194
  signing_key:
187
195
  specification_version: 4
188
196
  summary: Provides an internal extension API to ActiveRecord