kasket 3.1.3 → 3.1.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: 0c6bfa50affd0410b4118a393a9f058c54149bac
4
- data.tar.gz: fec8fa3b11f35c364b9e5c26448830d0331a5082
3
+ metadata.gz: f991371eb51fc1fa71c6902a9f7521011eaad4a3
4
+ data.tar.gz: 585665215a4aad97c63f41395965e2f53397a18d
5
5
  SHA512:
6
- metadata.gz: 65e2baa04a767f94209a508a4b853bd17dfc318803a3afbcd6fd650ede78ec65cc9510567d867d0a2e8ce416b9eb125d7578fff02bf6f5fbab701f2f1dc50202
7
- data.tar.gz: 5523ee1be9feeaddf7b62276c01d1ba620d9e482cd814b39ac2e3b0348aaec1c37c3b52e92a122918450159bfece81daae341b921cf9637cd3f02ef0e3faeac6
6
+ metadata.gz: 56dd49026d082012079b32fb729e70228081333327026461c8b1a0a2e624ec4cb1cd0d8240800ffbc0f1cf76a8c4870b2d11fc15963afec4fa5d186de6eda8e7
7
+ data.tar.gz: 62c542fe0a7c6d867b685c8d46d0b021dfc4ee36bc004d207e735845f9bd15ced98f474d5e1ff99c6082efcabe05b5d1fefc72049f31b291af6549b1e9c3c7e2
@@ -37,7 +37,12 @@ module Kasket
37
37
  key = attribute_value_pairs.map do |attribute, value|
38
38
  column = columns_hash[attribute.to_s]
39
39
  value = nil if value.blank?
40
- attribute.to_s + '=' + connection.quote(column.type_cast(value), column).downcase
40
+ quoted_value = if column
41
+ connection.quote(column.type_cast(value), column).downcase
42
+ else
43
+ value.to_s
44
+ end
45
+ attribute.to_s << '=' << quoted_value
41
46
  end.join('/')
42
47
 
43
48
  if key.size > (250 - kasket_key_prefix.size) || key =~ /\s/
@@ -1,7 +1,11 @@
1
1
  module Kasket
2
2
  module SelectManagerMixin
3
3
  def to_kasket_query(klass, binds = [])
4
- query = Kasket::Visitor.new(klass, binds).accept(ast)
4
+ begin
5
+ query = Kasket::Visitor.new(klass, binds).accept(ast)
6
+ rescue TypeError # unsupported object in ast
7
+ return nil
8
+ end
5
9
 
6
10
  return nil if query.nil? || query == :unsupported
7
11
  return nil if query[:attributes].blank?
@@ -3,7 +3,7 @@ module Kasket
3
3
  class Version
4
4
  MAJOR = 3
5
5
  MINOR = 1
6
- PATCH = 3
6
+ PATCH = 4
7
7
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
8
  PROTOCOL = 4
9
9
  end
@@ -126,15 +126,5 @@ module Kasket
126
126
  alias :visit_TrueClass :literal
127
127
  alias :visit_FalseClass :literal
128
128
  alias :visit_Arel_Nodes_SqlLiteral :literal
129
-
130
- def method_missing(name, *args, &block)
131
- return :unsupported if name.to_s.start_with?('visit_')
132
- super
133
- end
134
-
135
- def respond_to?(name, include_private = false)
136
- return super || name.to_s.start_with?('visit_')
137
- end
138
-
139
129
  end
140
130
  end
@@ -10,6 +10,13 @@ class ConfigurationMixinTest < ActiveSupport::TestCase
10
10
  assert_equal expected_cache_key, Post.kasket_key_for(query_attributes)
11
11
  end
12
12
 
13
+ should "not fail on unknown columns" do
14
+ expected_cache_key = "#{Post.kasket_key_prefix}does_not_exist=111"
15
+ query_attributes = [ [:does_not_exist, '111'] ]
16
+
17
+ assert_equal expected_cache_key, Post.kasket_key_for(query_attributes)
18
+ end
19
+
13
20
  should "not generate keys longer that 255" do
14
21
  very_large_number = (1..999).to_a.join
15
22
  query_attributes = [ [:blog_id, very_large_number] ]
data/test/helper.rb CHANGED
@@ -14,10 +14,12 @@ end
14
14
  require 'test/unit'
15
15
  require 'mocha'
16
16
  require 'active_record'
17
+ require "logger"
17
18
 
18
19
  raise "Must configure #time_zone_aware_attributes prior to models" if defined?(Post)
19
20
  ENV['TZ'] = 'utc'
20
21
  ActiveRecord::Base.time_zone_aware_attributes = true
22
+ ActiveRecord::Base.logger = Logger.new(StringIO.new)
21
23
 
22
24
  require 'active_record/fixtures'
23
25
 
data/test/visitor_test.rb CHANGED
@@ -1,5 +1,13 @@
1
1
  require File.expand_path("helper", File.dirname(__FILE__))
2
2
 
3
+ module Nori
4
+ class StringWithAttributes < String
5
+ end
6
+
7
+ class Unknown
8
+ end
9
+ end
10
+
3
11
  class VisitorTest < ActiveSupport::TestCase
4
12
  if arel?
5
13
  context Kasket::Visitor do
@@ -12,6 +20,20 @@ class VisitorTest < ActiveSupport::TestCase
12
20
  }
13
21
  assert_equal expected, Post.where(:id => 1).to_kasket_query
14
22
  end
23
+
24
+ should "build from Nori::StringWithAttributes" do
25
+ expected = {
26
+ :attributes=>[[:id, "1"]],
27
+ :from=>"posts",
28
+ :index=>[:id],
29
+ :key=>"#{Post.kasket_key_prefix}id=1"
30
+ }
31
+ assert_equal expected, Post.where(:id => Nori::StringWithAttributes.new("1")).to_kasket_query
32
+ end
33
+
34
+ should "notify on missing attribute" do
35
+ assert_equal nil, Post.where(:id => Nori::Unknown.new).to_kasket_query
36
+ end
15
37
  end
16
38
  end
17
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kasket
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.3
4
+ version: 3.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mick Staugaard
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-15 00:00:00.000000000 Z
12
+ date: 2013-10-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
174
  version: '0'
175
175
  requirements: []
176
176
  rubyforge_project:
177
- rubygems_version: 2.0.7
177
+ rubygems_version: 2.0.6
178
178
  signing_key:
179
179
  specification_version: 4
180
180
  summary: A write back caching layer on active record