26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/rubeus/extensions/java/sql/database_meta_data.rb', line 26
def table_objects(options = nil)
options = {
:catalog => nil,
:schema => nil,
:schema_pattern => nil,
:table => nil,
:table_name => nil,
:table_name_pattern => nil,
:name_case => nil }.update(options || {})
catalog = options[:catalog]
schema_pattern = options[:schema_pattern] || options[:schema]
table_name_pattern = options[:table_name_pattern] || options[:table_name] || options[:table]
@table_objects ||= {}
unless table_name_pattern.nil?
key = [catalog, schema_pattern, table_name_pattern].map{|s| s.nil? ? nil : s.to_s.upcase}
cached = @table_objects[key]
return [cached] if cached
end
tables = getTables(catalog, schema_pattern, table_name_pattern, nil).map do |rs|
Rubeus::Jdbc::Table.new(self, rs.to_hash, options)
end
tables = Rubeus::Util::NameAccessArray.new(*tables)
columns = getColumns(catalog, schema_pattern, table_name_pattern, nil).map{|r| r.to_hash}
tables.each do |table|
table.columns = Rubeus::Util::NameAccessArray.new(
*columns.
select{|hash|table.same_fqn?(hash)}.
map{|hash| Rubeus::Jdbc::Column.new(self, table, hash, options)})
end
tables.each{|t| @table_objects[t.fqn] = t}
tables
end
|