activerecord-turntable 2.0.3 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c7d26c10b2a5821aa33e7136734bcf2e5ef25080
4
- data.tar.gz: 5a4709f8c44aaf2f2d9ac437c8b1bc3ff679fa1d
3
+ metadata.gz: 8069297634d4cb87e81b6f4e06332ce1d5876183
4
+ data.tar.gz: bd7470ff554b46af40af99e904add373e3109d46
5
5
  SHA512:
6
- metadata.gz: c990394e1144fc5f7b20fa6c5a9a2a818e8937683676bb0c5752f26582109a17ef43c8548e8645d811884facf0e4a9a4f196a62b4025947dde23fcfcb65bfbfd
7
- data.tar.gz: 7afc6bc759ecbe127e720664888576b91c3628990a02c38bdd1cf5f4af8c71dff0e426f211fee76b640d5d5c6de4f7fbcc13509690c5db6b057007340c2d4323
6
+ metadata.gz: 7ecad4f8c75a561cedb0fca64e859a045b0518b252cc69c63f4ef31e0312570728e2e0adbe99844de53b2a6f93aaebc2918a7680dc3dfc2b29f252a1238fc4c2
7
+ data.tar.gz: 1b4d0ab20b846f1abd96fb5f4fd1924829150da9666783f8ecec67f5bf67e521fa422efa31cc5223cffc76f0e96ba152e033190a43f6ec46bd1a0ae725996c63
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## activerecord-turntable 2.0.4 ##
2
+
3
+ Add dependency: ruby >= 1.9.3 from this release
4
+
5
+ ### Bugfixes
6
+
7
+ * Fix incorrect insert sql with binary literal
8
+
1
9
  ## activerecord-turntable 2.0.3 ##
2
10
 
3
11
  ### Bugfixes
data/Rakefile CHANGED
@@ -51,6 +51,7 @@ namespace :turntable do
51
51
  ActiveRecord::Base.connection.create_table :users do |t|
52
52
  t.string :nickname
53
53
  t.string :thumbnail_url
54
+ t.binary :blob
54
55
  t.datetime :joined_at
55
56
  t.datetime :deleted_at
56
57
  t.timestamps
@@ -21,12 +21,13 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
22
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
23
  spec.require_paths = ["lib"]
24
+ spec.required_ruby_version = '>= 1.9.3'
24
25
 
25
- spec.add_dependency "activerecord", ">= 4.0.0"
26
- spec.add_dependency "activesupport", ">= 4.0.0"
27
- spec.add_dependency "sql_tree", "= 0.2.0"
28
- spec.add_dependency "bsearch", "~> 1.5"
29
- spec.add_dependency "httpclient", ">= 0"
26
+ spec.add_runtime_dependency "activerecord", ">= 4.0.0", "< 5.0"
27
+ spec.add_runtime_dependency "activesupport", ">= 4.0.0", "< 5.0"
28
+ spec.add_runtime_dependency "sql_tree", "= 0.2.0"
29
+ spec.add_runtime_dependency "bsearch", "~> 1.5"
30
+ spec.add_runtime_dependency "httpclient", ">= 0"
30
31
 
31
32
  # optional dependencies
32
33
  spec.add_development_dependency "activerecord-import"
@@ -214,7 +214,7 @@ module ActiveRecord::Turntable
214
214
  tree.values = [[SQLTree::Node::Expression::Variable.new("\\0")]]
215
215
  sql = tree.to_sql
216
216
  value_sql = vs.map do |val|
217
- "(#{val.map { |v| @proxy.connection.quote(v.value)}.join(', ')})"
217
+ "(#{val.map { |v| "#{v.escape}#{@proxy.connection.quote(v.value)}" }.join(', ')})"
218
218
  end.join(', ')
219
219
  sql.gsub!('("\0")') { value_sql }
220
220
  shards_with_query[@proxy.cluster.shard_for(k)] = sql
@@ -208,6 +208,10 @@ module SQLTree::Node
208
208
  end
209
209
  end
210
210
 
211
+ class Value
212
+ leaf :escape
213
+ end
214
+
211
215
  class EscapedValue < Value
212
216
  def initialize(value, escape = nil)
213
217
  @value = value
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Turntable
3
- VERSION = "2.0.3"
3
+ VERSION = "2.0.4"
4
4
  end
5
5
  end
@@ -35,6 +35,20 @@ describe ActiveRecord::Turntable::ActiveRecordExt::Persistence do
35
35
  Card.create!(:name => 'foobar')
36
36
  }
37
37
 
38
+ context "When creating record" do
39
+ context "with blob column" do
40
+ let(:blob_value) { "\123\123\123" }
41
+ let(:user) {
42
+ u = User.new(:nickname => 'x', :blob => blob_value )
43
+ u.id = 1
44
+ u.save
45
+ u
46
+ }
47
+ subject { user }
48
+ its(:blob) { is_expected.to eq(user.reload.blob) }
49
+ end
50
+ end
51
+
38
52
  context "When the model is sharded by surrogate key" do
39
53
  it "should not changed from normal operation when updating" do
40
54
  user.nickname = "fizzbuzz"
@@ -3,6 +3,7 @@ class CreateUsers < ActiveRecord::Migration
3
3
  create_table :users do |t|
4
4
  t.string :nickname
5
5
  t.string :thumbnail_url
6
+ t.binary :blob
6
7
  t.datetime :joined_at
7
8
  t.datetime :deleted_at
8
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-turntable
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - gussan
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-18 00:00:00.000000000 Z
12
+ date: 2014-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -18,6 +18,9 @@ dependencies:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: 4.0.0
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '5.0'
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -25,6 +28,9 @@ dependencies:
25
28
  - - ">="
26
29
  - !ruby/object:Gem::Version
27
30
  version: 4.0.0
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.0'
28
34
  - !ruby/object:Gem::Dependency
29
35
  name: activesupport
30
36
  requirement: !ruby/object:Gem::Requirement
@@ -32,6 +38,9 @@ dependencies:
32
38
  - - ">="
33
39
  - !ruby/object:Gem::Version
34
40
  version: 4.0.0
41
+ - - "<"
42
+ - !ruby/object:Gem::Version
43
+ version: '5.0'
35
44
  type: :runtime
36
45
  prerelease: false
37
46
  version_requirements: !ruby/object:Gem::Requirement
@@ -39,6 +48,9 @@ dependencies:
39
48
  - - ">="
40
49
  - !ruby/object:Gem::Version
41
50
  version: 4.0.0
51
+ - - "<"
52
+ - !ruby/object:Gem::Version
53
+ version: '5.0'
42
54
  - !ruby/object:Gem::Dependency
43
55
  name: sql_tree
44
56
  requirement: !ruby/object:Gem::Requirement
@@ -429,7 +441,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
429
441
  requirements:
430
442
  - - ">="
431
443
  - !ruby/object:Gem::Version
432
- version: '0'
444
+ version: 1.9.3
433
445
  required_rubygems_version: !ruby/object:Gem::Requirement
434
446
  requirements:
435
447
  - - ">="