Class: Sequel::Vertica::Database
- Inherits:
-
Database
- Object
- Database
- Sequel::Vertica::Database
- Defined in:
- lib/sequel/adapters/vertica.rb
Constant Summary collapse
- PK_NAME =
'C_PRIMARY'
- AUTO_INCREMENT =
'AUTO_INCREMENT'
- DatasetClass =
self
Instance Method Summary collapse
- #auto_increment_sql ⇒ Object
- #connect(server) ⇒ Object
- #create_table_generator_class ⇒ Object
- #execute(sql, opts = {}, &block) ⇒ Object (also: #execute_dui)
- #execute_insert(sql, opts = {}, &block) ⇒ Object
- #identifier_input_method_default ⇒ Object
- #identifier_output_method_default ⇒ Object
- #locks ⇒ Object
- #schema_parse_table(table_name, options = {}) ⇒ Object
- #supports_create_table_if_not_exists? ⇒ Boolean
- #supports_drop_table_if_exists? ⇒ Boolean
- #supports_transaction_isolation_levels? ⇒ Boolean
- #tables(options = {}) ⇒ Object
Instance Method Details
#auto_increment_sql ⇒ Object
84 85 86 |
# File 'lib/sequel/adapters/vertica.rb', line 84 def auto_increment_sql AUTO_INCREMENT end |
#connect(server) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sequel/adapters/vertica.rb', line 28 def connect(server) opts = server_opts(server) ::Vertica::Connection.new( :host => opts[:host], :user => opts[:user], :password => opts[:password], :port => opts[:port], :schema => opts[:schema], :database => opts[:database], :read_timeout => opts[:read_timeout].nil? ? nil : opts[:read_timeout].to_i, :ssl => opts[:ssl] ) end |
#create_table_generator_class ⇒ Object
88 89 90 |
# File 'lib/sequel/adapters/vertica.rb', line 88 def create_table_generator_class Vertica::CreateTableGenerator end |
#execute(sql, opts = {}, &block) ⇒ Object Also known as: execute_dui
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/sequel/adapters/vertica.rb', line 42 def execute(sql, opts = {}, &block) res = nil synchronize(opts[:server]) do |conn| res = log_yield(sql) { conn.query(sql) } res.each(&block) end res rescue ::Vertica::Error => e raise_error(e) end |
#execute_insert(sql, opts = {}, &block) ⇒ Object
53 54 55 56 |
# File 'lib/sequel/adapters/vertica.rb', line 53 def execute_insert(sql, opts = {}, &block) result = execute(sql, opts, &block) result.first[:OUTPUT] end |
#identifier_input_method_default ⇒ Object
72 73 74 |
# File 'lib/sequel/adapters/vertica.rb', line 72 def identifier_input_method_default nil end |
#identifier_output_method_default ⇒ Object
76 77 78 |
# File 'lib/sequel/adapters/vertica.rb', line 76 def identifier_output_method_default nil end |
#locks ⇒ Object
80 81 82 |
# File 'lib/sequel/adapters/vertica.rb', line 80 def locks dataset.from(:v_monitor__locks) end |
#schema_parse_table(table_name, options = {}) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/sequel/adapters/vertica.rb', line 104 def schema_parse_table(table_name, = {}) schema = [:schema] selector = [:column_name, :constraint_name, :is_nullable.as(:allow_null), (:column_default).as(:default), (:data_type).as(:db_type)] filter = { :columns__table_name => table_name } filter[:columns__table_schema] = schema.to_s if schema dataset = . select(*selector). filter(filter). from(:v_catalog__columns). left_outer_join(:v_catalog__table_constraints, :table_id => :table_id) dataset.map do |row| row[:default] = nil if blank_object?(row[:default]) row[:type] = schema_column_type(row[:db_type]) row[:primary_key] = row.delete(:constraint_name) == PK_NAME [row.delete(:column_name).to_sym, row] end end |
#supports_create_table_if_not_exists? ⇒ Boolean
60 61 62 |
# File 'lib/sequel/adapters/vertica.rb', line 60 def supports_create_table_if_not_exists? true end |
#supports_drop_table_if_exists? ⇒ Boolean
64 65 66 |
# File 'lib/sequel/adapters/vertica.rb', line 64 def supports_drop_table_if_exists? true end |
#supports_transaction_isolation_levels? ⇒ Boolean
68 69 70 |
# File 'lib/sequel/adapters/vertica.rb', line 68 def supports_transaction_isolation_levels? true end |
#tables(options = {}) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/sequel/adapters/vertica.rb', line 92 def tables( = {}) schema = [:schema] filter = {} filter[:table_schema] = schema.to_s if schema dataset.select(:table_name). from(:v_catalog__tables). filter(filter). to_a. map { |h| h[:table_name].to_sym } end |