declare_schema 0.8.0.pre.5 → 0.8.0.pre.6
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/Gemfile.lock +1 -1
- data/lib/declare_schema/model/column.rb +2 -0
- data/lib/declare_schema/version.rb +1 -1
- data/spec/lib/declare_schema/field_spec_spec.rb +31 -24
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d3ceea8167afc532a38353f4bdac36fc805762dd2c8f2bf5fdb7895e7fc9886
|
4
|
+
data.tar.gz: 766a96c62aad5a6360c12a74a2630d52d6ee4c08b44ceeb3dd7309251886ce14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9de9bb8b90e978d745b5832ce81553d1156e10810f30304a347dd5e591ccd55fa086982ea32f349634cc1a8ff34fad3798d94ccfcd1fe3351be1f9e5a1f9648
|
7
|
+
data.tar.gz: 7b569604b9dc7f0ca2b8a8c36ffaede21a85e5f0ca13e39291823cfdf41a7b2f3ee00dedb7dd93e4ddd589a266dee75909f9b33bcb084c1e8929086216dbdee9
|
data/Gemfile.lock
CHANGED
@@ -44,6 +44,8 @@ module DeclareSchema
|
|
44
44
|
if ActiveRecord::Base.connection.class.name.match?(/mysql/i)
|
45
45
|
types[:text][:limit] ||= 0xffff
|
46
46
|
types[:binary][:limit] ||= 0xffff
|
47
|
+
|
48
|
+
types[:varbinary] ||= { name: "varbinary" } # TODO: :varbinary is an Invoca addition to Rails; make it a configurable option
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
@@ -83,37 +83,44 @@ RSpec.describe DeclareSchema::Model::FieldSpec do
|
|
83
83
|
expect(subject.schema_attributes(col_spec)).to eq(type: :text, null: true, default: 'none')
|
84
84
|
end
|
85
85
|
end
|
86
|
+
end
|
86
87
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
88
|
+
describe 'varbinary' do # TODO: :varbinary is an Invoca addition to Rails; make it a configurable option
|
89
|
+
it 'is supported' do
|
90
|
+
subject = described_class.new(model, :binary_dump, :varbinary, limit: 200, null: false, position: 2)
|
91
|
+
expect(subject.schema_attributes(col_spec)).to eq(type: :varbinary, limit: 200, null: false)
|
92
|
+
end
|
93
|
+
end
|
92
94
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
95
|
+
describe 'decimal' do
|
96
|
+
it 'allows precision: and scale:' do
|
97
|
+
subject = described_class.new(model, :quantity, :decimal, precision: 8, scale: 10, null: true, position: 3)
|
98
|
+
expect(subject.schema_attributes(col_spec)).to eq(type: :decimal, precision: 8, scale: 10, null: true)
|
99
|
+
end
|
97
100
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
end
|
101
|
+
it 'requires precision:' do
|
102
|
+
expect_any_instance_of(described_class).to receive(:warn).with(/precision: required for :decimal type/)
|
103
|
+
described_class.new(model, :quantity, :decimal, scale: 10, null: true, position: 3)
|
102
104
|
end
|
103
105
|
|
104
|
-
|
105
|
-
|
106
|
-
|
106
|
+
it 'requires scale:' do
|
107
|
+
expect_any_instance_of(described_class).to receive(:warn).with(/scale: required for :decimal type/)
|
108
|
+
described_class.new(model, :quantity, :decimal, precision: 8, null: true, position: 3)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
[:integer, :bigint, :string, :text, :binary, :varbinary, :datetime, :date, :time].each do |t|
|
113
|
+
describe t.to_s do
|
114
|
+
let(:extra) { t == :string ? { limit: 100 } : {} }
|
107
115
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
116
|
+
it 'does not allow precision:' do
|
117
|
+
expect_any_instance_of(described_class).to receive(:warn).with(/precision: only allowed for :decimal type/)
|
118
|
+
described_class.new(model, :quantity, t, { precision: 8, null: true, position: 3 }.merge(extra))
|
119
|
+
end unless t == :datetime
|
112
120
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
end
|
121
|
+
it 'does not allow scale:' do
|
122
|
+
expect_any_instance_of(described_class).to receive(:warn).with(/scale: only allowed for :decimal type/)
|
123
|
+
described_class.new(model, :quantity, t, { scale: 10, null: true, position: 3 }.merge(extra))
|
117
124
|
end
|
118
125
|
end
|
119
126
|
end
|