sequel-vertica 0.1.0 → 0.2.0
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.
- checksums.yaml +7 -0
- data/.rspec +1 -0
- data/.travis.yml +19 -0
- data/{Readme.md → README.md} +2 -2
- data/lib/sequel-vertica/version.rb +1 -1
- data/lib/sequel/adapters/vertica.rb +23 -19
- data/sequel-vertica.gemspec +11 -5
- data/spec/adapters/vertica_spec.rb +8 -9
- data/spec/spec_config.example.rb +1 -1
- data/spec/spec_helper.rb +55 -0
- metadata +46 -43
- data/spec/adapters/spec_helper.rb +0 -57
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 224357ab7df2bccbf853e1a34c7bc5f6b1c89ebb
|
4
|
+
data.tar.gz: 2480bc67b31e77b8291d2fa3198f8c0bbe1bc074
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e5f8fd7028e06c8d0e7e5d78eb60a237f490adff29fea5dff4c42e718f614e50a666c83d02c8bb049130c60b62a16784e12cbfbc694427663e1bea0b5d742ab
|
7
|
+
data.tar.gz: 672e91d04cd326dfa20f961f268a675381565a44a6cc44ea6b260c83983924143fe3b7b37ec3207f47c277809a3e5618e9118b77c9e17913d616aaf35482bcc0
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color --format doc
|
data/.travis.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.9.3
|
4
|
+
- 2.0.0
|
5
|
+
- 2.1.1
|
6
|
+
|
7
|
+
before_install:
|
8
|
+
- sudo wget -nv https://s3.amazonaws.com/circle-support-bucket/vertica_7.0.1-0_amd64.deb
|
9
|
+
- sudo dpkg -i vertica_7.0.1-0_amd64.deb
|
10
|
+
- sudo /opt/vertica/sbin/install_vertica --failure-threshold HALT --accept-eula --dba-user-password dbadmin --license CE -s localhost
|
11
|
+
- sudo -u dbadmin /opt/vertica/bin/adminTools -t create_db --database ci -s localhost -p dbadmin
|
12
|
+
# - sudo -u dbadmin openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /home/dbadmin/ci/v_ci_node0001_catalog/server.key -out /home/dbadmin/ci/v_ci_node0001_catalog/server.crt -batch
|
13
|
+
# - sudo -u dbadmin chmod 600 /home/dbadmin/ci/v_ci_node0001_catalog/server.key /home/dbadmin/ci/v_ci_node0001_catalog/server.crt
|
14
|
+
# - sudo -u dbadmin /opt/vertica/bin/adminTools -t stop_db --database ci -p dbadmin
|
15
|
+
# - sudo -u dbadmin sh -c 'echo "EnableSSL = 1" > /home/dbadmin/ci/v_ci_node0001_catalog/vertica.conf'
|
16
|
+
# - sudo -u dbadmin /opt/vertica/bin/adminTools -t start_db --database ci -p dbadmin
|
17
|
+
|
18
|
+
before_script:
|
19
|
+
- cp ./spec/spec_config.example.rb ./spec/spec_config.rb
|
data/{Readme.md → README.md}
RENAMED
@@ -1,9 +1,9 @@
|
|
1
|
-
|
1
|
+
# Sequel-vertica [](https://travis-ci.org/camilo/sequel-vertica)
|
2
2
|
|
3
3
|
A third party adapter to use Vertica through sequel, most of the actual work is
|
4
4
|
done by sequel and the vertica gem.
|
5
5
|
|
6
|
-
|
6
|
+
## Usage
|
7
7
|
|
8
8
|
The usage is straight forward as any other Sequel adapter, just make sure to
|
9
9
|
require sequel and the sequel-vertica gem.
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'vertica'
|
2
2
|
|
3
3
|
module Sequel
|
4
|
+
extension :core_extensions
|
4
5
|
module Vertica
|
5
6
|
|
6
7
|
class CreateTableGenerator < Sequel::Schema::CreateTableGenerator
|
@@ -18,7 +19,7 @@ module Sequel
|
|
18
19
|
|
19
20
|
class Database < Sequel::Database
|
20
21
|
|
21
|
-
::Vertica::Connection.send(:alias_method
|
22
|
+
::Vertica::Connection.send(:alias_method, :execute, :query)
|
22
23
|
|
23
24
|
PK_NAME = 'C_PRIMARY'
|
24
25
|
AUTO_INCREMENT = 'AUTO_INCREMENT'
|
@@ -33,7 +34,8 @@ module Sequel
|
|
33
34
|
:port => opts[:port],
|
34
35
|
:schema => opts[:schema],
|
35
36
|
:database => opts[:database],
|
36
|
-
:ssl => opts[:ssl]
|
37
|
+
:ssl => opts[:ssl]
|
38
|
+
)
|
37
39
|
end
|
38
40
|
|
39
41
|
def execute(sql, opts = {}, &block)
|
@@ -86,27 +88,31 @@ module Sequel
|
|
86
88
|
Vertica::CreateTableGenerator
|
87
89
|
end
|
88
90
|
|
89
|
-
def tables(options = {}
|
91
|
+
def tables(options = {})
|
90
92
|
schema = options[:schema]
|
91
93
|
filter = {}
|
92
94
|
filter[:table_schema] = schema.to_s if schema
|
93
95
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
96
|
+
dataset.select(:table_name).
|
97
|
+
from(:v_catalog__tables).
|
98
|
+
filter(filter).
|
99
|
+
to_a.
|
100
|
+
map { |h| h[:table_name].to_sym }
|
98
101
|
end
|
99
102
|
|
100
103
|
def schema_parse_table(table_name, options = {})
|
101
104
|
schema = options[:schema]
|
102
105
|
|
103
|
-
selector = [:column_name, :constraint_name, :is_nullable.as(:allow_null),
|
106
|
+
selector = [:column_name, :constraint_name, :is_nullable.as(:allow_null),
|
104
107
|
(:column_default).as(:default), (:data_type).as(:db_type)]
|
105
|
-
filter = { :
|
106
|
-
filter[:
|
108
|
+
filter = { :columns__table_name => table_name }
|
109
|
+
filter[:columns__table_schema] = schema.to_s if schema
|
107
110
|
|
108
|
-
dataset = metadata_dataset.
|
109
|
-
|
111
|
+
dataset = metadata_dataset.
|
112
|
+
select(*selector).
|
113
|
+
filter(filter).
|
114
|
+
from(:v_catalog__columns).
|
115
|
+
left_outer_join(:v_catalog__table_constraints, :table_id => :table_id)
|
110
116
|
|
111
117
|
dataset.map do |row|
|
112
118
|
row[:default] = nil if blank_object?(row[:default])
|
@@ -115,32 +121,30 @@ module Sequel
|
|
115
121
|
[row.delete(:column_name).to_sym, row]
|
116
122
|
end
|
117
123
|
end
|
118
|
-
|
119
124
|
end
|
120
125
|
|
121
126
|
class Dataset < Sequel::Dataset
|
122
127
|
Database::DatasetClass = self
|
123
128
|
EXPLAIN = 'EXPLAIN '
|
124
129
|
EXPLAIN_LOCAL = 'EXPLAIN LOCAL '
|
125
|
-
QUERY_PLAN = 'QUERY PLAN'
|
130
|
+
QUERY_PLAN = 'QUERY PLAN'
|
126
131
|
|
127
132
|
def columns
|
128
133
|
return @columns if @columns
|
129
|
-
ds = unfiltered.unordered.clone(:distinct => nil, :limit => 0, :offset=>nil)
|
134
|
+
ds = unfiltered.unordered.clone(:distinct => nil, :limit => 0, :offset => nil)
|
130
135
|
res = @db.execute(ds.select_sql)
|
131
136
|
@columns = res.columns.map { |c| c.name }
|
132
137
|
@columns
|
133
138
|
end
|
134
139
|
|
135
|
-
|
136
140
|
def fetch_rows(sql)
|
137
|
-
execute(sql) do |row|
|
138
|
-
yield row
|
141
|
+
execute(sql) do |row|
|
142
|
+
yield row
|
139
143
|
end
|
140
144
|
end
|
141
145
|
|
142
146
|
def explain(opts={})
|
143
|
-
execute((opts[:local] ? EXPLAIN_LOCAL : EXPLAIN) + select_sql).map{ |k, v| k == QUERY_PLAN }.join("\$")
|
147
|
+
execute((opts[:local] ? EXPLAIN_LOCAL : EXPLAIN) + select_sql).map { |k, v| k == QUERY_PLAN }.join("\$")
|
144
148
|
end
|
145
149
|
|
146
150
|
def supports_regexp?
|
data/sequel-vertica.gemspec
CHANGED
@@ -2,22 +2,28 @@
|
|
2
2
|
require File.expand_path('../lib/sequel-vertica/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "sequel-vertica"
|
6
|
+
gem.version = Sequel::Vertica::VERSION
|
7
|
+
|
5
8
|
gem.authors = ["Camilo Lopez"]
|
6
9
|
gem.email = ["camilo@camilolopez.com"]
|
7
10
|
gem.description = %q{Sequel adapter for the Vertica database}
|
8
11
|
gem.summary = %q{Sequel adapter for the Vertica database largely based on the PostgreSQL adapter}
|
9
12
|
gem.homepage = "https://github.com/camilo/sequel-vertica"
|
13
|
+
gem.license = "MIT"
|
10
14
|
|
11
15
|
gem.requirements = "Vertica version 6.0 or higher"
|
16
|
+
gem.required_ruby_version = '>= 1.9.3'
|
12
17
|
|
13
|
-
gem.
|
14
|
-
gem.add_runtime_dependency "
|
15
|
-
|
18
|
+
gem.add_runtime_dependency "sequel", "~> 4.9.0"
|
19
|
+
gem.add_runtime_dependency "vertica", "~> 0.11.0"
|
20
|
+
|
21
|
+
gem.add_development_dependency "rake", ">= 10"
|
22
|
+
gem.add_development_dependency "rspec" , "~> 2.14"
|
16
23
|
|
17
24
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
25
|
gem.files = `git ls-files`.split("\n")
|
19
26
|
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
20
|
-
|
27
|
+
|
21
28
|
gem.require_paths = ["lib"]
|
22
|
-
gem.version = Sequel::Vertica::VERSION
|
23
29
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
unless defined?(VERTICA_DB)
|
4
4
|
VERTICA_URL = 'vertica://vertica:vertica@localhost:5432/reality_spec' unless defined? VERTICA_URL
|
@@ -28,7 +28,7 @@ VERTICA_DB.create_table! :test4 do
|
|
28
28
|
bytea :value
|
29
29
|
end
|
30
30
|
|
31
|
-
describe "A Vertica database" do
|
31
|
+
describe "A Vertica database" do
|
32
32
|
|
33
33
|
before do
|
34
34
|
@db = VERTICA_DB
|
@@ -67,7 +67,7 @@ describe "A vertica dataset" do
|
|
67
67
|
@d.select(:name).sql.should == \
|
68
68
|
'SELECT "name" FROM "test"'
|
69
69
|
|
70
|
-
@d.select('COUNT(*)'
|
70
|
+
@d.select(Sequel.lit('COUNT(*)')).sql.should == \
|
71
71
|
'SELECT COUNT(*) FROM "test"'
|
72
72
|
|
73
73
|
@d.select(:max.sql_function(:value)).sql.should == \
|
@@ -82,13 +82,13 @@ describe "A vertica dataset" do
|
|
82
82
|
@d.order(:name.desc).sql.should == \
|
83
83
|
'SELECT * FROM "test" ORDER BY "name" DESC'
|
84
84
|
|
85
|
-
@d.select('test.name AS item_name'
|
85
|
+
@d.select(Sequel.lit('test.name AS item_name')).sql.should == \
|
86
86
|
'SELECT test.name AS item_name FROM "test"'
|
87
87
|
|
88
|
-
@d.select('"name"'
|
88
|
+
@d.select(Sequel.lit('"name"')).sql.should == \
|
89
89
|
'SELECT "name" FROM "test"'
|
90
90
|
|
91
|
-
@d.select('max(test."name") AS "max_name"'
|
91
|
+
@d.select(Sequel.lit('max(test."name") AS "max_name"')).sql.should == \
|
92
92
|
'SELECT max(test."name") AS "max_name" FROM "test"'
|
93
93
|
|
94
94
|
@d.insert_sql(:x => :y).should =~ \
|
@@ -239,7 +239,6 @@ describe "Vertica::Database schema qualified tables" do
|
|
239
239
|
|
240
240
|
after do
|
241
241
|
VERTICA_DB << "DROP SCHEMA schema_test CASCADE"
|
242
|
-
VERTICA_DB.default_schema = nil
|
243
242
|
end
|
244
243
|
|
245
244
|
specify "should be able to create, drop, select and insert into tables in a given schema" do
|
@@ -247,11 +246,11 @@ describe "Vertica::Database schema qualified tables" do
|
|
247
246
|
VERTICA_DB[:schema_test__table_in_schema_test].first.should == nil
|
248
247
|
VERTICA_DB[:schema_test__table_in_schema_test].insert(:i=>1).should == 1
|
249
248
|
VERTICA_DB[:schema_test__table_in_schema_test].first.should == {:i=>1}
|
250
|
-
VERTICA_DB.from('schema_test.table_in_schema_test'
|
249
|
+
VERTICA_DB.from(Sequel.lit('schema_test.table_in_schema_test')).first.should == {:i=>1}
|
251
250
|
VERTICA_DB.drop_table(:schema_test__table_in_schema_test)
|
252
251
|
VERTICA_DB.create_table(:table_in_schema_test.qualify(:schema_test)){integer :i}
|
253
252
|
VERTICA_DB[:schema_test__table_in_schema_test].first.should == nil
|
254
|
-
VERTICA_DB.from('schema_test.table_in_schema_test'
|
253
|
+
VERTICA_DB.from(Sequel.lit('schema_test.table_in_schema_test')).first.should == nil
|
255
254
|
VERTICA_DB.drop_table(:table_in_schema_test.qualify(:schema_test))
|
256
255
|
end
|
257
256
|
|
data/spec/spec_config.example.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
VERTICA_URL = 'vertica://dbadmin
|
1
|
+
VERTICA_URL = 'vertica://dbadmin:dbadmin@127.0.0.1:5433/ci'
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'logger'
|
3
|
+
require 'sequel'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'spec_config'
|
7
|
+
rescue LoadError
|
8
|
+
$stderr.puts "Please create a file spec/spec_config.rb with a database connection string."
|
9
|
+
raise
|
10
|
+
end
|
11
|
+
|
12
|
+
if ENV['SEQUEL_COLUMNS_INTROSPECTION']
|
13
|
+
Sequel.extension :columns_introspection
|
14
|
+
Sequel::Dataset.introspect_all_columns
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
Sequel.cache_anonymous_models = false
|
19
|
+
|
20
|
+
class Sequel::Database
|
21
|
+
def log_duration(duration, message)
|
22
|
+
log_info(message)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
(defined?(RSpec) ? RSpec::Core::ExampleGroup : Spec::Example::ExampleGroup).class_eval do
|
27
|
+
def log
|
28
|
+
begin
|
29
|
+
INTEGRATION_DB.loggers << Logger.new(STDOUT)
|
30
|
+
yield
|
31
|
+
ensure
|
32
|
+
INTEGRATION_DB.loggers.pop
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.cspecify(message, *checked, &block)
|
37
|
+
return specify(message, &block) if ENV['SEQUEL_NO_PENDING']
|
38
|
+
pending = false
|
39
|
+
checked.each do |c|
|
40
|
+
case c
|
41
|
+
when INTEGRATION_DB.adapter_scheme
|
42
|
+
pending = c
|
43
|
+
when Proc
|
44
|
+
pending = c if c.first.call(INTEGRATION_DB)
|
45
|
+
when Array
|
46
|
+
pending = c if c.first == INTEGRATION_DB.adapter_scheme && c.last == INTEGRATION_DB.call(INTEGRATION_DB)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
if pending
|
50
|
+
specify(message){pending("Not yet working on #{Array(pending).join(', ')}", &block)}
|
51
|
+
else
|
52
|
+
specify(message, &block)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
metadata
CHANGED
@@ -1,64 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel-vertica
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.1.0
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Camilo Lopez
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-04-14 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
name: sequel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.9.0
|
20
|
+
type: :runtime
|
15
21
|
prerelease: false
|
16
|
-
name: rspec
|
17
|
-
type: :development
|
18
22
|
version_requirements: !ruby/object:Gem::Requirement
|
19
23
|
requirements:
|
20
|
-
- -
|
24
|
+
- - ~>
|
21
25
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
23
|
-
|
26
|
+
version: 4.9.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: vertica
|
24
29
|
requirement: !ruby/object:Gem::Requirement
|
25
30
|
requirements:
|
26
|
-
- -
|
31
|
+
- - ~>
|
27
32
|
- !ruby/object:Gem::Version
|
28
|
-
version:
|
29
|
-
none: false
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
prerelease: false
|
32
|
-
name: sequel
|
33
|
+
version: 0.11.0
|
33
34
|
type: :runtime
|
35
|
+
prerelease: false
|
34
36
|
version_requirements: !ruby/object:Gem::Requirement
|
35
37
|
requirements:
|
36
38
|
- - ~>
|
37
39
|
- !ruby/object:Gem::Version
|
38
|
-
version:
|
39
|
-
|
40
|
+
version: 0.11.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
40
43
|
requirement: !ruby/object:Gem::Requirement
|
41
44
|
requirements:
|
42
|
-
- -
|
45
|
+
- - '>='
|
43
46
|
- !ruby/object:Gem::Version
|
44
|
-
version:
|
45
|
-
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
+
version: '10'
|
48
|
+
type: :development
|
47
49
|
prerelease: false
|
48
|
-
name: vertica
|
49
|
-
type: :runtime
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
|
54
|
+
version: '10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
56
57
|
requirement: !ruby/object:Gem::Requirement
|
57
58
|
requirements:
|
58
59
|
- - ~>
|
59
60
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
61
|
-
|
61
|
+
version: '2.14'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.14'
|
62
69
|
description: Sequel adapter for the Vertica database
|
63
70
|
email:
|
64
71
|
- camilo@camilolopez.com
|
@@ -67,47 +74,43 @@ extensions: []
|
|
67
74
|
extra_rdoc_files: []
|
68
75
|
files:
|
69
76
|
- .gitignore
|
77
|
+
- .rspec
|
78
|
+
- .travis.yml
|
70
79
|
- CHANGELOG
|
71
80
|
- Gemfile
|
81
|
+
- README.md
|
72
82
|
- Rakefile
|
73
|
-
- Readme.md
|
74
83
|
- lib/sequel-vertica.rb
|
75
84
|
- lib/sequel-vertica/version.rb
|
76
85
|
- lib/sequel/adapters/vertica.rb
|
77
86
|
- sequel-vertica.gemspec
|
78
|
-
- spec/adapters/spec_helper.rb
|
79
87
|
- spec/adapters/vertica_spec.rb
|
80
88
|
- spec/spec_config.example.rb
|
81
89
|
- spec/spec_helper.rb
|
82
90
|
homepage: https://github.com/camilo/sequel-vertica
|
83
|
-
licenses:
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
84
94
|
post_install_message:
|
85
95
|
rdoc_options: []
|
86
96
|
require_paths:
|
87
97
|
- lib
|
88
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
89
99
|
requirements:
|
90
|
-
- -
|
100
|
+
- - '>='
|
91
101
|
- !ruby/object:Gem::Version
|
92
|
-
|
93
|
-
- 0
|
94
|
-
hash: 2330074690303578723
|
95
|
-
version: '0'
|
96
|
-
none: false
|
102
|
+
version: 1.9.3
|
97
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
104
|
requirements:
|
99
|
-
- -
|
105
|
+
- - '>='
|
100
106
|
- !ruby/object:Gem::Version
|
101
|
-
segments:
|
102
|
-
- 0
|
103
|
-
hash: 2330074690303578723
|
104
107
|
version: '0'
|
105
|
-
none: false
|
106
108
|
requirements:
|
107
109
|
- Vertica version 6.0 or higher
|
108
110
|
rubyforge_project:
|
109
|
-
rubygems_version:
|
111
|
+
rubygems_version: 2.0.14
|
110
112
|
signing_key:
|
111
|
-
specification_version:
|
113
|
+
specification_version: 4
|
112
114
|
summary: Sequel adapter for the Vertica database largely based on the PostgreSQL adapter
|
113
115
|
test_files: []
|
116
|
+
has_rdoc:
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'logger'
|
3
|
-
|
4
|
-
unless Object.const_defined?('Sequel') && Sequel.const_defined?('Model')
|
5
|
-
$:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../../lib/"))
|
6
|
-
require 'sequel'
|
7
|
-
end
|
8
|
-
|
9
|
-
begin
|
10
|
-
require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'spec_config.rb')
|
11
|
-
rescue LoadError
|
12
|
-
end
|
13
|
-
|
14
|
-
if ENV['SEQUEL_COLUMNS_INTROSPECTION']
|
15
|
-
Sequel.extension :columns_introspection
|
16
|
-
Sequel::Dataset.introspect_all_columns
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
Sequel::Model.cache_anonymous_models = false
|
21
|
-
|
22
|
-
class Sequel::Database
|
23
|
-
def log_duration(duration, message)
|
24
|
-
log_info(message)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
(defined?(RSpec) ? RSpec::Core::ExampleGroup : Spec::Example::ExampleGroup).class_eval do
|
29
|
-
def log
|
30
|
-
begin
|
31
|
-
INTEGRATION_DB.loggers << Logger.new(STDOUT)
|
32
|
-
yield
|
33
|
-
ensure
|
34
|
-
INTEGRATION_DB.loggers.pop
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.cspecify(message, *checked, &block)
|
39
|
-
return specify(message, &block) if ENV['SEQUEL_NO_PENDING']
|
40
|
-
pending = false
|
41
|
-
checked.each do |c|
|
42
|
-
case c
|
43
|
-
when INTEGRATION_DB.adapter_scheme
|
44
|
-
pending = c
|
45
|
-
when Proc
|
46
|
-
pending = c if c.first.call(INTEGRATION_DB)
|
47
|
-
when Array
|
48
|
-
pending = c if c.first == INTEGRATION_DB.adapter_scheme && c.last == INTEGRATION_DB.call(INTEGRATION_DB)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
if pending
|
52
|
-
specify(message){pending("Not yet working on #{Array(pending).join(', ')}", &block)}
|
53
|
-
else
|
54
|
-
specify(message, &block)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|