Skip to content

Commit be6f088

Browse files
committed
Merge pull request #257 from jmondo/default_arrays
Quote each value in default arrays
2 parents 02ed4da + 5f9fa90 commit be6f088

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

lib/annotate/annotate_models.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def quote(value)
9393
when Float, Fixnum, Bignum then value.to_s
9494
# BigDecimals need to be output in a non-normalized form and quoted.
9595
when BigDecimal then value.to_s('F')
96+
when Array then value.map {|v| quote(v)}
9697
else
9798
value.inspect
9899
end

spec/annotate/annotate_models_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def mock_column(name, type, options={})
5656
it { expect(AnnotateModels.quote(25)).to eql("25") }
5757
it { expect(AnnotateModels.quote(25.6)).to eql("25.6") }
5858
it { expect(AnnotateModels.quote(1e-20)).to eql("1.0e-20") }
59+
it { expect(AnnotateModels.quote(BigDecimal.new("1.2"))).to eql("1.2") }
60+
it { expect(AnnotateModels.quote([BigDecimal.new("1.2")])).to eql(["1.2"]) }
5961

6062
it "should get schema info" do
6163
klass = mock_class(:users, :id, [

0 commit comments

Comments
 (0)