gotime-cassandra_object 4.0.0 → 4.0.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.
- data/gotime-cassandra_object.gemspec +1 -1
- data/lib/cassandra_object/base.rb +0 -1
- data/lib/cassandra_object/connection.rb +17 -0
- data/lib/gotime-cassandra_object.rb +0 -2
- data/test/unit/connection_test.rb +4 -0
- metadata +2 -4
- data/lib/cassandra_object/collection.rb +0 -8
- data/lib/cassandra_object/mocking.rb +0 -15
@@ -1,3 +1,20 @@
|
|
1
|
+
module CassandraCQL
|
2
|
+
class Statement
|
3
|
+
def self.sanitize(statement, bind_vars=[])
|
4
|
+
return statement if bind_vars.empty?
|
5
|
+
|
6
|
+
bind_vars = bind_vars.dup
|
7
|
+
expected_bind_vars = statement.count("?")
|
8
|
+
|
9
|
+
raise Error::InvalidBindVariable, "Wrong number of bound variables (statement expected #{expected_bind_vars}, was #{bind_vars.size})" if expected_bind_vars != bind_vars.size
|
10
|
+
|
11
|
+
statement.gsub(/\?/) do
|
12
|
+
quote(cast_to_cql(bind_vars.shift))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
1
18
|
module CassandraObject
|
2
19
|
module Connection
|
3
20
|
extend ActiveSupport::Concern
|
@@ -4,6 +4,10 @@ class CassandraObject::ConnectionTest < CassandraObject::TestCase
|
|
4
4
|
class TestObject < CassandraObject::Base
|
5
5
|
end
|
6
6
|
|
7
|
+
test "sanitize supports question marks" do
|
8
|
+
assert_equal 'hello ?', CassandraCQL::Statement.sanitize('hello ?')
|
9
|
+
end
|
10
|
+
|
7
11
|
test 'establish_connection' do
|
8
12
|
# TestObject.establish_connection(
|
9
13
|
# keyspace: 'place_directory_development',
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gotime-cassandra_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-08-
|
13
|
+
date: 2012-08-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
@@ -120,7 +120,6 @@ files:
|
|
120
120
|
- lib/cassandra_object/belongs_to/builder.rb
|
121
121
|
- lib/cassandra_object/belongs_to/reflection.rb
|
122
122
|
- lib/cassandra_object/callbacks.rb
|
123
|
-
- lib/cassandra_object/collection.rb
|
124
123
|
- lib/cassandra_object/connection.rb
|
125
124
|
- lib/cassandra_object/consistency.rb
|
126
125
|
- lib/cassandra_object/errors.rb
|
@@ -128,7 +127,6 @@ files:
|
|
128
127
|
- lib/cassandra_object/identity.rb
|
129
128
|
- lib/cassandra_object/inspect.rb
|
130
129
|
- lib/cassandra_object/log_subscriber.rb
|
131
|
-
- lib/cassandra_object/mocking.rb
|
132
130
|
- lib/cassandra_object/persistence.rb
|
133
131
|
- lib/cassandra_object/railtie.rb
|
134
132
|
- lib/cassandra_object/savepoints.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'cassandra/mock'
|
2
|
-
module CassandraObject
|
3
|
-
module Mocking
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
module ClassMethods
|
6
|
-
def use_mock!(really=true)
|
7
|
-
if really
|
8
|
-
self.connection_class = Cassandra::Mock
|
9
|
-
else
|
10
|
-
self.connection_class = Cassandra
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|