Class: ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/oracle_enhanced_adapter_patch.rb

Overview

interface independent methods

Instance Method Summary collapse

Instance Method Details

#columns_without_cache_with_pipelined(table, name) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/active_record/oracle_enhanced_adapter_patch.rb', line 17

def columns_without_cache_with_pipelined(table, name)
  begin
    return columns_without_cache_without_pipelined(table, name)
  rescue OracleEnhancedConnectionException => error
    # Will try to find a pipelined function
  end

  function_name, package_name = parse_function_name(table)

  if package_name
    function = plsql.send(package_name.downcase.to_sym)[function_name.downcase]
  else
    raise error.class, error.message
  end

  if function
     = function.arguments[0].sort_by {|arg| arg[1][:position]}
    arguments = .map do |(arg_name, argument)|
      OracleEnhancedColumn.new(arg_name.to_s, nil, argument[:data_type], table)
    end

    return_columns = function.return[:element][:fields].sort_by {|(col_name, col)| col[:position]}.map do |(col_name, )|
      .merge(name: col_name)
    end

    return_columns.map do |col|
      OracleEnhancedColumn.new(col[:name].to_s, nil, col[:data_type], table)
    end + arguments
  else
    raise error.class, error.message
  end
end

#parse_function_name(name) ⇒ Object



52
53
54
55
56
57
58
59
60
# File 'lib/active_record/oracle_enhanced_adapter_patch.rb', line 52

def parse_function_name(name)
  name = name.to_s.upcase
  # We can get name of function with calling syntax
  # Just extract function name
  if name =~ /\ATABLE\((([^.]+\.)[^.]+)\([^)]+\)\)\z/
    name = $1
  end
  name.split('.').reverse
end