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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +2 -2
- data/lib/cequel/metal/keyspace.rb +1 -1
- data/lib/cequel/record/data_set_builder.rb +3 -3
- data/lib/cequel/record/record_set.rb +34 -23
- data/lib/cequel/version.rb +1 -1
- data/spec/examples/record/record_set_spec.rb +8 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2eda195d7d5e6aef81b19d481e572bfb1d51dac5
|
4
|
+
data.tar.gz: 414334060e4cc735fd00fffce7be63dea0046318
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac630af7bebd8bc6567c796d0b7b2bcb6c02648b1d26f28b31a64e7e146368d7f1799083bd88ec419422de64dffc708e923581bd54485467730e36bc2d24e0e1
|
7
|
+
data.tar.gz: 0000ce0ab0b14cf5d08b90fb14aa1597e1f8c0ab4e23b8799ccc6972199bff6c39f610f588aa67ceb76b6fb0533016c810ca9a8c5f0ff34a2c7dd4e8fcc0d448
|
data/CHANGELOG.md
CHANGED
@@ -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
|
|
data/Gemfile.lock
CHANGED
@@ -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
|
-
:
|
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
|
76
|
-
self.data_set = data_set.where(
|
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
|
-
:
|
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
|
-
|
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
|
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
|
-
|
850
|
-
|
851
|
-
|
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
|
data/lib/cequel/version.rb
CHANGED
@@ -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
|
-
:
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
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
|
-
|
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.
|
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-
|
34
|
+
date: 2019-03-23 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: activemodel
|