Skip to content

Commit 3d70cc8

Browse files
fidelpjurewicz
andcommitted
Internally it's just MySQL
We don't need to reflect specific adapter naming. Default driver for MySQL in rails 7.1 will be Trilogy. It's a detail not in our scope of interest. We only need to be sure which data types are allowed for given database. Co-authored-by: Piotr Jurewicz <[email protected]>
1 parent dc4f416 commit 3d70cc8

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

ruby_event_store-active_record/lib/ruby_event_store/active_record/generators/database_adapter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def initialize(data_type = NOT_SET)
1616
end
1717
end
1818

19-
class MySQL2 < self
19+
class MySQL < self
2020
SUPPORTED_DATA_TYPES = %w[binary json].freeze
2121

2222
def initialize(data_type = NOT_SET)
@@ -64,7 +64,7 @@ def self.from_string(adapter_name, data_type = NOT_SET)
6464
when "postgresql", "postgis"
6565
PostgreSQL.new(data_type)
6666
when "mysql2"
67-
MySQL2.new(data_type)
67+
MySQL.new(data_type)
6868
when "sqlite"
6969
SQLite.new(data_type)
7070
else

ruby_event_store-active_record/lib/ruby_event_store/active_record/generators/templates/template_directory.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def self.for_adapter(database_adapter)
77
case database_adapter
88
when DatabaseAdapter::PostgreSQL
99
"postgres/"
10-
when DatabaseAdapter::MySQL2
10+
when DatabaseAdapter::MySQL
1111
"mysql/"
1212
end
1313
end

ruby_event_store-active_record/spec/database_adapter_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ module ActiveRecord
88
specify "from_string" do
99
expect(DatabaseAdapter.from_string("PostgreSQL")).to eql(DatabaseAdapter::PostgreSQL.new)
1010
expect(DatabaseAdapter.from_string("PostGIS")).to eql(DatabaseAdapter::PostgreSQL.new)
11-
expect(DatabaseAdapter.from_string("MySQL2")).to eql(DatabaseAdapter::MySQL2.new)
11+
expect(DatabaseAdapter.from_string("MySQL2")).to eql(DatabaseAdapter::MySQL.new)
1212
expect(DatabaseAdapter.from_string("SQLite")).to eql(DatabaseAdapter::SQLite.new)
1313
end
1414

1515
specify "equality" do
16-
expect(DatabaseAdapter::PostgreSQL.new).not_to eql(DatabaseAdapter::MySQL2.new)
16+
expect(DatabaseAdapter::PostgreSQL.new).not_to eql(DatabaseAdapter::MySQL.new)
1717
expect(DatabaseAdapter::PostgreSQL.new).not_to eql("postgresql")
1818
end
1919

2020
specify "adapter_name" do
2121
expect(DatabaseAdapter::PostgreSQL.new.adapter_name).to eql("postgresql")
22-
expect(DatabaseAdapter::MySQL2.new.adapter_name).to eql("mysql2")
22+
expect(DatabaseAdapter::MySQL.new.adapter_name).to eql("mysql2")
2323
expect(DatabaseAdapter::SQLite.new.adapter_name).to eql("sqlite")
2424
end
2525

@@ -40,13 +40,13 @@ module ActiveRecord
4040

4141
specify "hash" do
4242
expect(DatabaseAdapter::PostgreSQL.new.hash).to eql(DatabaseAdapter.hash ^ "postgresql".hash)
43-
expect(DatabaseAdapter::MySQL2.new.hash).to eql(DatabaseAdapter.hash ^ "mysql2".hash)
43+
expect(DatabaseAdapter::MySQL.new.hash).to eql(DatabaseAdapter.hash ^ "mysql2".hash)
4444
expect(DatabaseAdapter::SQLite.new.hash).to eql(DatabaseAdapter.hash ^ "sqlite".hash)
4545
end
4646

4747
specify "child classes don't implement #from_string" do
4848
expect { DatabaseAdapter::PostgreSQL.from_string("postgresql") }.to raise_error(NoMethodError)
49-
expect { DatabaseAdapter::MySQL2.from_string("mysql2") }.to raise_error(NoMethodError)
49+
expect { DatabaseAdapter::MySQL.from_string("mysql2") }.to raise_error(NoMethodError)
5050
expect { DatabaseAdapter::SQLite.from_string("sqlite") }.to raise_error(NoMethodError)
5151
end
5252

@@ -56,16 +56,16 @@ module ActiveRecord
5656

5757
context "data type verification" do
5858
specify "MySQL supports binary" do
59-
expect(DatabaseAdapter::MySQL2.new("binary").data_type).to eq("binary")
59+
expect(DatabaseAdapter::MySQL.new("binary").data_type).to eq("binary")
6060
end
6161

6262
specify "MySQL supports json" do
63-
expect(DatabaseAdapter::MySQL2.new("json").data_type).to eq("json")
63+
expect(DatabaseAdapter::MySQL.new("json").data_type).to eq("json")
6464
end
6565

6666
specify "MySQL doesn't support jsonb" do
67-
expect { DatabaseAdapter::MySQL2.new("jsonb") }.to raise_error InvalidDataTypeForAdapter,
68-
"MySQL2 doesn't support \"jsonb\". Supported types are: binary, json."
67+
expect { DatabaseAdapter::MySQL.new("jsonb") }.to raise_error InvalidDataTypeForAdapter,
68+
"MySQL doesn't support \"jsonb\". Supported types are: binary, json."
6969
end
7070

7171
specify "PostgreSQL supports binary" do

ruby_event_store-active_record/spec/migration_generator_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ module ActiveRecord
7373
)
7474
end
7575

76-
specify "throws on attempt to create migration with jsonb data type for MySQL2 adapter" do
76+
specify "throws on attempt to create migration with jsonb data type for MySQL adapter" do
7777
expect { migration_generator(@dir, "jsonb", "MySQL2") }.to raise_error(
7878
InvalidDataTypeForAdapter,
79-
"MySQL2 doesn't support \"jsonb\". Supported types are: binary, json."
79+
"MySQL doesn't support \"jsonb\". Supported types are: binary, json."
8080
)
8181
end
8282

83-
specify "creates migration with binary data type for MySQL2 adapter" do
83+
specify "creates migration with binary data type for MySQL adapter" do
8484
migration_generator(@dir, "binary", "MySQL2")
8585

8686
expect(read_migration(@dir)).to match(/t.binary\s+:data/)

0 commit comments

Comments
 (0)