sequel-sequence 0.4.0 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,178 +1,185 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Mysql
4
- def check_sequences
5
- fetch('SELECT * FROM mysql_sequence;').all.to_a
6
- end
7
-
8
- def custom_sequence?(sequence_name)
9
- out = nil
10
- begin
11
- fetch(select_from_mysql_sequence_where(stringify(sequence_name))) do |row|
12
- out = row[:name]
13
- end
14
- rescue Sequel::DatabaseError
15
- return false
16
- end
17
-
18
- !out.nil?
19
- end
20
-
21
- def create_sequence(name, options = {})
22
- check_options(options)
23
- if_exists = build_exists_condition(options[:if_exists])
24
- start_option = options[:start] || 1
25
- num_label = options[:numeric_label] || 0
26
- return if (current = lastval(name)) && (current >= start_option)
27
-
28
- run create_sequence_table(stringify(name), if_exists)
29
- run insert_into_sequence_table_init_values(stringify(name), start_option, num_label)
30
- run create_mysql_sequence
31
- table_matcher { run delete_from_mysql_sequence(stringify(name)) }
32
- run insert_into_mysql_sequence(stringify(name), start_option)
33
- end
34
-
35
- def drop_sequence(name, options = {})
36
- if_exists = build_exists_condition(options[:if_exists])
37
- run drop_sequence_table(stringify(name), if_exists)
38
- table_matcher { run delete_from_mysql_sequence(stringify(name)) }
39
- end
40
-
41
- def nextval(name)
42
- run insert_into_sequence_table(stringify(name), 0)
43
- table_matcher { run delete_from_mysql_sequence(stringify(name)) }
44
- run insert_last_insert_id_into_mysql_sequence(stringify(name))
45
- take_seq(stringify(name))
46
- end
47
-
48
- def nextval_with_label(name, num_label = 0)
49
- run insert_into_sequence_table(stringify(name), num_label)
50
- table_matcher { run delete_from_mysql_sequence(stringify(name)) }
51
- run insert_last_insert_id_into_mysql_sequence(stringify(name))
52
- take_seq(stringify(name))
53
- end
54
-
55
- def lastval(name)
56
- take_seq(stringify(name))
57
- end
58
-
59
- alias currval lastval
60
-
61
- def setval(name, value)
62
- current = lastval(stringify(name))
63
- if current.nil?
64
- create_sequence(stringify(name), { start: value })
65
- elsif value < current
66
- log_info Sequel::Database::DANGER_OPT_ID
67
- value = current
68
- elsif value > current
69
- run insert_into_sequence_table_init_values(stringify(name), value, 0)
70
- table_matcher { run delete_from_mysql_sequence(stringify(name)) }
71
- run insert_into_mysql_sequence(stringify(name), value)
72
- end
73
- value
74
- end
75
-
76
- def set_column_default_nextval(table, column, sequence)
77
- run create_sequenced_column(stringify(table),
78
- stringify(column),
79
- stringify(sequence))
80
- run update_sequenced_column(stringify(table),
81
- stringify(column),
82
- stringify(sequence))
83
- end
84
-
85
- private
86
-
87
- def stringify(name)
88
- @name ||= {}
89
- @name.fetch(name, nil) || (@name[name] = name.to_s)
90
- end
91
-
92
- def select_from_mysql_sequence_where(name)
93
- "SELECT * FROM mysql_sequence where name = '#{name}';"
94
- end
95
-
96
- def create_sequence_table(name, if_exists = nil)
97
- %(
98
- CREATE TABLE #{if_exists || Sequel::Database::IF_NOT_EXISTS} #{name}
99
- (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
100
- fiction INT);
101
- ).strip
102
- end
103
-
104
- def insert_into_sequence_table_init_values(name, start_id, num_label)
105
- "INSERT INTO #{name} (id, fiction) VALUES (#{start_id}, #{num_label});"
106
- end
107
-
108
- def create_mysql_sequence
109
- %(
110
- CREATE TABLE #{Sequel::Database::IF_NOT_EXISTS} mysql_sequence
111
- (name VARCHAR(40), seq INT);
112
- ).strip
113
- end
114
-
115
- def select_max_seq(name)
116
- "SELECT MAX(seq) AS id FROM mysql_sequence WHERE name = '#{name}';"
117
- end
118
-
119
- def take_seq(name)
120
- table_matcher do
121
- out = nil
122
- fetch(select_max_seq(name)) do |row|
123
- out = row[:id]
3
+ module Sequel
4
+ module Sequence
5
+ module Database
6
+ module Server
7
+ module Mysql
8
+ def check_sequences
9
+ fetch('SELECT * FROM mysql_sequence;').all.to_a
10
+ end
11
+
12
+ def custom_sequence?(sequence_name)
13
+ table_matcher do
14
+ out = nil
15
+ fetch(select_from_mysql_sequence_where(stringify(sequence_name))) do |row|
16
+ out = row[:name]
17
+ end
18
+ !out.nil?
19
+ end || false
20
+ end
21
+
22
+ def create_sequence(name, options = {})
23
+ check_options(options)
24
+ if_exists = build_exists_condition(options[:if_exists])
25
+ start_option = options[:start] || 1
26
+ num_label = options[:numeric_label] || 0
27
+ return if (current = lastval(name)) && (current >= start_option)
28
+
29
+ run create_sequence_table(stringify(name), if_exists)
30
+ run insert_into_sequence_table_init_values(stringify(name), start_option, num_label)
31
+ run create_mysql_sequence
32
+ table_matcher { run delete_from_mysql_sequence(stringify(name)) }
33
+ run insert_into_mysql_sequence(stringify(name), start_option)
34
+ end
35
+
36
+ def drop_sequence(name, options = {})
37
+ if_exists = build_exists_condition(options[:if_exists])
38
+ run drop_sequence_table(stringify(name), if_exists)
39
+ table_matcher { run delete_from_mysql_sequence(stringify(name)) }
40
+ end
41
+
42
+ def nextval(name)
43
+ run insert_into_sequence_table(stringify(name), 0)
44
+ table_matcher { run delete_from_mysql_sequence(stringify(name)) }
45
+ run insert_last_insert_id_into_mysql_sequence(stringify(name))
46
+ take_seq(stringify(name))
47
+ end
48
+
49
+ def nextval_with_label(name, num_label = 0)
50
+ run insert_into_sequence_table(stringify(name), num_label)
51
+ table_matcher { run delete_from_mysql_sequence(stringify(name)) }
52
+ run insert_last_insert_id_into_mysql_sequence(stringify(name))
53
+ take_seq(stringify(name))
54
+ end
55
+
56
+ def lastval(name)
57
+ take_seq(stringify(name))
58
+ end
59
+
60
+ alias currval lastval
61
+
62
+ def setval(name, value)
63
+ current = lastval(name)
64
+ if current.nil?
65
+ create_sequence(stringify(name), { start: value })
66
+ elsif value < current
67
+ log_info Sequel::Database::DANGER_OPT_ID
68
+ value = current
69
+ elsif value > current
70
+ run insert_into_sequence_table_init_values(stringify(name), value, 0)
71
+ table_matcher { run delete_from_mysql_sequence(stringify(name)) }
72
+ run insert_into_mysql_sequence(stringify(name), value)
73
+ end
74
+ value
75
+ end
76
+
77
+ def set_column_default_nextval(table, column, sequence)
78
+ run create_sequenced_column(stringify(table),
79
+ stringify(column),
80
+ stringify(sequence))
81
+ run update_sequenced_column(stringify(table),
82
+ stringify(column),
83
+ stringify(sequence))
84
+ end
85
+
86
+ private
87
+
88
+ def stringify(name)
89
+ @name ||= {}
90
+ @name.fetch(name, nil) || (@name[name] = name.to_s)
91
+ end
92
+
93
+ def select_from_mysql_sequence_where(name)
94
+ "SELECT * FROM mysql_sequence where name = '#{name}';"
95
+ end
96
+
97
+ def create_sequence_table(name, if_exists = nil)
98
+ %(
99
+ CREATE TABLE #{if_exists || Sequel::Database::IF_NOT_EXISTS} #{name}
100
+ (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
101
+ fiction INT);
102
+ ).strip
103
+ end
104
+
105
+ def insert_into_sequence_table_init_values(name, start_id, num_label)
106
+ "INSERT INTO #{name} (id, fiction) VALUES (#{start_id}, #{num_label});"
107
+ end
108
+
109
+ def create_mysql_sequence
110
+ %(
111
+ CREATE TABLE #{Sequel::Database::IF_NOT_EXISTS} mysql_sequence
112
+ (name VARCHAR(40), seq INT);
113
+ ).strip
114
+ end
115
+
116
+ def select_max_seq(name)
117
+ "SELECT MAX(seq) AS id FROM mysql_sequence WHERE name = '#{name}';"
118
+ end
119
+
120
+ def take_seq(name)
121
+ table_matcher do
122
+ out = nil
123
+ fetch(select_max_seq(name)) do |row|
124
+ out = row[:id]
125
+ end
126
+ out
127
+ end
128
+ end
129
+
130
+ def delete_from_mysql_sequence(name)
131
+ "DELETE QUICK IGNORE FROM mysql_sequence WHERE name = '#{name}';"
132
+ end
133
+
134
+ def insert_into_mysql_sequence(name, value)
135
+ "INSERT INTO mysql_sequence (name, seq) VALUES ('#{name}', #{value});"
136
+ end
137
+
138
+ def drop_sequence_table(name, if_exists = nil)
139
+ "DROP TABLE #{if_exists || Sequel::Database::IF_EXISTS} #{name};"
140
+ end
141
+
142
+ def insert_into_sequence_table(name, num_label)
143
+ "INSERT INTO #{name} (fiction) VALUES (#{num_label});"
144
+ end
145
+
146
+ def insert_last_insert_id_into_mysql_sequence(name)
147
+ "INSERT INTO mysql_sequence (name, seq) VALUES ('#{name}', LAST_INSERT_ID());"
148
+ end
149
+
150
+ def create_sequenced_column(table, _column, sequence)
151
+ %(
152
+ CREATE TRIGGER IF NOT EXISTS #{table}_#{sequence} BEFORE INSERT
153
+ ON #{table}
154
+ FOR EACH ROW BEGIN
155
+ DELETE QUICK IGNORE FROM mysql_sequence WHERE name = '#{sequence}';
156
+ INSERT INTO #{sequence} SET fiction = 0;
157
+ INSERT INTO mysql_sequence SET name = '#{sequence}', seq = LAST_INSERT_ID();
158
+
159
+ END;
160
+ ).strip
161
+ end
162
+
163
+ def update_sequenced_column(table, column, sequence)
164
+ %(
165
+ CREATE TRIGGER IF NOT EXISTS #{table}_#{column} BEFORE INSERT
166
+ ON #{table}
167
+ FOR EACH ROW FOLLOWS #{table}_#{sequence}
168
+ SET NEW.#{column} = ( SELECT MAX(seq) FROM mysql_sequence WHERE name = '#{sequence}' );
169
+ ).strip
170
+ end
171
+
172
+ def table_matcher(&block)
173
+ block.call
174
+ rescue Sequel::DatabaseError => e
175
+ return if e.message =~ /\AMysql2::Error: Table(.)*doesn't exist\z/
176
+
177
+ # :nocov:
178
+ raise e
179
+ # :nocov:
180
+ end
181
+ end
124
182
  end
125
- out
126
183
  end
127
184
  end
128
-
129
- def delete_from_mysql_sequence(name)
130
- "DELETE QUICK IGNORE FROM mysql_sequence WHERE name = '#{name}';"
131
- end
132
-
133
- def insert_into_mysql_sequence(name, value)
134
- "INSERT INTO mysql_sequence (name, seq) VALUES ('#{name}', #{value});"
135
- end
136
-
137
- def drop_sequence_table(name, if_exists = nil)
138
- "DROP TABLE #{if_exists || Sequel::Database::IF_EXISTS} #{name};"
139
- end
140
-
141
- def insert_into_sequence_table(name, num_label)
142
- "INSERT INTO #{name} (fiction) VALUES (#{num_label});"
143
- end
144
-
145
- def insert_last_insert_id_into_mysql_sequence(name)
146
- "INSERT INTO mysql_sequence (name, seq) VALUES ('#{name}', LAST_INSERT_ID());"
147
- end
148
-
149
- def create_sequenced_column(table, _column, sequence)
150
- %(
151
- CREATE TRIGGER IF NOT EXISTS #{table}_#{sequence} BEFORE INSERT
152
- ON #{table}
153
- FOR EACH ROW BEGIN
154
- DELETE QUICK IGNORE FROM mysql_sequence WHERE name = '#{sequence}';
155
- INSERT INTO #{sequence} SET fiction = 0;
156
- INSERT INTO mysql_sequence SET name = '#{sequence}', seq = LAST_INSERT_ID();
157
-
158
- END;
159
- ).strip
160
- end
161
-
162
- def update_sequenced_column(table, column, sequence)
163
- %(
164
- CREATE TRIGGER IF NOT EXISTS #{table}_#{column} BEFORE INSERT
165
- ON #{table}
166
- FOR EACH ROW FOLLOWS #{table}_#{sequence}
167
- SET NEW.#{column} = ( SELECT MAX(seq) FROM mysql_sequence WHERE name = '#{sequence}' );
168
- ).strip
169
- end
170
-
171
- def table_matcher(&block)
172
- block.call
173
- rescue Sequel::DatabaseError => e
174
- return if e.message =~ /\AMysql2::Error: Table(.)*doesn't exist\z/
175
-
176
- raise e
177
- end
178
185
  end
@@ -6,6 +6,11 @@ module Sequel
6
6
  module Sequence
7
7
  module Database
8
8
  module SQLite
9
+ def custom_sequence?(sequence_name)
10
+ sql = "SELECT * FROM `sqlite_sequence` WHERE name = '#{stringify(sequence_name)}';"
11
+ fetch(sql).all.size.positive?
12
+ end
13
+
9
14
  def check_sequences
10
15
  fetch('SELECT * FROM `sqlite_sequence`;').all.to_a
11
16
  end
@@ -44,18 +49,14 @@ module Sequel
44
49
  alias currval lastval
45
50
 
46
51
  def setval(name, value)
47
- current = lastval(stringify(name))
52
+ current = lastval(name)
48
53
  if current.nil?
49
54
  create_sequence(stringify(name), { start: value })
50
55
  elsif value < current
51
- # sql = [delete_from_sqlite_sequence(name)]
52
- # sql << drop_sequence_table(name)
53
- # sql << insert_into_sqlite_sequence(name, value)
54
- # run(sql.join("\n"))
55
- log_info DANGER_OPT_ID
56
+ log_info Sequel::Database::DANGER_OPT_ID
56
57
  value = current
57
58
  else
58
- run(insert_into_sqlite_sequence(stringify(name), value))
59
+ run(update_sqlite_sequence(stringify(name), value))
59
60
  end
60
61
  value
61
62
  end
@@ -83,7 +84,7 @@ module Sequel
83
84
 
84
85
  def create_sequence_table(name, if_exists = nil)
85
86
  %(
86
- CREATE TABLE #{if_exists || IF_NOT_EXISTS} #{name}
87
+ CREATE TABLE #{if_exists || Sequel::Database::IF_NOT_EXISTS} #{name}
87
88
  (id integer primary key autoincrement, fiction integer);
88
89
  )
89
90
  end
@@ -96,25 +97,16 @@ module Sequel
96
97
  "INSERT INTO #{name} (fiction) VALUES (#{num_label});"
97
98
  end
98
99
 
99
- def insert_into_sqlite_sequence(name, value)
100
- current = take_seq(name)
101
- if current.nil?
102
- "INSERT INTO sqlite_sequence (name, seq) VALUES ('#{name}', #{value});"
103
- else
104
- %(
105
- UPDATE sqlite_sequence
106
- SET seq = #{[current, value].max}
107
- WHERE name = '#{name}';
108
- )
109
- end
110
- end
111
-
112
- def delete_from_sqlite_sequence(name)
113
- "DELETE FROM sqlite_sequence WHERE name = '#{name}';"
100
+ def update_sqlite_sequence(name, value)
101
+ %(
102
+ UPDATE sqlite_sequence
103
+ SET seq = #{value}
104
+ WHERE name = '#{name}';
105
+ )
114
106
  end
115
107
 
116
108
  def drop_sequence_table(name, if_exists = nil)
117
- "DROP TABLE #{if_exists || IF_EXISTS} #{name};"
109
+ "DROP TABLE #{if_exists || Sequel::Database::IF_EXISTS} #{name};"
118
110
  end
119
111
 
120
112
  def select_max_seq(name)
@@ -14,24 +14,24 @@ module Sequel
14
14
  end
15
15
 
16
16
  def custom_sequence?(_sequence_name)
17
- raise Sequel::MethodNotAllowed, Sequel::MethodNotAllowed::METHOD_NOT_ALLOWED
17
+ raise Sequel::MethodNotAllowed, Sequel::Database::METHOD_NOT_ALLOWED
18
18
  end
19
19
 
20
20
  def check_sequences
21
- raise Sequel::MethodNotAllowed, Sequel::MethodNotAllowed::METHOD_NOT_ALLOWED
21
+ raise Sequel::MethodNotAllowed, Sequel::Database::METHOD_NOT_ALLOWED
22
22
  end
23
23
 
24
24
  def create_sequence(_name, _options = {})
25
- raise Sequel::MethodNotAllowed, Sequel::MethodNotAllowed::METHOD_NOT_ALLOWED
25
+ raise Sequel::MethodNotAllowed, Sequel::Database::METHOD_NOT_ALLOWED
26
26
  end
27
27
 
28
28
  def drop_sequence(_name, _options = {})
29
- raise Sequel::MethodNotAllowed, Sequel::MethodNotAllowed::METHOD_NOT_ALLOWED
29
+ raise Sequel::MethodNotAllowed, Sequel::Database::METHOD_NOT_ALLOWED
30
30
  end
31
31
 
32
32
  def quote_name(name)
33
33
  unless respond_to?(:quote_column_name, false)
34
- raise Sequel::MethodNotAllowed, Sequel::MethodNotAllowed::METHOD_NOT_ALLOWED
34
+ raise Sequel::MethodNotAllowed, Sequel::Database::METHOD_NOT_ALLOWED
35
35
  end
36
36
 
37
37
  name.to_s.split('.', 2).map { |part| quote_column_name(part) }.join('.')
@@ -39,30 +39,30 @@ module Sequel
39
39
 
40
40
  def quote(name)
41
41
  unless respond_to?(:quote_sequence_name, false)
42
- raise Sequel::MethodNotAllowed, Sequel::MethodNotAllowed::METHOD_NOT_ALLOWED
42
+ raise Sequel::MethodNotAllowed, Sequel::Database::METHOD_NOT_ALLOWED
43
43
  end
44
44
 
45
45
  name.to_s.split('.', 2).map { |part| quote_sequence_name(part) }.join('.')
46
46
  end
47
47
 
48
48
  def nextval_with_label(_name, _num_label = 0)
49
- raise Sequel::MethodNotAllowed, Sequel::MethodNotAllowed::METHOD_NOT_ALLOWED
49
+ raise Sequel::MethodNotAllowed, Sequel::Database::METHOD_NOT_ALLOWED
50
50
  end
51
51
 
52
52
  def nextval(_name)
53
- raise Sequel::MethodNotAllowed, Sequel::MethodNotAllowed::METHOD_NOT_ALLOWED
53
+ raise Sequel::MethodNotAllowed, Sequel::Database::METHOD_NOT_ALLOWED
54
54
  end
55
55
 
56
56
  # for Postgres
57
57
  def currval(_name)
58
- raise Sequel::MethodNotAllowed, Sequel::MethodNotAllowed::METHOD_NOT_ALLOWED
58
+ raise Sequel::MethodNotAllowed, Sequel::Database::METHOD_NOT_ALLOWED
59
59
  end
60
60
 
61
61
  # for MariaDB
62
62
  alias lastval currval
63
63
 
64
64
  def setval(_name, _value)
65
- raise Sequel::MethodNotAllowed, Sequel::MethodNotAllowed::METHOD_NOT_ALLOWED
65
+ raise Sequel::MethodNotAllowed, Sequel::Database::METHOD_NOT_ALLOWED
66
66
  end
67
67
 
68
68
  def build_exists_condition(option)
@@ -14,9 +14,13 @@ module Sequel
14
14
  define_singleton_method(:connect) do |*args|
15
15
  db = old_connect.call(*args)
16
16
  if db.adapter_scheme == :mysql2
17
- @dbms = db.mariadb? ? Mariadb : Mysql
18
- puts "Sequel::Database.REconnect mariadb? = #{db.mariadb?.inspect}"
19
- puts "Sequel::Database.REconnect server_version = #{db.server_version.inspect}"
17
+ @dbms = if db.mariadb?
18
+ Sequel::Sequence::Database::Server::Mariadb
19
+ else
20
+ Sequel::Sequence::Database::Server::Mysql
21
+ end
22
+ db.log_info "Sequel::Database.connect (mariadb? = #{db.mariadb?.inspect})"
23
+ db.log_info "Sequel::Database.connect (server_version = #{db.server_version.inspect})"
20
24
  Sequel::Mysql2::Database.include(@dbms)
21
25
  end
22
26
  db
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sequel
4
4
  module Sequence
5
- VERSION = '0.4.0'
5
+ VERSION = '0.4.2'
6
6
  end
7
7
  end
@@ -1,29 +1,61 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'sequel/database'
4
- require 'sequel/adapters/postgres'
5
- require 'sequel/adapters/mysql2'
6
- require 'sequel/adapters/sqlite'
7
4
  require 'sequel/error'
8
5
  require 'sequel/sequence/database_ext_connection'
9
6
 
10
7
  module Sequel
11
8
  module Sequence
12
9
  require 'sequel/sequence/database'
13
-
14
- module Database
15
- require 'sequel/sequence/database/postgresql'
16
- require 'sequel/sequence/database/sqlite'
17
- end
18
10
  end
19
11
  end
20
12
 
21
13
  Sequel::Database.include(
22
14
  Sequel::Sequence::Database
23
15
  )
24
- Sequel::Postgres::Database.include(
25
- Sequel::Sequence::Database::PostgreSQL
26
- )
27
- Sequel::SQLite::Database.include(
28
- Sequel::Sequence::Database::SQLite
29
- )
16
+
17
+ begin
18
+ if Gem::Specification.find_by_name('pg')
19
+ require 'sequel/adapters/postgres'
20
+
21
+ module Sequel
22
+ module Sequence
23
+ module Database
24
+ require 'sequel/sequence/database/postgresql'
25
+ end
26
+ end
27
+ end
28
+
29
+ Sequel::Postgres::Database.include(
30
+ Sequel::Sequence::Database::PostgreSQL
31
+ )
32
+ end
33
+ rescue Gem::LoadError
34
+ # do nothing
35
+ end
36
+
37
+ begin
38
+ require 'sequel/adapters/mysql2' if Gem::Specification.find_by_name('mysql2')
39
+ rescue Gem::LoadError
40
+ # do nothing
41
+ end
42
+
43
+ begin
44
+ if Gem::Specification.find_by_name('sqlite3')
45
+ require 'sequel/adapters/sqlite'
46
+
47
+ module Sequel
48
+ module Sequence
49
+ module Database
50
+ require 'sequel/sequence/database/sqlite'
51
+ end
52
+ end
53
+ end
54
+
55
+ Sequel::SQLite::Database.include(
56
+ Sequel::Sequence::Database::SQLite
57
+ )
58
+ end
59
+ rescue Gem::LoadError
60
+ # do nothing
61
+ end
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.summary = \
10
10
  'Adds SEQUENCE support to Sequel for migrations to PostgreSQL, MariaDB, MySQL and SQLite.'
11
11
  spec.description = <<-DES
12
- This gem provides a single interface for SEQUENCE functionality
12
+ This gem provides a single user-friendly interface for SEQUENCE functionality
13
13
  in Postgresql and MariaDB DBMS within the Sequel ORM.
14
14
  It also models the Sequences to meet the needs of SQLite and MySQL users.
15
15
  DES
@@ -27,22 +27,22 @@ Gem::Specification.new do |spec|
27
27
  spec.platform = Gem::Platform::RUBY
28
28
  spec.required_ruby_version = '>= 2.7.0'
29
29
 
30
- spec.add_dependency 'sequel', '>= 5.28', '<5.73'
30
+ spec.add_dependency 'sequel', '>= 5.28', '<6.0'
31
31
  spec.add_development_dependency 'bundler', '>= 2.2.4'
32
32
  spec.add_development_dependency 'minitest-utils', '~> 0.4.6'
33
33
  spec.add_development_dependency 'pry-byebug', '~> 3.10.1'
34
34
  spec.add_development_dependency 'rake', '~> 13.0.2'
35
35
  spec.add_development_dependency 'rubocop', '~> 1.56.3'
36
36
  spec.add_development_dependency 'simplecov', '~> 0.22.0'
37
- if RUBY_ENGINE == 'jruby'
38
- # JRuby Adapter Dependencies
39
- spec.add_development_dependency 'jdbc-mysql', '~> 8.0.17'
40
- spec.add_development_dependency 'jdbc-postgres', '~> 42.2.14'
41
- spec.add_development_dependency 'jdbc-sqlite3', '~> 3.42'
42
- else
43
- # MRI/Rubinius Adapter Dependencies
44
- spec.add_development_dependency 'mysql2', '~> 0.5.3'
45
- spec.add_development_dependency 'pg', '~> 1.5.4'
46
- spec.add_development_dependency 'sqlite3', '~> 1.6.0'
47
- end
37
+ # if RUBY_ENGINE == 'jruby'
38
+ # # JRuby Adapter Dependencies
39
+ # spec.add_development_dependency 'jdbc-mysql', '~> 8.0.17'
40
+ # spec.add_development_dependency 'jdbc-postgres', '~> 42.2.14'
41
+ # spec.add_development_dependency 'jdbc-sqlite3', '~> 3.42'
42
+ # else
43
+ # # MRI/Rubinius Adapter Dependencies
44
+ # spec.add_development_dependency 'mysql2', '~> 0.5.3'
45
+ # spec.add_development_dependency 'pg', '~> 1.5.4'
46
+ # spec.add_development_dependency 'sqlite3', '~> 1.6.0'
47
+ # end
48
48
  end
@@ -13,7 +13,9 @@ MariaDB = Sequel.connect(
13
13
 
14
14
  module MariadbTestHelper
15
15
  def recreate_table
16
+ MariaDB.run 'DROP TABLE IF EXISTS builders'
16
17
  MariaDB.run 'DROP SEQUENCE IF EXISTS position'
18
+ MariaDB.run 'DROP SEQUENCE IF EXISTS position_id'
17
19
  MariaDB.run 'DROP TABLE IF EXISTS wares'
18
20
  MariaDB.run 'DROP SEQUENCE IF EXISTS a'
19
21
  MariaDB.run 'DROP SEQUENCE IF EXISTS b'
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ MockDB = Sequel.connect('mock://postgresql')