cassie 1.0.0.beta.32 → 1.0.0.beta.33
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ffedeca0fe95eb9d618ed1042b54fc2ffbda0a4
|
4
|
+
data.tar.gz: 5bb78230669425a06ea21f8886006074b2b38878
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16503691f2a924dc76cae63749f0ab3cf5b40afa56b37fd51df271f500862ba181e83f45740c15f0305df2d5911437a26e89ce177ad58b6f617d32ee47f8e1cf
|
7
|
+
data.tar.gz: c3ede66882f0a2341581892ca83fbc430f0ba525b04ced68d1fdfa3ec0f1e2a67473a7c736793e9bb18f847e0215a7accffd1068bceaa7a835198188acfbe6cb
|
@@ -785,6 +785,32 @@ set_1 = query.fetch([1, 2, 3])
|
|
785
785
|
set_2 = query.fetch([7, 8, 9, 10, 11, 12])
|
786
786
|
```
|
787
787
|
|
788
|
+
#### Allowing Filtering
|
789
|
+
|
790
|
+
For select statements, allowing filtering is supported.
|
791
|
+
|
792
|
+
```ruby
|
793
|
+
class IveReallyThoughtThisOutQuery < Cassie::Query
|
794
|
+
|
795
|
+
select_from :users_by_id
|
796
|
+
|
797
|
+
where :rank, :gt
|
798
|
+
|
799
|
+
attr_accessor :rank
|
800
|
+
|
801
|
+
allow_filtering
|
802
|
+
end
|
803
|
+
```
|
804
|
+
|
805
|
+
Assuming `rank` is a field for which a ranging query requires [Cassandra filtering](http://www.datastax.com/dev/blog/allow-filtering-explained-2), the statement will now be valid.
|
806
|
+
```
|
807
|
+
query = IveReallyThoughtThisOutQuery.new(rank: rank)
|
808
|
+
query.to_cql
|
809
|
+
=> "SELECT * FROM users_by_id WHERE rank > 100 ALLOW FILTERING;"
|
810
|
+
```
|
811
|
+
|
812
|
+
Allowing filtering in production is usually a Bad Idea, unless you really are ok with Cassandra loading all CQL rows into memory before filtering down to the requested set.
|
813
|
+
|
788
814
|
#### Custom queries
|
789
815
|
|
790
816
|
For certain queries, it may be most effective to write CQL directly. The recommended way is to override `cql` and `params`.
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Cassie::Statements::Statement
|
2
|
+
module AllowFiltering
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def inherited(subclass)
|
7
|
+
subclass.allow_filtering(allow_filtering?) if defined?(@allow_filtering)
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
def allow_filtering(val=:allow)
|
12
|
+
@allow_filtering = !!val
|
13
|
+
end
|
14
|
+
|
15
|
+
def allow_filtering?
|
16
|
+
return !!@allow_filtering if defined?(@allow_filtering)
|
17
|
+
false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def allow_filtering?
|
22
|
+
self.class.allow_filtering?
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
|
27
|
+
def build_allow_filtering_str
|
28
|
+
if allow_filtering?
|
29
|
+
"ALLOW FILTERING"
|
30
|
+
else
|
31
|
+
""
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative 'limiting'
|
2
|
+
require_relative 'allow_filtering'
|
2
3
|
require_relative 'pagination'
|
3
4
|
require_relative 'relations'
|
4
5
|
require_relative 'ordering'
|
@@ -11,6 +12,7 @@ module Cassie::Statements::Statement
|
|
11
12
|
include Relations
|
12
13
|
include Ordering
|
13
14
|
include Limiting
|
15
|
+
include AllowFiltering
|
14
16
|
include Pagination
|
15
17
|
|
16
18
|
@result_class = Cassie::Statements::Results::QueryResult
|
@@ -68,6 +70,7 @@ module Cassie::Statements::Statement
|
|
68
70
|
#{where_str}
|
69
71
|
#{build_order_str}
|
70
72
|
#{build_limit_str}
|
73
|
+
#{build_allow_filtering_str}
|
71
74
|
).squish + ";"
|
72
75
|
end
|
73
76
|
|
data/lib/cassie/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cassie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.beta.
|
4
|
+
version: 1.0.0.beta.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Prothro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cassandra-driver
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- lib/cassie/statements/modification.rb
|
161
161
|
- lib/cassie/statements/query.rb
|
162
162
|
- lib/cassie/statements/statement.rb
|
163
|
+
- lib/cassie/statements/statement/allow_filtering.rb
|
163
164
|
- lib/cassie/statements/statement/assignment.rb
|
164
165
|
- lib/cassie/statements/statement/assignments.rb
|
165
166
|
- lib/cassie/statements/statement/conditions.rb
|