cequel 3.2.0 → 3.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06737301a7c04005670f2c38aa69a50d08a8166a
4
- data.tar.gz: 9253937c264d5d6ef64a3861aa1d909779b9f853
3
+ metadata.gz: 2eda195d7d5e6aef81b19d481e572bfb1d51dac5
4
+ data.tar.gz: 414334060e4cc735fd00fffce7be63dea0046318
5
5
  SHA512:
6
- metadata.gz: 3e1d63bb14b7f0f7d365533274a54805cce8298c65bb8128715af69338487f41190dda0912ae2980e27a5b021de60d763cc2a697043ef087607ea1071d1776c1
7
- data.tar.gz: 1c0f57e5b8f3a53624da0a5eb694a4786ab59a362883cf0e3d4296a805947c0106e67310ba8bb5adf6c66cb17fd3ef1b8888b1ea3f9a0bed4c34656327b547b9
6
+ metadata.gz: ac630af7bebd8bc6567c796d0b7b2bcb6c02648b1d26f28b31a64e7e146368d7f1799083bd88ec419422de64dffc708e923581bd54485467730e36bc2d24e0e1
7
+ data.tar.gz: 0000ce0ab0b14cf5d08b90fb14aa1597e1f8c0ab4e23b8799ccc6972199bff6c39f610f588aa67ceb76b6fb0533016c810ca9a8c5f0ff34a2c7dd4e8fcc0d448
@@ -1,3 +1,7 @@
1
+ ## 3.2.1
2
+ - fix multiple non-index column filtering (https://github.com/cequel/cequel/pull/407)
3
+ - fix KeySpace#client docs (https://github.com/cequel/cequel/pull/409)
4
+
1
5
  ## 3.2.0
2
6
  - Can filter on more than one non-indexed columns (https://github.com/cequel/cequel/pull/404)
3
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cequel (3.2.0)
4
+ cequel (3.2.1)
5
5
  activemodel (>= 4.0)
6
6
  cassandra-driver (~> 3.0)
7
7
 
@@ -357,4 +357,4 @@ DEPENDENCIES
357
357
  yard (~> 0.6)
358
358
 
359
359
  BUNDLED WITH
360
- 1.17.1
360
+ 1.17.3
@@ -167,7 +167,7 @@ module Cequel
167
167
  end
168
168
 
169
169
  #
170
- # @return [Cql::Client::Client] the low-level client provided by the
170
+ # @return [Cassandra::Session] the low-level client session provided by the
171
171
  # adapter
172
172
  # @api private
173
173
  #
@@ -52,7 +52,7 @@ module Cequel
52
52
  attr_reader :record_set
53
53
  def_delegators :record_set, :row_limit, :select_columns,
54
54
  :scoped_key_names, :scoped_key_values,
55
- :scoped_indexed_column, :lower_bound,
55
+ :scoped_secondary_columns, :lower_bound,
56
56
  :upper_bound, :reversed?, :order_by_column,
57
57
  :query_consistency, :query_page_size, :query_paging_state,
58
58
  :ascends_by?, :allow_filtering
@@ -72,8 +72,8 @@ module Cequel
72
72
  key_conditions = Hash[scoped_key_names.zip(scoped_key_values)]
73
73
  self.data_set = data_set.where(key_conditions)
74
74
  end
75
- if scoped_indexed_column
76
- self.data_set = data_set.where(scoped_indexed_column)
75
+ if scoped_secondary_columns
76
+ self.data_set = data_set.where(scoped_secondary_columns)
77
77
  end
78
78
  end
79
79
 
@@ -107,7 +107,7 @@ module Cequel
107
107
 
108
108
  # @private
109
109
  def self.default_attributes
110
- {scoped_key_values: [], select_columns: []}
110
+ { scoped_key_values: [], select_columns: [], scoped_secondary_columns: {} }
111
111
  end
112
112
 
113
113
  # @return [Class] the Record class that this collection yields instances
@@ -743,7 +743,7 @@ module Cequel
743
743
 
744
744
  hattr_reader :cequel_attributes, :select_columns, :scoped_key_values,
745
745
  :row_limit, :lower_bound, :upper_bound,
746
- :scoped_indexed_column, :query_consistency,
746
+ :scoped_secondary_columns, :query_consistency,
747
747
  :query_page_size, :query_paging_state,
748
748
  :allow_filtering
749
749
 
@@ -818,7 +818,7 @@ module Cequel
818
818
  if column_values.key?(next_unscoped_key_name)
819
819
  filter_primary_key(column_values.delete(next_unscoped_key_name))
820
820
  else
821
- filter_secondary_index(*column_values.shift)
821
+ filter_secondary_column(*column_values.shift)
822
822
  end.filter_columns(column_values)
823
823
  end
824
824
 
@@ -832,29 +832,14 @@ module Cequel
832
832
  end
833
833
  end
834
834
 
835
- def filter_secondary_index(column_name, value)
835
+ def filter_secondary_column(column_name, value)
836
836
  column = target_class.reflect_on_column(column_name)
837
837
  if column.nil?
838
- fail ArgumentError,
839
- "No column #{column_name} configured for #{target_class.name}"
840
- end
841
- if column.key?
842
- missing_column_names = unscoped_key_names.take_while do |key_name|
843
- key_name != column_name
844
- end
845
- fail IllegalQuery,
846
- "Can't scope key column #{column_name} without also scoping " \
847
- "#{missing_column_names.join(', ')}"
838
+ fail ArgumentError, "No column #{column_name} configured for #{target_class.name}"
848
839
  end
849
- if scoped_indexed_column && !allow_filtering
850
- fail IllegalQuery,
851
- "Can't scope by more than one indexed column in the same query"
852
- end
853
- unless column.indexed? || allow_filtering
854
- fail ArgumentError,
855
- "Can't scope by non-indexed column #{column_name}"
856
- end
857
- scoped(scoped_indexed_column: {column_name => column.cast(value)})
840
+ validate_secondary_column_filter(column)
841
+ scoped(scoped_secondary_columns:
842
+ scoped_secondary_columns.merge(column_name => column.cast(value)))
858
843
  end
859
844
 
860
845
  def scoped_key_columns
@@ -995,6 +980,32 @@ module Cequel
995
980
  next_unscoped_key_column.cast(value)
996
981
  end
997
982
  end
983
+
984
+ def validate_secondary_column_filter(column)
985
+ if column.key?
986
+ missing_column_names = unscoped_key_names.take_while do |key_name|
987
+ key_name != column.name
988
+ end
989
+ fail IllegalQuery,
990
+ "Can't scope key column #{column.name} without also scoping " \
991
+ "#{missing_column_names.join(', ')}"
992
+ else
993
+ validate_non_key_column_filter(column)
994
+ end
995
+ end
996
+
997
+ def validate_non_key_column_filter(column)
998
+ return if allow_filtering
999
+
1000
+ if scoped_secondary_columns.any?
1001
+ fail IllegalQuery,
1002
+ "Can't scope by more than one indexed column in the same query without allow_filtering!"
1003
+ end
1004
+ unless column.indexed?
1005
+ fail ArgumentError,
1006
+ "Can't scope by non-indexed column #{column.name} without allow_filtering!"
1007
+ end
1008
+ end
998
1009
  end
999
1010
  end
1000
1011
  end
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Cequel
3
3
  # The current version of the library
4
- VERSION = '3.2.0'
4
+ VERSION = '3.2.1'
5
5
  end
@@ -13,6 +13,7 @@ describe Cequel::Record::RecordSet do
13
13
  key :permalink, :ascii
14
14
  column :title, :text
15
15
  column :body, :text
16
+ column :subtitle, :text
16
17
  column :author_id, :uuid, index: true
17
18
  column :author_name, :text, index: true
18
19
  list :tags, :text
@@ -54,11 +55,12 @@ describe Cequel::Record::RecordSet do
54
55
  let(:cassandra_posts) do
55
56
  5.times.map do |i|
56
57
  Post.new(
57
- :blog_subdomain => 'cassandra',
58
- :permalink => "cequel#{i}",
59
- :title => "Cequel #{i}",
60
- :body => "Post number #{i}",
61
- :author_id => uuids[i%2]
58
+ blog_subdomain: 'cassandra',
59
+ permalink: "cequel#{i}",
60
+ title: "Cequel #{i}",
61
+ subtitle: 'New Cequel Post',
62
+ body: "Post number #{i}",
63
+ author_id: uuids[i%2]
62
64
  )
63
65
  end
64
66
  end
@@ -826,7 +828,7 @@ describe Cequel::Record::RecordSet do
826
828
  it 'should allow filtering for more than one non-indexed column' do
827
829
  expect(Post.allow_filtering!.where(
828
830
  title: 'Cequel 0',
829
- body: 'Post number 0'
831
+ subtitle: 'New Cequel Post'
830
832
  ).entries.length).to be(1)
831
833
  end
832
834
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat Brown
@@ -31,7 +31,7 @@ authors:
31
31
  autorequire:
32
32
  bindir: bin
33
33
  cert_chain: []
34
- date: 2019-01-02 00:00:00.000000000 Z
34
+ date: 2019-03-23 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activemodel