activerecord-jdbcvertica-adapter 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e5459f0f11071a51788a81dbf27ea7aac63e2600
4
+ data.tar.gz: 4d35b4c163bbc92826a2855bf1f3f977e3f726bc
5
+ SHA512:
6
+ metadata.gz: faa8b2172233defd616bc05b03564d5116a5b778e2f95b00924b268065553b4137231b93e4351d732e54d884e125574316afff0114f5f605926b1b3b208b5ef2
7
+ data.tar.gz: 129db38199c19ae24803907f259714251109d20cd7a677f7aa2266fc271b44ff601ef728969840fa5821b08b51e5bc1b6030558d217ccd325160d342bd4c8d3e
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ *.yml
4
+ .ruby-*
5
+ .bundle
6
+ .config
7
+ .yardoc
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in activerecord-jdbcvertica6-adapter.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Brandon Dewitt
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Activerecord::Jdbcvertica::Adapter
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'activerecord-jdbcvertica-adapter'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install activerecord-jdbcvertica-adapter
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs.push "lib"
7
+ t.libs.push "spec"
8
+ t.pattern = "spec/**/*_spec.rb"
9
+ t.verbose = true
10
+ end
11
+
12
+ task :spec => :test
13
+ task :default => :spec
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'activerecord-jdbcvertica-adapter/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "activerecord-jdbcvertica-adapter"
8
+ gem.version = Activerecord::Jdbcvertica::Adapter::VERSION
9
+ gem.authors = ["Brandon Dewitt"]
10
+ gem.email = ["brandonsdewitt@gmail.com"]
11
+ gem.description = %q{ An ActiveRecord adapter for Vertica databases (jdbc based) }
12
+ gem.summary = %q{ An ActiveRecord adapter JDBC }
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "activerecord"
21
+ gem.add_dependency "activerecord-jdbc-adapter"
22
+
23
+ gem.add_development_dependency "bundler"
24
+ gem.add_development_dependency "mocha"
25
+ gem.add_development_dependency "pry"
26
+ gem.add_development_dependency "rake"
27
+ end
@@ -0,0 +1,2 @@
1
+ # Looks like Vertica5 shares with Vertica6
2
+ require 'active_record/connection_adapters/vertica6_adapter'
@@ -0,0 +1,4 @@
1
+ require 'java'
2
+ require 'activerecord-jdbcvertica-adapter/jars/vertica-jdk5-6.1.3-0.jar'
3
+
4
+ require 'arjdbc/vertica'
@@ -0,0 +1,4 @@
1
+ require 'java'
2
+ require 'activerecord-jdbcvertica-adapter/jars/vertica-jdbc-7.0.0-0.jar'
3
+
4
+ require 'arjdbc/vertica'
@@ -0,0 +1,2 @@
1
+ require "activerecord-jdbcvertica-adapter/version"
2
+ require "active_record"
@@ -0,0 +1,7 @@
1
+ module Activerecord
2
+ module Jdbcvertica
3
+ module Adapter
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ require 'arjdbc/jdbc'
2
+ require 'arjdbc/vertica/connection_methods'
3
+ require 'arjdbc/vertica/adapter'
@@ -0,0 +1,62 @@
1
+ # Load a mapping for the "text" type that will actually work
2
+ ::ActiveRecord::ConnectionAdapters::JdbcTypeConverter::AR_TO_JDBC_TYPES[:text] << lambda { |r| r['type_name'] =~ /varchar$/i }
3
+
4
+ module ::ArJdbc
5
+ module Vertica
6
+ ADAPTER_NAME = 'Vertica'.freeze
7
+
8
+ NATIVE_DATABASE_TYPES = {
9
+ :primary_key => "auto_increment",
10
+ :string => { :name => "varchar", :limit => 255 },
11
+ :text => { :name => "varchar", :limit => 15000 },
12
+ :integer => { :name => "integer" },
13
+ :float => { :name => "float" },
14
+ :decimal => { :name => "decimal" },
15
+ :datetime => { :name => "datetime" },
16
+ :timestamp => { :name => "timestamp" },
17
+ :time => { :name => "time" },
18
+ :date => { :name => "date" },
19
+ :binary => { :name => "bytea" },
20
+ :boolean => { :name => "boolean" },
21
+ :xml => { :name => "xml" }
22
+ }
23
+
24
+ def adapter_name
25
+ ADAPTER_NAME
26
+ end
27
+
28
+ ##
29
+ # Vertica JDBC does not work with JDBC GET_GENERATED_KEYS
30
+ # so we need to execute the sql raw and then lookup the
31
+ # LAST_INSERT_ID() that occurred in this "session"
32
+ #
33
+ def exec_insert(sql, name, binds, *args)
34
+ execute(sql, name, binds)
35
+
36
+ return select_value("SELECT LAST_INSERT_ID();")
37
+ end
38
+
39
+ def native_database_types
40
+ NATIVE_DATABASE_TYPES
41
+ end
42
+
43
+ ##
44
+ # Vertica does not allow the table name to prefix the columns when
45
+ # setting a value, this is not a pleasant work-around, but it works
46
+ #
47
+ def quote_table_name_for_assignment(table, attr)
48
+ quote_column_name(attr)
49
+ end
50
+
51
+ end
52
+ end
53
+
54
+ module ActiveRecord::ConnectionAdapters
55
+ class VerticaAdapter < JdbcAdapter
56
+ include ::ArJdbc::Vertica
57
+
58
+ def rename_index(*args)
59
+ raise ArgumentError, "rename_index does not work on Vertica"
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,21 @@
1
+ class ActiveRecord::Base
2
+ def self.vertica5_connection(config)
3
+ config[:port] ||= 5433
4
+ config[:url] = "jdbc:vertica://#{config[:host]}:#{config[:port]}/#{config[:database]}"
5
+ config[:driver] = "com.vertica.jdbc.Driver"
6
+ config[:prepared_statements] = false
7
+ config[:connection_alive_sql] = "SELECT 1;"
8
+ config[:adapter_class] = ::ActiveRecord::ConnectionAdapters::VerticaAdapter
9
+
10
+ jdbc_connection(config)
11
+ end
12
+
13
+ class << self
14
+ # connection methods should be the same
15
+ alias_method :vertica7_connection, :vertica5_connection
16
+ alias_method :vertica6_connection, :vertica5_connection
17
+ alias_method :jdbcvertica7_connection, :vertica5_connection
18
+ alias_method :jdbcvertica6_connection, :vertica5_connection
19
+ alias_method :jdbcvertica5_connection, :vertica5_connection
20
+ end
21
+ end
@@ -0,0 +1,271 @@
1
+ require 'spec_helper'
2
+
3
+ class CreateFullObject < ::ActiveRecord::Migration
4
+ def self.up
5
+ create_table :full_objects do |t|
6
+ t.string :string
7
+ t.text :text
8
+ t.integer :integer
9
+ t.float :float
10
+ t.decimal :decimal
11
+ t.datetime :datetime
12
+ t.time :time
13
+ t.date :date
14
+ t.boolean :boolean
15
+ end
16
+ end
17
+
18
+ def self.down
19
+ if table_exists?(:full_objects)
20
+ drop_table :full_objects
21
+ end
22
+ end
23
+ end
24
+
25
+ class FullObject < ::ActiveRecord::Base;
26
+ self.primary_key = "id"
27
+ end
28
+
29
+ describe ::FullObject do
30
+ subject { FullObject.new }
31
+
32
+ before do
33
+ CreateFullObject.down
34
+ CreateFullObject.up
35
+ end
36
+
37
+ describe "API" do
38
+ specify { subject.must_respond_to(:string) }
39
+ specify { subject.must_respond_to(:text) }
40
+ specify { subject.must_respond_to(:integer) }
41
+ specify { subject.must_respond_to(:float) }
42
+ specify { subject.must_respond_to(:decimal) }
43
+ specify { subject.must_respond_to(:datetime) }
44
+ specify { subject.must_respond_to(:time) }
45
+ specify { subject.must_respond_to(:date) }
46
+ specify { subject.must_respond_to(:boolean) }
47
+ end
48
+
49
+ describe "#delete" do
50
+ it "deletes a persisted record" do
51
+ subject.string = "string"
52
+ subject.save
53
+
54
+ FullObject.count.must_equal(1)
55
+ subject.delete
56
+ FullObject.count.must_equal(0)
57
+ end
58
+ end
59
+
60
+ describe "#delete_all" do
61
+ it "deletes a persisted record" do
62
+ subject.string = "string"
63
+ subject.save
64
+
65
+ FullObject.count.must_equal(1)
66
+ FullObject.where("id > 0").delete_all
67
+ FullObject.count.must_equal(0)
68
+ end
69
+ end
70
+
71
+ describe "#insert" do
72
+ it "string" do
73
+ subject.string = "string"
74
+ subject.save
75
+
76
+ retrieved = FullObject.find(subject.id)
77
+ retrieved.string.must_equal(subject.string)
78
+ end
79
+
80
+ it "text" do
81
+ subject.text = "text"
82
+ subject.save
83
+
84
+ retrieved = FullObject.find(subject.id)
85
+ retrieved.text.must_equal(subject.text)
86
+ end
87
+
88
+ it "integer" do
89
+ subject.integer = 1234
90
+ subject.save
91
+
92
+ retrieved = FullObject.find(subject.id)
93
+ retrieved.integer.must_equal(subject.integer)
94
+ end
95
+
96
+ it "float" do
97
+ subject.float = 1234.4321
98
+ subject.save
99
+
100
+ retrieved = FullObject.find(subject.id)
101
+ retrieved.float.must_equal(subject.float)
102
+ end
103
+
104
+ it "decimal" do
105
+ subject.decimal = 1234.4321
106
+ subject.save
107
+
108
+ retrieved = FullObject.find(subject.id)
109
+ retrieved.decimal.must_equal(subject.decimal)
110
+ end
111
+
112
+ it "datetime" do
113
+ subject.datetime = Time.current.utc
114
+ subject.save
115
+
116
+ retrieved = FullObject.find(subject.id)
117
+ retrieved.datetime.to_s.must_equal(subject.datetime.to_s)
118
+ end
119
+
120
+ it "time" do
121
+ subject.time = Time.current.utc
122
+ subject.save
123
+
124
+ retrieved = FullObject.find(subject.id)
125
+ retrieved.time.strftime("%H%M%S").must_equal(subject.time.strftime("%H%M%S"))
126
+ end
127
+
128
+ it "date" do
129
+ subject.date = Time.current
130
+ subject.save
131
+
132
+ retrieved = FullObject.find(subject.id)
133
+ retrieved.date.must_equal(subject.date)
134
+ end
135
+
136
+ it "boolean (false)" do
137
+ subject.boolean = false
138
+ subject.save
139
+
140
+ retrieved = FullObject.find(subject.id)
141
+ retrieved.boolean.must_equal(subject.boolean)
142
+ end
143
+
144
+ it "boolean (true)" do
145
+ subject.boolean = true
146
+ subject.save
147
+
148
+ retrieved = FullObject.find(subject.id)
149
+ retrieved.boolean.must_equal(subject.boolean)
150
+ end
151
+ end
152
+
153
+ describe "#update" do
154
+ it "string" do
155
+ change_to = "string2"
156
+ subject.string = "string"
157
+ subject.save
158
+
159
+ retrieved = FullObject.find(subject.id)
160
+ retrieved.update(:string => change_to)
161
+ retrieved.reload.string.must_equal(change_to)
162
+ end
163
+
164
+ it "text" do
165
+ change_to = "text2"
166
+ subject.text = "text"
167
+ subject.save
168
+
169
+ retrieved = FullObject.find(subject.id)
170
+ retrieved.update(:text => change_to)
171
+ retrieved.reload.text.must_equal(change_to)
172
+ end
173
+
174
+ it "integer" do
175
+ change_to = 4321
176
+ subject.integer = 1234
177
+ subject.save
178
+
179
+ retrieved = FullObject.find(subject.id)
180
+ retrieved.update(:integer => change_to)
181
+ retrieved.reload.integer.must_equal(change_to)
182
+ end
183
+
184
+ it "float" do
185
+ change_to = 4321.1234
186
+ subject.float = 1234.4321
187
+ subject.save
188
+
189
+ retrieved = FullObject.find(subject.id)
190
+ retrieved.update(:float => change_to)
191
+ retrieved.reload.float.must_equal(change_to)
192
+ end
193
+
194
+ it "decimal" do
195
+ change_to = 4321.1234
196
+ subject.decimal = 1234.4321
197
+ subject.save
198
+
199
+ retrieved = FullObject.find(subject.id)
200
+ retrieved.update(:decimal => change_to)
201
+ retrieved.reload.decimal.must_equal(change_to)
202
+ end
203
+
204
+ it "datetime" do
205
+ change_to = Time.new(2010).utc
206
+ subject.datetime = Time.current.utc
207
+ subject.save
208
+
209
+ retrieved = FullObject.find(subject.id)
210
+ retrieved.update(:datetime => change_to)
211
+ retrieved.reload.datetime.to_s.must_equal(change_to.to_s)
212
+ end
213
+
214
+ it "time" do
215
+ change_to = Time.new(2010).utc
216
+ subject.time = Time.current.utc
217
+ subject.save
218
+
219
+ retrieved = FullObject.find(subject.id)
220
+ retrieved.update(:time => change_to)
221
+ retrieved.reload.time.strftime("%H%M%S").must_equal(change_to.strftime("%H%M%S"))
222
+ end
223
+
224
+ it "date" do
225
+ change_to = Time.new(2010).utc
226
+ subject.date = Time.current
227
+ subject.save
228
+
229
+ retrieved = FullObject.find(subject.id)
230
+ retrieved.update(:date => change_to)
231
+ retrieved.reload.date.strftime("%Y%m%d").must_equal(change_to.strftime("%Y%m%d"))
232
+ end
233
+
234
+ it "boolean (false)" do
235
+ change_to = true
236
+ subject.boolean = false
237
+ subject.save
238
+
239
+ retrieved = FullObject.find(subject.id)
240
+ retrieved.update(:boolean => change_to)
241
+ retrieved.reload.boolean.must_equal(change_to)
242
+ end
243
+
244
+ it "boolean (true)" do
245
+ change_to = false
246
+ subject.boolean = true
247
+ subject.save
248
+
249
+ retrieved = FullObject.find(subject.id)
250
+ retrieved.update(:boolean => change_to)
251
+ retrieved.reload.boolean.must_equal(change_to)
252
+ end
253
+ end
254
+
255
+ describe "#update_all" do
256
+ it "boolean (false)" do
257
+ change_to = true
258
+ subject.boolean = false
259
+ subject.save
260
+
261
+ another = FullObject.new
262
+ another.boolean = false
263
+ another.save
264
+
265
+ FullObject.where(:boolean => false).count.must_equal(2)
266
+ FullObject.where(:boolean => false).update_all(:boolean => true)
267
+ FullObject.where(:boolean => false).count.must_equal(0)
268
+ FullObject.where(:boolean => true).count.must_equal(2)
269
+ end
270
+ end
271
+ end
@@ -0,0 +1,115 @@
1
+ require 'spec_helper'
2
+
3
+ class ColumnKing < ::ActiveRecord::Migration
4
+ def self.drop_kings
5
+ if table_exists?(:kings)
6
+ drop_table :kings
7
+ end
8
+ end
9
+
10
+ def self.up
11
+ create_table :kings do |t|
12
+ t.string :king_name_to_not_have_only_auto_increment_columns
13
+ end
14
+ end
15
+
16
+ def self.down
17
+ drop_table :kings
18
+ end
19
+ end
20
+
21
+ describe ColumnKing do
22
+ def columns
23
+ connection.columns(:kings)
24
+ end
25
+
26
+ def connection
27
+ ::ActiveRecord::Base.connection
28
+ end
29
+
30
+ def has_column?(name)
31
+ columns.any? { |column| column.name == "#{name}" }
32
+ end
33
+
34
+ def has_column_typed?(name, type)
35
+ !!(has_column?(name) &&
36
+ columns.find { |column| column.name == "#{name}" }.sql_type =~ type)
37
+ end
38
+
39
+ before do
40
+ ColumnKing.drop_kings
41
+ ColumnKing.up
42
+ end
43
+
44
+ describe "#add_column" do
45
+ it "throws an error if table does not exist" do
46
+ -> {
47
+ connection.add_column(:king2, :queen_id, :integer)
48
+ }.must_raise(ActiveRecord::StatementInvalid)
49
+ end
50
+
51
+ it "creates :integer columns" do
52
+ connection.add_column(:kings, :queen_id, :integer)
53
+ has_column?(:queen_id).must_equal(true)
54
+ has_column_typed?(:queen_id, /integer/i).must_equal(true)
55
+ end
56
+
57
+ it "creates :string columns (as varchar)" do
58
+ connection.add_column(:kings, :name, :string)
59
+ has_column?(:name).must_equal(true)
60
+ has_column_typed?(:name, /varchar/i).must_equal(true)
61
+ end
62
+
63
+ it "creates :text columns (as varchar columns)" do
64
+ connection.add_column(:kings, :lineage, :text)
65
+ has_column?(:lineage).must_equal(true)
66
+ has_column_typed?(:lineage, /varchar/i).must_equal(true)
67
+ end
68
+ end
69
+
70
+ describe "#column_exists?" do
71
+ it "is false if column not present" do
72
+ connection.column_exists?(:kings, :name).must_equal(false)
73
+ end
74
+
75
+ it "is true when column exists" do
76
+ connection.add_column(:kings, :name, :string)
77
+ connection.column_exists?(:kings, :name).must_equal(true)
78
+ end
79
+
80
+ it "is false when column types does not match declared type" do
81
+ connection.add_column(:kings, :name, :string)
82
+ connection.column_exists?(:kings, :name, :integer)
83
+ end
84
+
85
+ it "is false when column sql_type matches but declared type does not (like string/text)" do
86
+ connection.add_column(:kings, :name, :string)
87
+ connection.column_exists?(:kings, :name, :text)
88
+ end
89
+ end
90
+
91
+ describe "#remove_column" do
92
+ it "removes a column that is present" do
93
+ connection.add_column(:kings, :name, :string)
94
+ connection.column_exists?(:kings, :name).must_equal(true)
95
+ connection.remove_column(:kings, :name)
96
+ connection.column_exists?(:kings, :name).must_equal(false)
97
+ end
98
+
99
+ it "raises an error if column not present" do
100
+ -> {
101
+ connection.remove_column(:kings, :name)
102
+ }.must_raise(ActiveRecord::StatementInvalid)
103
+ end
104
+ end
105
+
106
+ describe "#rename_column" do
107
+ it "does not rename columns (JDBC)" do
108
+ connection.add_column(:kings, :name, :string)
109
+
110
+ -> {
111
+ connection.rename_column(:kings, :name, :name2)
112
+ }.must_raise(NotImplementedError)
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ class IndexKing < ::ActiveRecord::Migration
4
+ def self.drop_kings
5
+ if table_exists?(:kings)
6
+ drop_table :kings
7
+ end
8
+ end
9
+
10
+ def self.up
11
+ create_table :kings do |t|
12
+ t.string :king_name_to_not_have_only_auto_increment_columns
13
+ end
14
+ end
15
+
16
+ def self.down
17
+ drop_table :kings
18
+ end
19
+ end
20
+
21
+ # Vertica does not support "indexing" it uses Projections
22
+ # and those must be created differently
23
+ #
24
+ describe IndexKing do
25
+ def connection
26
+ ::ActiveRecord::Base.connection
27
+ end
28
+
29
+ before do
30
+ IndexKing.drop_kings
31
+ end
32
+
33
+ describe "#add_index" do
34
+ it "throws an error .... always" do
35
+ -> {
36
+ connection.add_index(:kings, "id")
37
+ }.must_raise(ActiveRecord::StatementInvalid)
38
+ end
39
+ end
40
+
41
+ describe "#index_exists?" do
42
+ it "always says false" do
43
+ connection.index_exists?(:kings, :id).must_equal(false)
44
+ connection.index_exists?(:kings, [ :id, :not_id ]).must_equal(false)
45
+ end
46
+ end
47
+
48
+ describe "#remove_index" do
49
+ it "throws an error .... always" do
50
+ -> {
51
+ connection.remove_index(:kings, "id")
52
+ }.must_raise(ArgumentError)
53
+ end
54
+ end
55
+
56
+ describe "#rename_index" do
57
+ it "throws an error .... always" do
58
+ -> {
59
+ connection.rename_index(:kings, "id", "derp")
60
+ }.must_raise(ArgumentError)
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+
3
+ class TableKing < ::ActiveRecord::Migration
4
+ def self.drop_kings
5
+ if table_exists?(:kings)
6
+ drop_table :kings
7
+ end
8
+ end
9
+
10
+ def self.up
11
+ create_table :kings do |t|
12
+ t.string :king_name_to_not_have_only_auto_increment_columns
13
+ end
14
+ end
15
+
16
+ def self.down
17
+ drop_table :kings
18
+ end
19
+ end
20
+
21
+ describe ::TableKing do
22
+ def connection
23
+ ::ActiveRecord::Base.connection
24
+ end
25
+
26
+ before do
27
+ ::TableKing.drop_kings
28
+ end
29
+
30
+ describe "#create_table" do
31
+ it "creates a table in the schema with create_table" do
32
+ connection.tables.wont_include("kings")
33
+ ::TableKing.up
34
+ connection.tables.must_include("kings")
35
+ ::TableKing.down
36
+ connection.tables.wont_include("kings")
37
+ end
38
+ end
39
+
40
+ describe "#drop_table" do
41
+ it "drops a table in the schema with drop_table" do
42
+ connection.tables.wont_include("kings")
43
+ ::TableKing.up
44
+ connection.tables.must_include("kings")
45
+ ::TableKing.down
46
+ connection.tables.wont_include("kings")
47
+ end
48
+ end
49
+
50
+ describe "#rename_table" do
51
+ it "renames a table" do
52
+ -> {
53
+ connection.rename_table("kings", "king_slayers")
54
+ }.must_raise(NotImplementedError)
55
+ end
56
+ end
57
+
58
+ describe "#table_exists?" do
59
+ it "returns false if table not present" do
60
+ connection.table_exists?("kings").must_equal(false)
61
+ end
62
+
63
+ it "returns true if table is present" do
64
+ connection.table_exists?("kings").must_equal(false)
65
+ ::TableKing.up
66
+ connection.table_exists?("kings").must_equal(true)
67
+ ::TableKing.down
68
+ connection.table_exists?("kings").must_equal(false)
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.require(:default, :development, :test)
4
+
5
+ require 'minitest/mock'
6
+ require 'minitest/spec'
7
+ require 'minitest/autorun'
8
+ require 'minitest/pride'
9
+
10
+ require 'mocha/api'
11
+
12
+ config = YAML.load_file(File.dirname(File.expand_path(__FILE__)) + "/test_connection.yml")
13
+
14
+ ActiveRecord::Base.establish_connection(
15
+ config['development']
16
+ )
metadata ADDED
@@ -0,0 +1,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activerecord-jdbcvertica-adapter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Brandon Dewitt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ requirement: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - '>='
23
+ - !ruby/object:Gem::Version
24
+ version: '0'
25
+ prerelease: false
26
+ type: :runtime
27
+ - !ruby/object:Gem::Dependency
28
+ name: activerecord-jdbc-adapter
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ prerelease: false
40
+ type: :runtime
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ prerelease: false
54
+ type: :development
55
+ - !ruby/object:Gem::Dependency
56
+ name: mocha
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ prerelease: false
68
+ type: :development
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ prerelease: false
82
+ type: :development
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirement: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ prerelease: false
96
+ type: :development
97
+ description: ' An ActiveRecord adapter for Vertica databases (jdbc based) '
98
+ email:
99
+ - brandonsdewitt@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - Gemfile
106
+ - LICENSE.txt
107
+ - README.md
108
+ - Rakefile
109
+ - activerecord-jdbcvertica-adapter.gemspec
110
+ - lib/active_record/connection_adapters/vertica5_adapter.rb
111
+ - lib/active_record/connection_adapters/vertica6_adapter.rb
112
+ - lib/active_record/connection_adapters/vertica7_adapter.rb
113
+ - lib/activerecord-jdbcvertica-adapter.rb
114
+ - lib/activerecord-jdbcvertica-adapter/jars/vertica-jdbc-7.0.0-0.jar
115
+ - lib/activerecord-jdbcvertica-adapter/jars/vertica-jdk5-6.1.3-0.jar
116
+ - lib/activerecord-jdbcvertica-adapter/version.rb
117
+ - lib/arjdbc/vertica.rb
118
+ - lib/arjdbc/vertica/adapter.rb
119
+ - lib/arjdbc/vertica/connection_methods.rb
120
+ - spec/full_object_spec.rb
121
+ - spec/migrations/column_spec.rb
122
+ - spec/migrations/index_spec.rb
123
+ - spec/migrations/table_spec.rb
124
+ - spec/spec_helper.rb
125
+ homepage: ''
126
+ licenses: []
127
+ metadata: {}
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.1.9
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: An ActiveRecord adapter JDBC
148
+ test_files:
149
+ - spec/full_object_spec.rb
150
+ - spec/migrations/column_spec.rb
151
+ - spec/migrations/index_spec.rb
152
+ - spec/migrations/table_spec.rb
153
+ - spec/spec_helper.rb