declare_schema 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/lib/declare_schema/version.rb +1 -1
- data/lib/declare_schema.rb +13 -3
- data/spec/lib/declare_schema_spec.rb +40 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d11ade44eb67c0d2afaae73dc540ee10ed09ff62494fff9feb32dcea9bfefaa
|
4
|
+
data.tar.gz: 83ce51a81e9b2b11944e199972b41c4a3662323bb0ccdf5ddef08b8dec9b3480
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43802ec088ddbd240c7ad04617cdd76753dc216d2cbac693bd6b6029f0809fc525545197c2ccb768a2b1e50c3d75c76ab612a9b16f1db63b0dc9b62f477325a8
|
7
|
+
data.tar.gz: dd323d88fbdbf493698710ebea366e8539f4b38e7a59a31c693553082a231264e99b7dde864f833fd8c92fd01ca6c5567958532a4833d0622d235ed20594f262
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,11 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
5
5
|
Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [1.3.5] - 2024-01-22
|
8
|
+
### Fixed
|
9
|
+
- Make `default_charset=` and `default_collation=` lazy so they don't use the database connection to check the
|
10
|
+
MySQL version. Instead, that is checked the first time `default_charset` or `default_collation` is called.
|
11
|
+
|
7
12
|
## [1.3.4] - 2024-01-18
|
8
13
|
### Fixed
|
9
14
|
- Add test for migrating `has_and_belongs_to_many` associations and fix them to properly declare their
|
data/Gemfile.lock
CHANGED
data/lib/declare_schema.rb
CHANGED
@@ -36,7 +36,7 @@ module DeclareSchema
|
|
36
36
|
|
37
37
|
class << self
|
38
38
|
attr_writer :mysql_version
|
39
|
-
attr_reader :
|
39
|
+
attr_reader :default_text_limit, :default_string_limit, :default_null,
|
40
40
|
:default_generate_foreign_keys, :default_generate_indexing, :db_migrate_command,
|
41
41
|
:max_index_and_constraint_name_length
|
42
42
|
|
@@ -81,12 +81,22 @@ module DeclareSchema
|
|
81
81
|
|
82
82
|
def default_charset=(charset)
|
83
83
|
charset.is_a?(String) or raise ArgumentError, "charset must be a string (got #{charset.inspect})"
|
84
|
-
@
|
84
|
+
@default_charset_before_normalization = charset
|
85
|
+
@default_charset = nil
|
86
|
+
end
|
87
|
+
|
88
|
+
def default_charset
|
89
|
+
@default_charset ||= normalize_charset(@default_charset_before_normalization)
|
85
90
|
end
|
86
91
|
|
87
92
|
def default_collation=(collation)
|
88
93
|
collation.is_a?(String) or raise ArgumentError, "collation must be a string (got #{collation.inspect})"
|
89
|
-
@
|
94
|
+
@default_collation_before_normalization = collation
|
95
|
+
@default_collation = nil
|
96
|
+
end
|
97
|
+
|
98
|
+
def default_collation
|
99
|
+
@default_collation ||= normalize_collation(@default_collation_before_normalization)
|
90
100
|
end
|
91
101
|
|
92
102
|
def default_text_limit=(text_limit)
|
@@ -37,6 +37,26 @@ RSpec.describe DeclareSchema do
|
|
37
37
|
it { is_expected.to eq("utf8mb3") }
|
38
38
|
end
|
39
39
|
end
|
40
|
+
|
41
|
+
context 'when MySQL version not known yet' do
|
42
|
+
before { described_class.remove_instance_variable('@mysql_version') rescue nil }
|
43
|
+
after { described_class.remove_instance_variable('@mysql_version') rescue nil }
|
44
|
+
|
45
|
+
context 'when set' do
|
46
|
+
let(:connection) { double("connection", select_value: "8.0.21") }
|
47
|
+
|
48
|
+
it "is lazy, so it doesn't use the database connection until read" do
|
49
|
+
expect(ActiveRecord::Base).to receive(:connection) do
|
50
|
+
@connection_called = true
|
51
|
+
connection
|
52
|
+
end
|
53
|
+
described_class.default_charset = "utf8"
|
54
|
+
expect(@connection_called).to be_falsey
|
55
|
+
described_class.default_charset
|
56
|
+
expect(@connection_called).to be_truthy
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
40
60
|
end
|
41
61
|
|
42
62
|
describe '#default_collation' do
|
@@ -81,6 +101,26 @@ RSpec.describe DeclareSchema do
|
|
81
101
|
it { is_expected.to eq("utf8mb3_general_ci") }
|
82
102
|
end
|
83
103
|
end
|
104
|
+
|
105
|
+
context 'when MySQL version not known yet' do
|
106
|
+
before { described_class.remove_instance_variable('@mysql_version') rescue nil }
|
107
|
+
after { described_class.remove_instance_variable('@mysql_version') rescue nil }
|
108
|
+
|
109
|
+
context 'when set' do
|
110
|
+
let(:connection) { double("connection", select_value: "8.0.21") }
|
111
|
+
|
112
|
+
it "is lazy, so it doesn't use the database connection until read" do
|
113
|
+
expect(ActiveRecord::Base).to receive(:connection) do
|
114
|
+
@connection_called = true
|
115
|
+
connection
|
116
|
+
end
|
117
|
+
described_class.default_collation = "utf8_general_ci"
|
118
|
+
expect(@connection_called).to be_falsey
|
119
|
+
described_class.default_collation
|
120
|
+
expect(@connection_called).to be_truthy
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
84
124
|
end
|
85
125
|
|
86
126
|
describe '#default_text_limit' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: declare_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Invoca Development adapted from hobo_fields by Tom Locke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|