activerecord-jdbcvertica-adapter 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f80bbb6d5c98a556d1bd9d86aa57ab480371540
4
- data.tar.gz: d733e728c1cc338c1034b4fd167b8d3328b81c0e
3
+ metadata.gz: e6052ecd363f79681629efed6fd53a220a265ac5
4
+ data.tar.gz: 3ec03924111f79c9274a8536437063835ed59cc6
5
5
  SHA512:
6
- metadata.gz: a4d9e5a2f91bce6b44bfe7c2d069370d684fcf274f8f529ba883fabf31f47a04f934fbd5904027197345cb552999ccc6059f412919b02b48526fd847b1673c9b
7
- data.tar.gz: ec2b498c79f5273e73f9cd4a3043c8641dfba2285db39eb96c9a5f17ea87ed345f31c2339b50f724303a378416dcd248076e6c6db60a3e34fe4e9d7b720046e3
6
+ metadata.gz: 508c26d590ef2ae3b1a50820920b9c9194ad425b267ae2f756df0fabc1a86819387f07880877abf8af563731d31b8c8f02635e5614f558c4bec2c7ab6425843f
7
+ data.tar.gz: e5147a5de1f6e010975f9c9d69ae2dd8eeda304f4ce64d675b1e3fdf73f8708028f2d4c7fa45d013db142567a0a955830263cb8326337f6bc0a4fbb4c225222b
@@ -16,6 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
+ gem.licenses = [ "MIT" ]
19
20
 
20
21
  gem.add_dependency "activerecord"
21
22
  gem.add_dependency "activerecord-jdbc-adapter"
@@ -1,7 +1,7 @@
1
1
  module Activerecord
2
2
  module Jdbcvertica
3
3
  module Adapter
4
- VERSION = "0.0.3"
4
+ VERSION = "0.0.4"
5
5
  end
6
6
  end
7
7
  end
@@ -1,3 +1,5 @@
1
+ require 'arjdbc/vertica/column'
2
+
1
3
  # Load a mapping for the "text" type that will actually work
2
4
  ::ActiveRecord::ConnectionAdapters::JdbcTypeConverter::AR_TO_JDBC_TYPES[:text] << lambda { |r| r['type_name'] =~ /varchar$/i }
3
5
 
@@ -29,6 +31,22 @@ module ::ArJdbc
29
31
  # no op
30
32
  end
31
33
 
34
+ def columns(table_name, name = nil)
35
+ sql = "SELECT * from V_CATALOG.COLUMNS WHERE table_name = '#{table_name}';"
36
+ raw_columns = execute(sql, name || "SCHEMA")
37
+ columns = raw_columns.map do |raw_column|
38
+ ::ActiveRecord::ConnectionAdapters::VerticaColumn.new(
39
+ raw_column['column_name'],
40
+ raw_column['column_default'],
41
+ raw_column['data_type'],
42
+ raw_column['is_nullable'],
43
+ raw_column['is_identity']
44
+ )
45
+ end
46
+
47
+ return columns
48
+ end
49
+
32
50
  ##
33
51
  # Vertica JDBC does not work with JDBC GET_GENERATED_KEYS
34
52
  # so we need to execute the sql raw and then lookup the
@@ -0,0 +1,62 @@
1
+ module ActiveRecord
2
+
3
+ module ConnectionAdapters
4
+ class VerticaColumn < Column
5
+ def initialize(name, default, sql_type = nil, null = true, primary_key = false)
6
+ super(name, self.class.extract_value_from_default(default), sql_type, null)
7
+ # Might need to set if it is primary key below? don't know
8
+ # self.primary = primary_key
9
+ end
10
+
11
+ def self.extract_value_from_default(default)
12
+ case default
13
+ # Numeric types
14
+ when /\A\(?(-?\d+(\.\d*)?\)?)\z/ then
15
+ $1
16
+ # Character types
17
+ when /\A'(.*)'::(?:character varchar|varying|bpchar|text)\z/m then
18
+ $1
19
+ # Character types (8.1 formatting)
20
+ when /\AE'(.*)'::(?:character varchar|varying|bpchar|text)\z/m then
21
+ $1.gsub(/\\(\d\d\d)/) { $1.oct.chr }
22
+ # Binary data types
23
+ when /\A'(.*)'::bytea\z/m then
24
+ $1
25
+ # Date/time types
26
+ when /\A'(.+)'::(?:time(?:stamp)? with(?:out)? time zone|date)\z/ then
27
+ $1
28
+ when /\A'(.*)'::interval\z/ then
29
+ $1
30
+ # Boolean type
31
+ when 'true' then
32
+ true
33
+ when 'false' then
34
+ false
35
+ # Geometric types
36
+ when /\A'(.*)'::(?:point|line|lseg|box|"?path"?|polygon|circle)\z/ then
37
+ $1
38
+ # Network address types
39
+ when /\A'(.*)'::(?:cidr|inet|macaddr)\z/ then
40
+ $1
41
+ # Bit string types
42
+ when /\AB'(.*)'::"?bit(?: varying)?"?\z/ then
43
+ $1
44
+ # XML type
45
+ when /\A'(.*)'::xml\z/m then
46
+ $1
47
+ # Arrays
48
+ when /\A'(.*)'::"?\D+"?\[\]\z/ then
49
+ $1
50
+ # Object identifier types
51
+ when /\A-?\d+\z/ then
52
+ $1
53
+ else
54
+ # Anything else is blank, some user type, or some function
55
+ # and we can't know the value of that, so return nil.
56
+ nil
57
+ end
58
+ end
59
+ end
60
+ end
61
+
62
+ end
@@ -51,7 +51,7 @@ describe ColumnKing do
51
51
  it "creates :integer columns" do
52
52
  connection.add_column(:kings, :queen_id, :integer)
53
53
  has_column?(:queen_id).must_equal(true)
54
- has_column_typed?(:queen_id, /integer/i).must_equal(true)
54
+ has_column_typed?(:queen_id, /int/i).must_equal(true)
55
55
  end
56
56
 
57
57
  it "creates :string columns (as varchar)" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-jdbcvertica-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Dewitt
@@ -116,6 +116,7 @@ files:
116
116
  - lib/activerecord-jdbcvertica-adapter/version.rb
117
117
  - lib/arjdbc/vertica.rb
118
118
  - lib/arjdbc/vertica/adapter.rb
119
+ - lib/arjdbc/vertica/column.rb
119
120
  - lib/arjdbc/vertica/connection_methods.rb
120
121
  - spec/full_object_spec.rb
121
122
  - spec/migrations/column_spec.rb
@@ -123,7 +124,8 @@ files:
123
124
  - spec/migrations/table_spec.rb
124
125
  - spec/spec_helper.rb
125
126
  homepage: ''
126
- licenses: []
127
+ licenses:
128
+ - MIT
127
129
  metadata: {}
128
130
  post_install_message:
129
131
  rdoc_options: []