sequel-vertica 0.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/.gitignore +19 -0
- data/Gemfile +4 -0
- data/Rakefile +13 -0
- data/Readme.md +16 -0
- data/lib/sequel-vertica.rb +4 -0
- data/lib/sequel-vertica/version.rb +5 -0
- data/lib/sequel/adapters/vertica.rb +110 -0
- data/sequel-vertica.gemspec +21 -0
- data/spec/adapters/spec_helper.rb +54 -0
- data/spec/adapters/vertica_spec.rb +284 -0
- data/spec/spec_config.example.rb +1 -0
- data/spec/spec_helper.rb +0 -0
- metadata +90 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
desc 'Default: run specs.'
|
7
|
+
task :default => :spec
|
8
|
+
|
9
|
+
desc "Run specs"
|
10
|
+
RSpec::Core::RakeTask.new #do |t|
|
11
|
+
#t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
|
12
|
+
# Put spec opts in a file named .rspec in root
|
13
|
+
#end
|
data/Readme.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
## Sequel-vertica
|
2
|
+
|
3
|
+
A third party adapter to use Vertica through sequel, most of the actual work is
|
4
|
+
done by sequel and the vertica gem.
|
5
|
+
|
6
|
+
# Usage
|
7
|
+
|
8
|
+
The usage is straight forward as any other Sequel adapter, just make sure to
|
9
|
+
require sequel and the sequel-vertica gem.
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
require 'sequel'
|
13
|
+
require 'sequel-vertica'
|
14
|
+
|
15
|
+
$DB = Sequel.connect('vertica://user:pw@host/database_name')
|
16
|
+
```
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'vertica'
|
2
|
+
|
3
|
+
module Sequel
|
4
|
+
module Vertica
|
5
|
+
class Database < Sequel::Database
|
6
|
+
::Vertica::Connection.send(:alias_method,:execute, :query)
|
7
|
+
PK_NAME = 'C_PRIMARY'
|
8
|
+
set_adapter_scheme :vertica
|
9
|
+
|
10
|
+
def connect(server)
|
11
|
+
opts = server_opts(server)
|
12
|
+
::Vertica::Connection.new(
|
13
|
+
:host => opts[:host],
|
14
|
+
:user => opts[:user],
|
15
|
+
:password => opts[:password],
|
16
|
+
:port => opts[:port],
|
17
|
+
:schema => opts[:schema],
|
18
|
+
:database => opts[:database],
|
19
|
+
:ssl => opts[:ssl] )
|
20
|
+
end
|
21
|
+
|
22
|
+
def execute(sql, opts = {}, &block)
|
23
|
+
synchronize(opts[:server]) do |conn|
|
24
|
+
res = conn.query(sql)
|
25
|
+
res.each(&block)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def execute_insert(sql, opts = {}, &block)
|
30
|
+
result = execute(sql, opts, &block)
|
31
|
+
result.first[:OUTPUT]
|
32
|
+
end
|
33
|
+
|
34
|
+
alias_method :execute_dui, :execute
|
35
|
+
|
36
|
+
def supports_create_table_if_not_exists?
|
37
|
+
true
|
38
|
+
end
|
39
|
+
|
40
|
+
def supports_drop_table_if_exists?
|
41
|
+
true
|
42
|
+
end
|
43
|
+
|
44
|
+
def supports_transaction_isolation_levels?
|
45
|
+
true
|
46
|
+
end
|
47
|
+
|
48
|
+
def identifier_input_method_default
|
49
|
+
nil
|
50
|
+
end
|
51
|
+
|
52
|
+
def identifier_output_method_default
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
|
56
|
+
def locks
|
57
|
+
dataset.from(:v_monitor__locks)
|
58
|
+
end
|
59
|
+
|
60
|
+
def tables(options = {} )
|
61
|
+
schema = options[:schema]
|
62
|
+
filter = {}
|
63
|
+
filter[:table_schema] = schema.to_s if schema
|
64
|
+
|
65
|
+
ds = dataset.select(:table_name).from(:v_catalog__tables).
|
66
|
+
filter(filter)
|
67
|
+
|
68
|
+
ds.to_a.map{ |h| h[:table_name].to_sym }
|
69
|
+
end
|
70
|
+
|
71
|
+
def schema_parse_table(table_name, options = {})
|
72
|
+
schema = options[:schema]
|
73
|
+
|
74
|
+
selector = [:column_name, :constraint_name, :is_nullable.as(:allow_null),
|
75
|
+
(:column_default).as(:default), (:data_type).as(:db_type)]
|
76
|
+
filter = { :table_name => table_name }
|
77
|
+
filter [:table_schema] = schema.to_s if schema
|
78
|
+
|
79
|
+
dataset = metadata_dataset.select(*selector).filter(filter).
|
80
|
+
from(:v_catalog__columns).left_outer_join(:v_catalog__table_constraints, :table_id => :table_id)
|
81
|
+
|
82
|
+
dataset.map do |row|
|
83
|
+
row[:default] = nil if blank_object?(row[:default])
|
84
|
+
row[:type] = schema_column_type(row[:db_type])
|
85
|
+
row[:primary_key] = row.delete(:constraint_name) == PK_NAME
|
86
|
+
[row.delete(:column_name).to_sym, row]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
class Dataset < Sequel::Dataset
|
93
|
+
Database::DatasetClass = self
|
94
|
+
EXPLAIN = 'EXPLAIN '
|
95
|
+
EXPLAIN_LOCAL = 'EXPLAIN LOCAL '
|
96
|
+
QUERY_PLAN = 'QUERY PLAN'
|
97
|
+
|
98
|
+
def fetch_rows(sql)
|
99
|
+
execute(sql) do |row|
|
100
|
+
@columns ||= row.keys
|
101
|
+
yield row
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def explain(opts={})
|
106
|
+
execute((opts[:local] ? EXPLAIN_LOCAL : EXPLAIN) + select_sql).map{ |k, v| k == QUERY_PLAN }.join("\$")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/sequel-vertica/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Camilo Lopez"]
|
6
|
+
gem.email = ["camilo@camilolopez.com"]
|
7
|
+
gem.description = %q{Sequel adapter for the Vertica database}
|
8
|
+
gem.summary = %q{Sequel adapter for the Vertica database largely based on the PostgreSQL adapter}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.add_development_dependency "rspec"
|
12
|
+
gem.add_runtime_dependency "sequel"
|
13
|
+
gem.add_runtime_dependency "vertica"
|
14
|
+
|
15
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
gem.files = `git ls-files`.split("\n")
|
17
|
+
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
18
|
+
gem.name = "sequel-vertica"
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
gem.version = Sequel::Vertica::VERSION
|
21
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'logger'
|
3
|
+
unless Object.const_defined?('Sequel')
|
4
|
+
$:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../../lib/"))
|
5
|
+
require 'sequel'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'spec_config.rb')
|
9
|
+
rescue LoadError
|
10
|
+
end
|
11
|
+
|
12
|
+
if ENV['SEQUEL_COLUMNS_INTROSPECTION']
|
13
|
+
Sequel.extension :columns_introspection
|
14
|
+
Sequel::Dataset.introspect_all_columns
|
15
|
+
end
|
16
|
+
|
17
|
+
Sequel::Model.cache_anonymous_models = false
|
18
|
+
|
19
|
+
class Sequel::Database
|
20
|
+
def log_duration(duration, message)
|
21
|
+
log_info(message)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
(defined?(RSpec) ? RSpec::Core::ExampleGroup : Spec::Example::ExampleGroup).class_eval do
|
26
|
+
def log
|
27
|
+
begin
|
28
|
+
INTEGRATION_DB.loggers << Logger.new(STDOUT)
|
29
|
+
yield
|
30
|
+
ensure
|
31
|
+
INTEGRATION_DB.loggers.pop
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.cspecify(message, *checked, &block)
|
36
|
+
return specify(message, &block) if ENV['SEQUEL_NO_PENDING']
|
37
|
+
pending = false
|
38
|
+
checked.each do |c|
|
39
|
+
case c
|
40
|
+
when INTEGRATION_DB.adapter_scheme
|
41
|
+
pending = c
|
42
|
+
when Proc
|
43
|
+
pending = c if c.first.call(INTEGRATION_DB)
|
44
|
+
when Array
|
45
|
+
pending = c if c.first == INTEGRATION_DB.adapter_scheme && c.last == INTEGRATION_DB.call(INTEGRATION_DB)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
if pending
|
49
|
+
specify(message){pending("Not yet working on #{Array(pending).join(', ')}", &block)}
|
50
|
+
else
|
51
|
+
specify(message, &block)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,284 @@
|
|
1
|
+
require File.join(File.dirname(File.expand_path(__FILE__)), 'spec_helper.rb')
|
2
|
+
|
3
|
+
unless defined?(VERTICA_DB)
|
4
|
+
VERTICA_URL = 'vertica://vertica:vertica@localhost:5432/reality_spec' unless defined? VERTICA_URL
|
5
|
+
VERTICA_DB = Sequel.connect(ENV['SEQUEL_VERTICA_SPEC_DB']||VERTICA_URL)
|
6
|
+
end
|
7
|
+
INTEGRATION_DB = VERTICA_DB unless defined?(INTEGRATION_DB)
|
8
|
+
|
9
|
+
def VERTICA_DB.sqls
|
10
|
+
(@sqls ||= [])
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
VERTICA_DB.create_table! :test do
|
15
|
+
varchar :name
|
16
|
+
integer :value
|
17
|
+
end
|
18
|
+
VERTICA_DB.create_table! :test2 do
|
19
|
+
varchar :name
|
20
|
+
integer :value
|
21
|
+
end
|
22
|
+
VERTICA_DB.create_table! :test3 do
|
23
|
+
integer :value
|
24
|
+
timestamp :time
|
25
|
+
end
|
26
|
+
VERTICA_DB.create_table! :test4 do
|
27
|
+
varchar :name, :size => 20
|
28
|
+
bytea :value
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "A Vertica database" do
|
32
|
+
|
33
|
+
before do
|
34
|
+
@db = VERTICA_DB
|
35
|
+
end
|
36
|
+
|
37
|
+
specify "should correctly parse the schema" do
|
38
|
+
@db.schema(:test3, :reload=>true).should == [
|
39
|
+
[:value, {:type=>:integer, :allow_null=>true, :default=>nil, :ruby_default=>nil, :db_type=>"int", :primary_key=>false}],
|
40
|
+
[:time, {:type=>:datetime, :allow_null=>true, :default=>nil, :ruby_default=>nil, :db_type=>"timestamp", :primary_key=>false}]
|
41
|
+
]
|
42
|
+
@db.schema(:test4, :reload=>true).should == [
|
43
|
+
[:name, {:type=>:string, :allow_null=>true, :default=>nil, :ruby_default=>nil, :db_type=>"varchar(20)", :primary_key=>false}],
|
44
|
+
[:value, {:type=>:blob, :allow_null=>true, :default=>nil, :ruby_default=>nil, :db_type=>"varbinary(80)", :primary_key=>false}]
|
45
|
+
]
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "A vertica dataset" do
|
51
|
+
before do
|
52
|
+
@d = VERTICA_DB[:test]
|
53
|
+
@d.delete if @d.count > 0 # Vertica will throw an error if the table has just been created and does not have a super projection yet.
|
54
|
+
end
|
55
|
+
|
56
|
+
specify "should quote columns and tables using double quotes if quoting identifiers" do
|
57
|
+
@d.select(:name).sql.should == \
|
58
|
+
'SELECT "name" FROM "test"'
|
59
|
+
|
60
|
+
@d.select('COUNT(*)'.lit).sql.should == \
|
61
|
+
'SELECT COUNT(*) FROM "test"'
|
62
|
+
|
63
|
+
@d.select(:max.sql_function(:value)).sql.should == \
|
64
|
+
'SELECT max("value") FROM "test"'
|
65
|
+
|
66
|
+
@d.select(:NOW.sql_function).sql.should == \
|
67
|
+
'SELECT NOW() FROM "test"'
|
68
|
+
|
69
|
+
@d.select(:max.sql_function(:items__value)).sql.should == \
|
70
|
+
'SELECT max("items"."value") FROM "test"'
|
71
|
+
|
72
|
+
@d.order(:name.desc).sql.should == \
|
73
|
+
'SELECT * FROM "test" ORDER BY "name" DESC'
|
74
|
+
|
75
|
+
@d.select('test.name AS item_name'.lit).sql.should == \
|
76
|
+
'SELECT test.name AS item_name FROM "test"'
|
77
|
+
|
78
|
+
@d.select('"name"'.lit).sql.should == \
|
79
|
+
'SELECT "name" FROM "test"'
|
80
|
+
|
81
|
+
@d.select('max(test."name") AS "max_name"'.lit).sql.should == \
|
82
|
+
'SELECT max(test."name") AS "max_name" FROM "test"'
|
83
|
+
|
84
|
+
@d.insert_sql(:x => :y).should =~ \
|
85
|
+
/\AINSERT INTO "test" \("x"\) VALUES \("y"\)( RETURNING NULL)?\z/
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
specify "should quote fields correctly when reversing the order if quoting identifiers" do
|
90
|
+
@d.reverse_order(:name).sql.should == \
|
91
|
+
'SELECT * FROM "test" ORDER BY "name" DESC'
|
92
|
+
|
93
|
+
@d.reverse_order(:name.desc).sql.should == \
|
94
|
+
'SELECT * FROM "test" ORDER BY "name" ASC'
|
95
|
+
|
96
|
+
@d.reverse_order(:name, :test.desc).sql.should == \
|
97
|
+
'SELECT * FROM "test" ORDER BY "name" DESC, "test" ASC'
|
98
|
+
|
99
|
+
@d.reverse_order(:name.desc, :test).sql.should == \
|
100
|
+
'SELECT * FROM "test" ORDER BY "name" ASC, "test" DESC'
|
101
|
+
end
|
102
|
+
|
103
|
+
specify "should support regexps" do
|
104
|
+
@d << {:name => 'abc', :value => 1}
|
105
|
+
@d << {:name => 'bcd', :value => 2}
|
106
|
+
|
107
|
+
@d.filter(:name => /bc/).count.should == 2
|
108
|
+
@d.filter(:name => /^bc/).count.should == 1
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
describe "A Vertica dataset with a timestamp field" do
|
115
|
+
before do
|
116
|
+
@db = VERTICA_DB
|
117
|
+
@d = @db[:test3]
|
118
|
+
@d.delete if @d.count > 0 # Vertica will throw an error if the table has just been created and does not have a super projection yet.
|
119
|
+
end
|
120
|
+
after do
|
121
|
+
@db.convert_infinite_timestamps = false if @db.adapter_scheme == :postgres
|
122
|
+
end
|
123
|
+
|
124
|
+
cspecify "should store milliseconds in time fields for Time objects", :do, :swift do
|
125
|
+
t = Time.now
|
126
|
+
@d << {:value=>1, :time=>t}
|
127
|
+
t2 = @d[:value =>1][:time]
|
128
|
+
@d.literal(t2).should == @d.literal(t)
|
129
|
+
t2.strftime('%Y-%m-%d %H:%M:%S').should == t.strftime('%Y-%m-%d %H:%M:%S')
|
130
|
+
(t2.is_a?(Time) ? t2.usec : t2.strftime('%N').to_i/1000).should == t.usec
|
131
|
+
end
|
132
|
+
|
133
|
+
cspecify "should store milliseconds in time fields for DateTime objects", :do, :swift do
|
134
|
+
t = DateTime.now
|
135
|
+
@d << {:value=>1, :time=>t}
|
136
|
+
t2 = @d[:value =>1][:time]
|
137
|
+
@d.literal(t2).should == @d.literal(t)
|
138
|
+
t2.strftime('%Y-%m-%d %H:%M:%S').should == t.strftime('%Y-%m-%d %H:%M:%S')
|
139
|
+
(t2.is_a?(Time) ? t2.usec : t2.strftime('%N').to_i/1000).should == t.strftime('%N').to_i/1000
|
140
|
+
end
|
141
|
+
|
142
|
+
describe "Verticas's EXPLAIN and EXPLAIN LOCAL" do
|
143
|
+
specify "should not raise errors" do
|
144
|
+
@d = VERTICA_DB[:test3]
|
145
|
+
proc{@d.explain}.should_not raise_error
|
146
|
+
proc{@d.explain(:local => true)}.should_not raise_error
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
describe "A Vertica database" do
|
154
|
+
before do
|
155
|
+
@db = VERTICA_DB
|
156
|
+
end
|
157
|
+
|
158
|
+
specify "should support column operations" do
|
159
|
+
@db.create_table!(:test2){varchar :name; integer :value}
|
160
|
+
@db[:test2] << {}
|
161
|
+
@db[:test2].columns.should == [:name, :value]
|
162
|
+
|
163
|
+
@db.add_column :test2, :xyz, :varchar, :default => '000'
|
164
|
+
@db[:test2].columns.should == [:name, :value, :xyz]
|
165
|
+
@db[:test2] << {:name => 'mmm', :value => 111}
|
166
|
+
@db[:test2].first[:xyz].should == '000'
|
167
|
+
|
168
|
+
@db[:test2].columns.should == [:name, :value, :xyz]
|
169
|
+
proc{ @db.drop_column :test2, :xyz }.should raise_error(Vertica::Error::QueryError,
|
170
|
+
/ALTER TABLE DROP COLUMN not supported/)
|
171
|
+
|
172
|
+
@db[:test2].columns.should ==[:name, :value, :xyz]
|
173
|
+
|
174
|
+
@db[:test2].delete
|
175
|
+
@db.add_column :test2, :xyz2, :varchar, :default => '000'
|
176
|
+
@db[:test2] << {:name => 'mmm', :value => 111, :xyz2 => 'qqqq'}
|
177
|
+
|
178
|
+
@db[:test2].columns.should == [:name, :value, :xyz, :xyz2]
|
179
|
+
@db.rename_column :test2, :xyz, :zyx
|
180
|
+
@db[:test2].columns.should == [:name, :value, :zyx, :xyz2]
|
181
|
+
@db[:test2].first[:xyz2].should == 'qqqq'
|
182
|
+
|
183
|
+
@db.add_column :test2, :xyz, :float
|
184
|
+
@db[:test2].delete
|
185
|
+
@db[:test2] << {:name => 'mmm', :value => 111, :xyz => 56.78}
|
186
|
+
|
187
|
+
proc{ @db.set_column_type :test2, :xyz, :integer }.should raise_error(Vertica::Error::QueryError,
|
188
|
+
/ALTER TABLE ALTER COLUMN not supported/)
|
189
|
+
end
|
190
|
+
|
191
|
+
specify "#locks should be a dataset returning database locks " do
|
192
|
+
@db.locks.should be_a_kind_of(Sequel::Dataset)
|
193
|
+
@db.locks.all.should be_a_kind_of(Array)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
describe "Vertica::Dataset#insert" do
|
198
|
+
before do
|
199
|
+
@db = VERTICA_DB
|
200
|
+
@db.create_table!(:test5){ :xid; Integer :value}
|
201
|
+
@db.sqls.clear
|
202
|
+
@ds = @db[:test5]
|
203
|
+
end
|
204
|
+
|
205
|
+
after do
|
206
|
+
@db.drop_table?(:test5)
|
207
|
+
end
|
208
|
+
|
209
|
+
specify "should work with static SQL" do
|
210
|
+
@ds.with_sql('INSERT INTO test5 (value) VALUES (10)').insert.should == 1
|
211
|
+
@db['INSERT INTO test5 (value) VALUES (20)'].insert.should == 1
|
212
|
+
@ds.all.should == [{:value=>10}, {:value=>20}]
|
213
|
+
end
|
214
|
+
|
215
|
+
specify "should insert correctly if using a column array and a value array" do
|
216
|
+
@ds.insert([:value], [10]).should == 1
|
217
|
+
@ds.all.should == [{:value=>10}]
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe "Vertica::Database schema qualified tables" do
|
222
|
+
before do
|
223
|
+
VERTICA_DB << "CREATE SCHEMA schema_test"
|
224
|
+
VERTICA_DB.instance_variable_set(:@primary_keys, {})
|
225
|
+
VERTICA_DB.instance_variable_set(:@primary_key_sequences, {})
|
226
|
+
end
|
227
|
+
|
228
|
+
after do
|
229
|
+
VERTICA_DB << "DROP SCHEMA schema_test CASCADE"
|
230
|
+
VERTICA_DB.default_schema = nil
|
231
|
+
end
|
232
|
+
|
233
|
+
specify "should be able to create, drop, select and insert into tables in a given schema" do
|
234
|
+
VERTICA_DB.create_table(:schema_test__table_in_schema_test){integer :i}
|
235
|
+
VERTICA_DB[:schema_test__table_in_schema_test].first.should == nil
|
236
|
+
VERTICA_DB[:schema_test__table_in_schema_test].insert(:i=>1).should == 1
|
237
|
+
VERTICA_DB[:schema_test__table_in_schema_test].first.should == {:i=>1}
|
238
|
+
VERTICA_DB.from('schema_test.table_in_schema_test'.lit).first.should == {:i=>1}
|
239
|
+
VERTICA_DB.drop_table(:schema_test__table_in_schema_test)
|
240
|
+
VERTICA_DB.create_table(:table_in_schema_test.qualify(:schema_test)){integer :i}
|
241
|
+
VERTICA_DB[:schema_test__table_in_schema_test].first.should == nil
|
242
|
+
VERTICA_DB.from('schema_test.table_in_schema_test'.lit).first.should == nil
|
243
|
+
VERTICA_DB.drop_table(:table_in_schema_test.qualify(:schema_test))
|
244
|
+
end
|
245
|
+
|
246
|
+
specify "#tables should not include tables in a default non-public schema" do
|
247
|
+
VERTICA_DB.create_table(:schema_test__table_in_schema_test){integer :i}
|
248
|
+
VERTICA_DB.tables.should include(:table_in_schema_test)
|
249
|
+
VERTICA_DB.tables.should_not include(:tables)
|
250
|
+
VERTICA_DB.tables.should_not include(:columns)
|
251
|
+
VERTICA_DB.tables.should_not include(:locks)
|
252
|
+
VERTICA_DB.tables.should_not include(:domain_udt_usage)
|
253
|
+
end
|
254
|
+
|
255
|
+
specify "#tables should return tables in the schema provided by the :schema argument" do
|
256
|
+
VERTICA_DB.create_table(:schema_test__table_in_schema_test){integer :i}
|
257
|
+
VERTICA_DB.tables(:schema=>:schema_test).should == [:table_in_schema_test]
|
258
|
+
end
|
259
|
+
|
260
|
+
specify "#schema should not include columns from tables in a default non-public schema" do
|
261
|
+
VERTICA_DB.create_table(:schema_test__domains){integer :i}
|
262
|
+
sch = VERTICA_DB.schema(:domains)
|
263
|
+
cs = sch.map{|x| x.first}
|
264
|
+
cs.should include(:i)
|
265
|
+
cs.should_not include(:data_type)
|
266
|
+
end
|
267
|
+
|
268
|
+
specify "#schema should only include columns from the table in the given :schema argument" do
|
269
|
+
VERTICA_DB.create_table!(:domains){integer :d}
|
270
|
+
VERTICA_DB.create_table(:schema_test__domains){integer :i}
|
271
|
+
sch = VERTICA_DB.schema(:domains, :schema=>:schema_test)
|
272
|
+
cs = sch.map{|x| x.first}
|
273
|
+
cs.should include(:i)
|
274
|
+
cs.should_not include(:d)
|
275
|
+
VERTICA_DB.drop_table(:domains)
|
276
|
+
end
|
277
|
+
|
278
|
+
|
279
|
+
specify "#table_exists? should see if the table is in a given schema" do
|
280
|
+
VERTICA_DB.create_table(:schema_test__schema_test){integer :i}
|
281
|
+
VERTICA_DB.table_exists?(:schema_test__schema_test).should == true
|
282
|
+
end
|
283
|
+
|
284
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
VERTICA_URL = 'vertica://dbadmin:@192.168.56.101:5433/warehouse'
|
data/spec/spec_helper.rb
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sequel-vertica
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Camilo Lopez
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-06 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70287178230020 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70287178230020
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: sequel
|
27
|
+
requirement: &70287178229280 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70287178229280
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: vertica
|
38
|
+
requirement: &70287178228620 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70287178228620
|
47
|
+
description: Sequel adapter for the Vertica database
|
48
|
+
email:
|
49
|
+
- camilo@camilolopez.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- Rakefile
|
57
|
+
- Readme.md
|
58
|
+
- lib/sequel-vertica.rb
|
59
|
+
- lib/sequel-vertica/version.rb
|
60
|
+
- lib/sequel/adapters/vertica.rb
|
61
|
+
- sequel-vertica.gemspec
|
62
|
+
- spec/adapters/spec_helper.rb
|
63
|
+
- spec/adapters/vertica_spec.rb
|
64
|
+
- spec/spec_config.example.rb
|
65
|
+
- spec/spec_helper.rb
|
66
|
+
homepage: ''
|
67
|
+
licenses: []
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.8.10
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Sequel adapter for the Vertica database largely based on the PostgreSQL adapter
|
90
|
+
test_files: []
|