gotime-cassandra_object 4.4.4 → 4.4.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'gotime-cassandra_object'
5
- s.version = '4.4.4'
5
+ s.version = '4.4.5'
6
6
  s.description = 'Cassandra ActiveModel'
7
7
  s.summary = 'Cassandra ActiveModel'
8
8
  s.authors = ["Michael Koziarski", "gotime"]
@@ -15,9 +15,18 @@ module CassandraObject
15
15
  system_execute "DROP KEYSPACE #{keyspace}"
16
16
  end
17
17
 
18
- def create_column_family(column_family)
19
- execute "CREATE COLUMNFAMILY #{column_family} " +
20
- "(KEY varchar PRIMARY KEY)"
18
+ def create_column_family(column_family, options = {})
19
+ stmt = "CREATE COLUMNFAMILY #{column_family} " +
20
+ "(KEY varchar PRIMARY KEY)"
21
+
22
+ if options.any?
23
+ with_stmt = options.map do |k,v|
24
+ "#{k} = #{CassandraCQL::Statement.quote(v)}"
25
+ end.join(' AND ')
26
+ stmt << " WITH #{with_stmt}"
27
+ end
28
+
29
+ execute stmt
21
30
  end
22
31
 
23
32
  def alter_column_family_with(with)
@@ -1,11 +1,27 @@
1
1
  ks_namespace = namespace :ks do
2
2
  desc 'Create the keyspace in cassandra_config/cassandra.yml for the current environment'
3
3
  task create: :environment do
4
- CassandraObject::Schema.create_keyspace cassandra_config['keyspace']
4
+ begin
5
+ CassandraObject::Schema.create_keyspace cassandra_config['keyspace']
6
+ rescue Exception => e
7
+ if e.message =~ /conflicts/
8
+ p "Keyspace #{cassandra_config['keyspace']} already exists"
9
+ else
10
+ raise e
11
+ end
12
+ end
5
13
  end
6
14
 
7
15
  task drop: :environment do
8
- CassandraObject::Schema.drop_keyspace cassandra_config['keyspace']
16
+ begin
17
+ CassandraObject::Schema.drop_keyspace cassandra_config['keyspace']
18
+ rescue Exception => e
19
+ if e.message =~ /non existing keyspace/
20
+ p "Keyspace #{cassandra_config['keyspace']} does not exist"
21
+ else
22
+ raise e
23
+ end
24
+ end
9
25
  end
10
26
 
11
27
  task reset: [:drop, :setup]
@@ -1,7 +1,6 @@
1
1
  CassandraObject::Base.establish_connection(
2
2
  keyspace: 'cassandra_object_test',
3
- servers: '127.0.0.1:9160',
4
- thrift: {timeout: 200}
3
+ servers: '127.0.0.1:9160'
5
4
  )
6
5
 
7
6
  begin
@@ -8,11 +8,7 @@ CassandraObject::Base.class_eval do
8
8
 
9
9
  def self.delete_after_test
10
10
  # created_records.reject(&:destroyed?).each(&:destroy)
11
- cql = CassandraCQL::Database.new(connection_config.servers, {keyspace: connection_config.keyspace}, connection_config.thrift_options)
12
- begin
13
- cql.execute "TRUNCATE Issues"
14
- rescue
15
- end
11
+ Issue.delete_all
16
12
  created_records.clear
17
13
  end
18
14
  end
@@ -0,0 +1,13 @@
1
+ require 'test_helper'
2
+
3
+ class CassandraObject::SchemaTest < CassandraObject::TestCase
4
+ test "create_column_family" do
5
+ CassandraObject::Schema.create_column_family 'TestRecords', 'compression_parameters:sstable_compression' => 'SnappyCompressor'
6
+
7
+ begin
8
+ CassandraObject::Schema.create_column_family 'TestRecords'
9
+ assert false, 'TestRecords should already exist'
10
+ rescue Exception => e
11
+ end
12
+ end
13
+ end
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.4.4
4
+ version: 4.4.5
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-09-19 00:00:00.000000000 Z
13
+ date: 2012-09-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activemodel
@@ -156,6 +156,7 @@ files:
156
156
  - test/unit/persistence_test.rb
157
157
  - test/unit/savepoints_test.rb
158
158
  - test/unit/schema/tasks_test.rb
159
+ - test/unit/schema_test.rb
159
160
  - test/unit/scope/batches_test.rb
160
161
  - test/unit/scope/finder_methods_test.rb
161
162
  - test/unit/scope/query_methods_test.rb