activerecord-jdbcvertica-adapter 0.3.0.pre1 → 0.6.2.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +5 -5
- data/activerecord-jdbcvertica-adapter.gemspec +6 -7
- data/lib/activerecord-jdbcvertica-adapter/version.rb +1 -1
- data/lib/arjdbc/vertica/adapter.rb +114 -31
- data/lib/arjdbc/vertica/column.rb +12 -7
- data/lib/arjdbc/vertica/connection_methods.rb +1 -0
- data/spec/adapter_spec.rb +77 -0
- data/spec/bulk_insert_spec.rb +3 -2
- data/spec/full_object_spec.rb +77 -35
- data/spec/migrations/column_spec.rb +2 -2
- data/spec/migrations/index_spec.rb +2 -2
- data/spec/migrations/table_spec.rb +1 -1
- metadata +30 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c43272579be682d3609da6df2f40558733d4ab6057b35038a6e3c38392d0f50a
|
4
|
+
data.tar.gz: c06d2d5980a074303e520b63ec628915eca4636f9317a2807e7e43974a95eb66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a46593165fcd3a8855876098893f5585d5743492f23c8010049d0f0d455fffe957bfd4e2078f8c2a123916adbe166049e5167bcb3bdc1cb59aa92536b947600
|
7
|
+
data.tar.gz: 115c897ad2f671110754f7b8ed81911aa91dc4b0c5dd109e923ec424337eb3af5dc18722045a59436100ed531fcac7f32c9593c4013771f603a2795ad59c43a5
|
data/.circleci/config.yml
CHANGED
@@ -4,9 +4,9 @@ version: 2.0
|
|
4
4
|
jobs:
|
5
5
|
build:
|
6
6
|
docker:
|
7
|
-
- image: circleci/jruby:9.
|
7
|
+
- image: circleci/jruby:9.3.4.0-jdk
|
8
8
|
environment:
|
9
|
-
BUNDLER_VERSION:
|
9
|
+
BUNDLER_VERSION: 2.3.14
|
10
10
|
- image: jbfavre/vertica:latest
|
11
11
|
environment:
|
12
12
|
DATABASE_ADAPTER: vertica5
|
@@ -19,12 +19,12 @@ jobs:
|
|
19
19
|
- run:
|
20
20
|
name: Configure Bundler
|
21
21
|
command: |
|
22
|
-
gem install bundler -v
|
22
|
+
gem install bundler -v 2.3.14
|
23
23
|
- run:
|
24
24
|
name: Bundle Install
|
25
25
|
command: |
|
26
|
-
bundle
|
26
|
+
bundle install
|
27
27
|
- run:
|
28
28
|
name: tests
|
29
29
|
command: |
|
30
|
-
bundle exec rake test
|
30
|
+
bundle exec rake test
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'activerecord-jdbcvertica-adapter/version'
|
@@ -17,12 +16,12 @@ Gem::Specification.new do |gem|
|
|
17
16
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
17
|
gem.require_paths = ["lib"]
|
19
18
|
gem.licenses = [ "MIT" ]
|
19
|
+
gem.add_dependency "activerecord", "~> 6.1"
|
20
|
+
gem.add_dependency "activerecord-jdbc-adapter", "~> 61"
|
20
21
|
|
21
|
-
gem.add_dependency "activerecord", "< 5.0"
|
22
|
-
gem.add_dependency "activerecord-jdbc-adapter", "< 50"
|
23
|
-
|
24
|
-
gem.add_development_dependency "bundler"
|
25
|
-
gem.add_development_dependency "mocha"
|
26
22
|
gem.add_development_dependency "pry"
|
23
|
+
gem.add_development_dependency "pry-nav"
|
24
|
+
gem.add_development_dependency "pry-remote"
|
25
|
+
gem.add_development_dependency "mocha"
|
27
26
|
gem.add_development_dependency "rake"
|
28
|
-
end
|
27
|
+
end
|
@@ -13,6 +13,19 @@ module ::ActiveRecord
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.bulk_insert(columns, data)
|
16
|
+
unless columns.include?("created_at")
|
17
|
+
columns << 'created_at'
|
18
|
+
data.each do |d|
|
19
|
+
d << ArJdbc::Vertica.current_time
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
unless columns.include?("updated_at")
|
24
|
+
columns << 'updated_at'
|
25
|
+
data.each do |d|
|
26
|
+
d << ArJdbc::Vertica.current_time
|
27
|
+
end
|
28
|
+
end
|
16
29
|
connection.bulk_insert(self.table_name, self.primary_key, self.sequence_name, columns, data)
|
17
30
|
end
|
18
31
|
|
@@ -45,6 +58,13 @@ end
|
|
45
58
|
module ::ArJdbc
|
46
59
|
module Vertica
|
47
60
|
include ::ArJdbc::Util::QuotedCache
|
61
|
+
require 'arjdbc/vertica/column'
|
62
|
+
def self.jdbc_connection_class
|
63
|
+
::ActiveRecord::ConnectionAdapters::JdbcConnection
|
64
|
+
end
|
65
|
+
|
66
|
+
# @see ActiveRecord::ConnectionAdapters::JdbcAdapter#jdbc_column_class
|
67
|
+
def jdbc_column_class; ::ActiveRecord::ConnectionAdapters::VerticaColumn end
|
48
68
|
|
49
69
|
ADAPTER_NAME = 'Vertica'.freeze
|
50
70
|
INSERT_TABLE_EXTRACTION = /into\s+(?<table_name>[^\(]*).*values\s*\(/im
|
@@ -67,12 +87,33 @@ module ::ArJdbc
|
|
67
87
|
}
|
68
88
|
|
69
89
|
TIMESTAMP_COLUMNS = [
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
90
|
+
"created_at",
|
91
|
+
"created_on",
|
92
|
+
"updated_at",
|
93
|
+
"updated_on"
|
74
94
|
]
|
75
95
|
|
96
|
+
def columns(table_name, name = nil)
|
97
|
+
sql = "SELECT * from V_CATALOG.COLUMNS WHERE table_name = '#{table_name}';"
|
98
|
+
raw_columns = execute(sql, name || "SCHEMA")
|
99
|
+
|
100
|
+
# Vertica doesn't use the type name of bigint since all ints are 8-byte, so when the type is int use bigint instead
|
101
|
+
|
102
|
+
columns = raw_columns.map do |raw_column|
|
103
|
+
data_type = raw_column['data_type'] == 'int' ? 'bigint' : raw_column['data_type']
|
104
|
+
::ActiveRecord::ConnectionAdapters::VerticaColumn.new(
|
105
|
+
raw_column['column_name'],
|
106
|
+
raw_column['column_default'],
|
107
|
+
raw_column['data_type_id'],
|
108
|
+
raw_column['table_name'],
|
109
|
+
data_type,
|
110
|
+
fetch_type_metadata(data_type),
|
111
|
+
raw_column['is_nullable'],
|
112
|
+
raw_column['is_identity']
|
113
|
+
)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
76
117
|
def self.current_time
|
77
118
|
::ActiveRecord::Base.default_timezone == :utc ? ::Time.now.utc : ::Time.now
|
78
119
|
end
|
@@ -105,24 +146,6 @@ module ::ArJdbc
|
|
105
146
|
execute(sql)
|
106
147
|
end
|
107
148
|
|
108
|
-
def columns(table_name, name = nil)
|
109
|
-
sql = "SELECT * from V_CATALOG.COLUMNS WHERE table_name = '#{table_name}';"
|
110
|
-
raw_columns = execute(sql, name || "SCHEMA")
|
111
|
-
|
112
|
-
columns = raw_columns.map do |raw_column|
|
113
|
-
::ActiveRecord::ConnectionAdapters::VerticaColumn.new(
|
114
|
-
raw_column['column_name'],
|
115
|
-
raw_column['column_default'],
|
116
|
-
raw_column['data_type_id'],
|
117
|
-
raw_column['data_type'],
|
118
|
-
raw_column['is_nullable'],
|
119
|
-
raw_column['is_identity']
|
120
|
-
)
|
121
|
-
end
|
122
|
-
|
123
|
-
return columns
|
124
|
-
end
|
125
|
-
|
126
149
|
##
|
127
150
|
# Override create_table to create the sequences
|
128
151
|
# needed to manage primary keys
|
@@ -163,7 +186,7 @@ module ::ArJdbc
|
|
163
186
|
|
164
187
|
##
|
165
188
|
# Vertica JDBC does not work with JDBC GET_GENERATED_KEYS
|
166
|
-
# so we need to execute the sql raw and then lookup the
|
189
|
+
# so we need to execute the sql raw and then lookup the
|
167
190
|
# LAST_INSERT_ID() that occurred in this "session"
|
168
191
|
#
|
169
192
|
def exec_insert(sql, name, binds, primary_key = nil, sequence_name = nil)
|
@@ -178,7 +201,7 @@ module ::ArJdbc
|
|
178
201
|
|
179
202
|
def native_database_types
|
180
203
|
NATIVE_DATABASE_TYPES
|
181
|
-
end
|
204
|
+
end
|
182
205
|
|
183
206
|
def next_insert_id_for(sequence_name)
|
184
207
|
return select_value("SELECT NEXTVAL('#{sequence_name}');")
|
@@ -279,21 +302,81 @@ module ::ArJdbc
|
|
279
302
|
"temporary_table_#{::SecureRandom.hex}"
|
280
303
|
end
|
281
304
|
|
282
|
-
|
283
|
-
|
305
|
+
end
|
306
|
+
end
|
284
307
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
308
|
+
module ActiveRecord
|
309
|
+
module ConnectionAdapters
|
310
|
+
class SchemaCreation
|
311
|
+
include ::ArJdbc::Vertica
|
312
|
+
def type_to_sql(type, limit: nil, precision: nil, scale: nil, **) # :nodoc:
|
313
|
+
type = type.to_sym if type
|
314
|
+
|
315
|
+
if native = native_database_types[type]
|
316
|
+
column_type_sql = (native.is_a?(Hash) ? native[:name] : native).dup
|
317
|
+
if type == :decimal # ignore limit, use precision and scale
|
318
|
+
scale ||= native[:scale]
|
319
|
+
|
320
|
+
if precision ||= native[:precision]
|
321
|
+
if scale
|
322
|
+
column_type_sql << "(#{precision},#{scale})"
|
323
|
+
else
|
324
|
+
column_type_sql << "(#{precision})"
|
325
|
+
end
|
326
|
+
elsif scale
|
327
|
+
raise ArgumentError, "Error adding decimal column: precision cannot be empty if scale is specified"
|
328
|
+
end
|
329
|
+
|
330
|
+
elsif [:datetime, :timestamp, :time, :interval].include?(type) && precision ||= native[:precision]
|
331
|
+
if (0..6) === precision
|
332
|
+
column_type_sql << "(#{precision})"
|
333
|
+
else
|
334
|
+
raise(ActiveRecordError, "No #{native[:name]} type has precision of #{precision}. The allowed range of precision is from 0 to 6")
|
335
|
+
end
|
336
|
+
elsif (type != :primary_key && type != :integer) && (limit ||= native.is_a?(Hash) && native[:limit])
|
337
|
+
column_type_sql << "(#{limit})"
|
338
|
+
end
|
339
|
+
|
340
|
+
column_type_sql
|
341
|
+
else
|
342
|
+
type.to_s
|
343
|
+
end
|
289
344
|
end
|
290
345
|
end
|
291
|
-
|
292
346
|
end
|
293
347
|
end
|
294
348
|
|
295
349
|
module ActiveRecord::ConnectionAdapters
|
296
350
|
class VerticaAdapter < JdbcAdapter
|
297
351
|
include ::ArJdbc::Vertica
|
352
|
+
def initialize(connection, logger = nil, connection_parameters = nil, config = {})
|
353
|
+
super(connection, logger, config) # configure_connection happens in super
|
354
|
+
end
|
355
|
+
|
356
|
+
def jdbc_connection_class(spec)
|
357
|
+
::ArJdbc::Vertica.jdbc_connection_class
|
358
|
+
end
|
359
|
+
|
360
|
+
def initialize_type_map(m = type_map)
|
361
|
+
super
|
362
|
+
m.register_type(%r(int)i) do
|
363
|
+
ActiveRecord::Type::Integer.new(limit: 8)
|
364
|
+
end
|
365
|
+
end
|
298
366
|
end
|
299
367
|
end
|
368
|
+
|
369
|
+
module ActiveRecord
|
370
|
+
module ConnectionAdapters
|
371
|
+
module DatabaseStatements
|
372
|
+
READ_QUERY = ActiveRecord::ConnectionAdapters::AbstractAdapter.build_read_query_regexp(
|
373
|
+
:close, :declare, :fetch, :move, :set, :show
|
374
|
+
) # :nodoc:
|
375
|
+
private_constant :READ_QUERY
|
376
|
+
|
377
|
+
def write_query?(sql) # :nodoc:
|
378
|
+
!READ_QUERY.match?(sql)
|
379
|
+
end
|
380
|
+
end
|
381
|
+
end
|
382
|
+
end
|
@@ -1,17 +1,23 @@
|
|
1
1
|
module ActiveRecord
|
2
|
-
|
3
2
|
module ConnectionAdapters
|
4
3
|
class VerticaColumn < Column
|
5
|
-
def initialize(name, default, data_type_id, sql_type = nil, null = true, primary_key = false)
|
4
|
+
def initialize(name, default, data_type_id, table_name, sql_type = nil, sql_meta_data = nil, null = true, default_function = nil, primary_key = false)
|
6
5
|
super(name,
|
7
|
-
self.class.extract_value_from_default(default),
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
default = self.class.extract_value_from_default(default),
|
7
|
+
sql_meta_data,
|
8
|
+
null,
|
9
|
+
table_name
|
10
|
+
)
|
11
|
+
|
11
12
|
# Might need to set if it is primary key below? don't know
|
12
13
|
# self.primary = primary_key
|
13
14
|
end
|
14
15
|
|
16
|
+
def self.sql_type_metadata(sql_type, data_type_id)
|
17
|
+
cast_type = self.cast_type_from_data_type_id(data_type_id) || self.cast_type_from_sql_type(sql_type)
|
18
|
+
ActiveRecord::ConnectionAdapters::SqlTypeMetadata.new(sql_type: sql_type, type: cast_type.type, limit: cast_type.limit, precision: cast_type.precision, scale: cast_type.scale)
|
19
|
+
end
|
20
|
+
|
15
21
|
def self.cast_type_from_data_type_id(data_type_id)
|
16
22
|
case data_type_id
|
17
23
|
when 5 #, 'bool', :bool
|
@@ -128,5 +134,4 @@ module ActiveRecord
|
|
128
134
|
end
|
129
135
|
end
|
130
136
|
end
|
131
|
-
|
132
137
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require_relative './spec_helper.rb'
|
2
|
+
|
3
|
+
class CreateTestObject < ActiveRecord::Migration[6.1]
|
4
|
+
def self.up
|
5
|
+
create_table :test_objects do |t|
|
6
|
+
t.string :string
|
7
|
+
t.string :limit_40_string, limit: 40
|
8
|
+
t.text :text
|
9
|
+
t.integer :integer
|
10
|
+
t.integer :limit_integer, limit: 8
|
11
|
+
t.bigint :big_integer
|
12
|
+
t.float :float
|
13
|
+
t.decimal :decimal
|
14
|
+
t.decimal :decimal_with_scale_and_precision, precision: 14, scale: 2
|
15
|
+
t.datetime :datetime
|
16
|
+
t.time :time
|
17
|
+
t.date :date
|
18
|
+
t.boolean :boolean
|
19
|
+
t.timestamps
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.down
|
24
|
+
if table_exists?(:test_objects)
|
25
|
+
drop_table :test_objects
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class TestObject < ::ActiveRecord::Base
|
31
|
+
end
|
32
|
+
|
33
|
+
describe ::TestObject do
|
34
|
+
subject { TestObject }
|
35
|
+
|
36
|
+
before do
|
37
|
+
CreateTestObject.down
|
38
|
+
CreateTestObject.up
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "respect args in migration" do
|
42
|
+
#TODO, test that when a migration is run with various args like :limit, :null, :precision, :scale
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "test column data" do
|
46
|
+
it "correctly assigns all integers as bigint column data" do
|
47
|
+
int_column_names = ["id","integer","biginteger"]
|
48
|
+
int_columns = TestObject.columns.select{|column| int_column_names.include?(column.name)}
|
49
|
+
id_column = TestObject.columns.first
|
50
|
+
_(id_column.name).must_equal("id")
|
51
|
+
_(id_column.null).must_equal(false)
|
52
|
+
|
53
|
+
int_columns.each do |int_column|
|
54
|
+
_(int_column.sql_type_metadata.limit).must_equal(8)
|
55
|
+
_(int_column.sql_type_metadata.sql_type).must_equal("bigint")
|
56
|
+
_(int_column.sql_type_metadata.type).must_equal(:integer)
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
it "correctly assigns non integer column data" do
|
62
|
+
string_column = TestObject.columns.second
|
63
|
+
_(string_column.name).must_equal("string")
|
64
|
+
_(string_column.sql_type_metadata.limit).must_equal(255)
|
65
|
+
_(string_column.sql_type_metadata.sql_type).must_equal("varchar(255)")
|
66
|
+
_(string_column.sql_type_metadata.type).must_equal(:string)
|
67
|
+
_(string_column.null).must_equal(true)
|
68
|
+
|
69
|
+
string_limited_column = TestObject.columns.third
|
70
|
+
_(string_limited_column.name).must_equal("limit_40_string")
|
71
|
+
_(string_limited_column.sql_type_metadata.limit).must_equal(40)
|
72
|
+
_(string_limited_column.sql_type_metadata.sql_type).must_equal("varchar(40)")
|
73
|
+
_(string_limited_column.sql_type_metadata.type).must_equal(:string)
|
74
|
+
_(string_limited_column.null).must_equal(true)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/spec/bulk_insert_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
require_relative 'spec_helper'
|
2
2
|
|
3
|
-
class CreateFullObject <
|
3
|
+
class CreateFullObject < ActiveRecord::Migration[6.1]
|
4
4
|
def self.up
|
5
5
|
create_table :full_objects do |t|
|
6
6
|
t.string :string
|
@@ -12,6 +12,7 @@ class CreateFullObject < ::ActiveRecord::Migration
|
|
12
12
|
t.time :time
|
13
13
|
t.date :date
|
14
14
|
t.boolean :boolean
|
15
|
+
t.timestamps
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
data/spec/full_object_spec.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
-
|
1
|
+
require_relative './spec_helper.rb'
|
2
2
|
|
3
|
-
class CreateFullObject <
|
3
|
+
class CreateFullObject < ActiveRecord::Migration[6.1]
|
4
4
|
def self.up
|
5
5
|
create_table :full_objects do |t|
|
6
|
-
t.string :string
|
6
|
+
t.string :string, :limit => 40
|
7
7
|
t.text :text
|
8
8
|
t.integer :integer
|
9
|
+
t.bigint :biginteger
|
9
10
|
t.float :float
|
10
11
|
t.decimal :decimal
|
11
12
|
t.datetime :datetime
|
12
13
|
t.time :time
|
13
14
|
t.date :date
|
14
15
|
t.boolean :boolean
|
16
|
+
t.timestamps
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
@@ -33,16 +35,21 @@ describe ::FullObject do
|
|
33
35
|
CreateFullObject.up
|
34
36
|
end
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
38
|
+
|
39
|
+
describe "API" do
|
40
|
+
it "must respond" do
|
41
|
+
_(_(subject).must_respond_to(:id))
|
42
|
+
_(_(subject).must_respond_to(:string))
|
43
|
+
_(_(subject).must_respond_to(:text))
|
44
|
+
_(_(subject).must_respond_to(:integer))
|
45
|
+
_(_(subject).must_respond_to(:float))
|
46
|
+
_(_(subject).must_respond_to(:decimal))
|
47
|
+
_(_(subject).must_respond_to(:datetime))
|
48
|
+
_(_(subject).must_respond_to(:time))
|
49
|
+
_(_(subject).must_respond_to(:date))
|
50
|
+
_(_(subject).must_respond_to(:boolean))
|
51
|
+
_(_(subject).must_respond_to(:biginteger))
|
52
|
+
end
|
46
53
|
end
|
47
54
|
|
48
55
|
describe "#create with id" do
|
@@ -56,7 +63,7 @@ describe ::FullObject do
|
|
56
63
|
end
|
57
64
|
|
58
65
|
describe "#delete" do
|
59
|
-
it "deletes a persisted record" do
|
66
|
+
it "deletes a persisted record" do
|
60
67
|
subject.string = "string"
|
61
68
|
subject.save
|
62
69
|
|
@@ -67,7 +74,7 @@ describe ::FullObject do
|
|
67
74
|
end
|
68
75
|
|
69
76
|
describe "#delete_all" do
|
70
|
-
it "deletes a persisted record" do
|
77
|
+
it "deletes a persisted record" do
|
71
78
|
subject.string = "string"
|
72
79
|
subject.save
|
73
80
|
|
@@ -78,7 +85,7 @@ describe ::FullObject do
|
|
78
85
|
end
|
79
86
|
|
80
87
|
describe "#insert" do
|
81
|
-
it "string" do
|
88
|
+
it "string" do
|
82
89
|
subject.string = "string"
|
83
90
|
subject.save
|
84
91
|
|
@@ -86,7 +93,7 @@ describe ::FullObject do
|
|
86
93
|
retrieved.string.must_equal(subject.string)
|
87
94
|
end
|
88
95
|
|
89
|
-
it "text" do
|
96
|
+
it "text" do
|
90
97
|
subject.text = "text"
|
91
98
|
subject.save
|
92
99
|
|
@@ -94,7 +101,7 @@ describe ::FullObject do
|
|
94
101
|
retrieved.text.must_equal(subject.text)
|
95
102
|
end
|
96
103
|
|
97
|
-
it "integer" do
|
104
|
+
it "integer" do
|
98
105
|
subject.integer = 1234
|
99
106
|
subject.save
|
100
107
|
|
@@ -102,7 +109,7 @@ describe ::FullObject do
|
|
102
109
|
retrieved.integer.must_equal(subject.integer)
|
103
110
|
end
|
104
111
|
|
105
|
-
it "float" do
|
112
|
+
it "float" do
|
106
113
|
subject.float = 1234.4321
|
107
114
|
subject.save
|
108
115
|
|
@@ -110,7 +117,7 @@ describe ::FullObject do
|
|
110
117
|
retrieved.float.must_equal(subject.float)
|
111
118
|
end
|
112
119
|
|
113
|
-
it "decimal" do
|
120
|
+
it "decimal" do
|
114
121
|
subject.decimal = 1234.4321
|
115
122
|
subject.save
|
116
123
|
|
@@ -118,7 +125,7 @@ describe ::FullObject do
|
|
118
125
|
retrieved.decimal.must_equal(subject.decimal)
|
119
126
|
end
|
120
127
|
|
121
|
-
it "datetime" do
|
128
|
+
it "datetime" do
|
122
129
|
subject.datetime = Time.current.utc
|
123
130
|
subject.save
|
124
131
|
|
@@ -126,7 +133,7 @@ describe ::FullObject do
|
|
126
133
|
retrieved.datetime.to_s.must_equal(subject.datetime.to_s)
|
127
134
|
end
|
128
135
|
|
129
|
-
it "time" do
|
136
|
+
it "time" do
|
130
137
|
subject.time = Time.current.utc
|
131
138
|
subject.save
|
132
139
|
|
@@ -134,7 +141,7 @@ describe ::FullObject do
|
|
134
141
|
retrieved.time.strftime("%H%M%S").must_equal(subject.time.strftime("%H%M%S"))
|
135
142
|
end
|
136
143
|
|
137
|
-
it "date" do
|
144
|
+
it "date" do
|
138
145
|
subject.date = Time.current
|
139
146
|
subject.save
|
140
147
|
|
@@ -142,7 +149,7 @@ describe ::FullObject do
|
|
142
149
|
retrieved.date.must_equal(subject.date)
|
143
150
|
end
|
144
151
|
|
145
|
-
it "boolean (false)" do
|
152
|
+
it "boolean (false)" do
|
146
153
|
subject.boolean = false
|
147
154
|
subject.save
|
148
155
|
|
@@ -150,7 +157,7 @@ describe ::FullObject do
|
|
150
157
|
retrieved.boolean.must_equal(subject.boolean)
|
151
158
|
end
|
152
159
|
|
153
|
-
it "boolean (true)" do
|
160
|
+
it "boolean (true)" do
|
154
161
|
subject.boolean = true
|
155
162
|
subject.save
|
156
163
|
|
@@ -160,7 +167,7 @@ describe ::FullObject do
|
|
160
167
|
end
|
161
168
|
|
162
169
|
describe "#update" do
|
163
|
-
it "string" do
|
170
|
+
it "string" do
|
164
171
|
change_to = "string2"
|
165
172
|
subject.string = "string"
|
166
173
|
subject.save
|
@@ -170,7 +177,7 @@ describe ::FullObject do
|
|
170
177
|
retrieved.reload.string.must_equal(change_to)
|
171
178
|
end
|
172
179
|
|
173
|
-
it "text" do
|
180
|
+
it "text" do
|
174
181
|
change_to = "text2"
|
175
182
|
subject.text = "text"
|
176
183
|
subject.save
|
@@ -180,7 +187,7 @@ describe ::FullObject do
|
|
180
187
|
retrieved.reload.text.must_equal(change_to)
|
181
188
|
end
|
182
189
|
|
183
|
-
it "integer" do
|
190
|
+
it "integer" do
|
184
191
|
change_to = 4321
|
185
192
|
subject.integer = 1234
|
186
193
|
subject.save
|
@@ -190,7 +197,7 @@ describe ::FullObject do
|
|
190
197
|
retrieved.reload.integer.must_equal(change_to)
|
191
198
|
end
|
192
199
|
|
193
|
-
it "float" do
|
200
|
+
it "float" do
|
194
201
|
change_to = 4321.1234
|
195
202
|
subject.float = 1234.4321
|
196
203
|
subject.save
|
@@ -200,7 +207,7 @@ describe ::FullObject do
|
|
200
207
|
retrieved.reload.float.must_equal(change_to)
|
201
208
|
end
|
202
209
|
|
203
|
-
it "decimal" do
|
210
|
+
it "decimal" do
|
204
211
|
change_to = 4321.1234
|
205
212
|
subject.decimal = 1234.4321
|
206
213
|
subject.save
|
@@ -210,7 +217,7 @@ describe ::FullObject do
|
|
210
217
|
retrieved.reload.decimal.must_equal(change_to)
|
211
218
|
end
|
212
219
|
|
213
|
-
it "datetime" do
|
220
|
+
it "datetime" do
|
214
221
|
change_to = Time.new(2010).utc
|
215
222
|
subject.datetime = Time.current.utc
|
216
223
|
subject.save
|
@@ -220,7 +227,7 @@ describe ::FullObject do
|
|
220
227
|
retrieved.reload.datetime.to_s.must_equal(change_to.to_s)
|
221
228
|
end
|
222
229
|
|
223
|
-
it "time" do
|
230
|
+
it "time" do
|
224
231
|
change_to = Time.new(2010).utc
|
225
232
|
subject.time = Time.current.utc
|
226
233
|
subject.save
|
@@ -230,7 +237,7 @@ describe ::FullObject do
|
|
230
237
|
retrieved.reload.time.strftime("%H%M%S").must_equal(change_to.strftime("%H%M%S"))
|
231
238
|
end
|
232
239
|
|
233
|
-
it "date" do
|
240
|
+
it "date" do
|
234
241
|
change_to = Time.new(2010).utc
|
235
242
|
subject.date = Time.current
|
236
243
|
subject.save
|
@@ -240,7 +247,7 @@ describe ::FullObject do
|
|
240
247
|
retrieved.reload.date.strftime("%Y%m%d").must_equal(change_to.strftime("%Y%m%d"))
|
241
248
|
end
|
242
249
|
|
243
|
-
it "boolean (false)" do
|
250
|
+
it "boolean (false)" do
|
244
251
|
change_to = true
|
245
252
|
subject.boolean = false
|
246
253
|
subject.save
|
@@ -250,7 +257,7 @@ describe ::FullObject do
|
|
250
257
|
retrieved.reload.boolean.must_equal(change_to)
|
251
258
|
end
|
252
259
|
|
253
|
-
it "boolean (true)" do
|
260
|
+
it "boolean (true)" do
|
254
261
|
change_to = false
|
255
262
|
subject.boolean = true
|
256
263
|
subject.save
|
@@ -277,4 +284,39 @@ describe ::FullObject do
|
|
277
284
|
FullObject.where(:boolean => true).count.must_equal(2)
|
278
285
|
end
|
279
286
|
end
|
287
|
+
|
288
|
+
describe "test column data" do
|
289
|
+
it "correctly assigns all integers as bigint column data" do
|
290
|
+
int_column_names = ["id","integer","biginteger"]
|
291
|
+
int_columns = FullObject.columns.select{|column| int_column_names.include?(column.name)}
|
292
|
+
id_column = FullObject.columns.first
|
293
|
+
_(id_column.name).must_equal("id")
|
294
|
+
_(id_column.null).must_equal(false)
|
295
|
+
|
296
|
+
int_columns.each do |int_column|
|
297
|
+
_(int_column.sql_type_metadata.limit).must_equal(8)
|
298
|
+
_(int_column.sql_type_metadata.sql_type).must_equal("bigint")
|
299
|
+
_(int_column.sql_type_metadata.type).must_equal(:integer)
|
300
|
+
end
|
301
|
+
|
302
|
+
end
|
303
|
+
|
304
|
+
it "correctly assigns string with limit column data" do
|
305
|
+
id_column = FullObject.columns.second
|
306
|
+
_(id_column.name).must_equal("string")
|
307
|
+
_(id_column.sql_type_metadata.limit).must_equal(40)
|
308
|
+
_(id_column.sql_type_metadata.sql_type).must_equal("varchar(40)")
|
309
|
+
_(id_column.sql_type_metadata.type).must_equal(:string)
|
310
|
+
_(id_column.null).must_equal(true)
|
311
|
+
end
|
312
|
+
|
313
|
+
it "correctly assigns text column data" do
|
314
|
+
id_column = FullObject.columns.third
|
315
|
+
_(id_column.name).must_equal("text")
|
316
|
+
_(id_column.sql_type_metadata.limit).must_equal(15000)
|
317
|
+
_(id_column.sql_type_metadata.sql_type).must_equal("varchar(15000)")
|
318
|
+
_(id_column.sql_type_metadata.type).must_equal(:string)
|
319
|
+
_(id_column.null).must_equal(true)
|
320
|
+
end
|
321
|
+
end
|
280
322
|
end
|
metadata
CHANGED
@@ -1,50 +1,50 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-jdbcvertica-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.2.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Dewitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
|
-
- - "
|
16
|
+
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: '
|
18
|
+
version: '6.1'
|
19
19
|
name: activerecord
|
20
20
|
prerelease: false
|
21
21
|
type: :runtime
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
30
|
-
- - "
|
30
|
+
- - "~>"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '61'
|
33
33
|
name: activerecord-jdbc-adapter
|
34
34
|
prerelease: false
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '61'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
|
-
name:
|
47
|
+
name: pry
|
48
48
|
prerelease: false
|
49
49
|
type: :development
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
|
-
name:
|
61
|
+
name: pry-nav
|
62
62
|
prerelease: false
|
63
63
|
type: :development
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -72,7 +72,21 @@ dependencies:
|
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
|
-
name: pry
|
75
|
+
name: pry-remote
|
76
|
+
prerelease: false
|
77
|
+
type: :development
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
name: mocha
|
76
90
|
prerelease: false
|
77
91
|
type: :development
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -123,6 +137,7 @@ files:
|
|
123
137
|
- lib/arjdbc/vertica/column.rb
|
124
138
|
- lib/arjdbc/vertica/connection_methods.rb
|
125
139
|
- lib/tasks/vertica_database_tasks.rake
|
140
|
+
- spec/adapter_spec.rb
|
126
141
|
- spec/bulk_insert_spec.rb
|
127
142
|
- spec/full_object_spec.rb
|
128
143
|
- spec/migrations/column_spec.rb
|
@@ -148,12 +163,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
163
|
- !ruby/object:Gem::Version
|
149
164
|
version: 1.3.1
|
150
165
|
requirements: []
|
151
|
-
|
152
|
-
rubygems_version: 2.6.14.1
|
166
|
+
rubygems_version: 3.2.29
|
153
167
|
signing_key:
|
154
168
|
specification_version: 4
|
155
169
|
summary: An ActiveRecord adapter JDBC
|
156
170
|
test_files:
|
171
|
+
- spec/adapter_spec.rb
|
157
172
|
- spec/bulk_insert_spec.rb
|
158
173
|
- spec/full_object_spec.rb
|
159
174
|
- spec/migrations/column_spec.rb
|