sequel_oracle_extensions 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.4
1
+ 0.6.5
@@ -28,7 +28,7 @@ module Sequel
28
28
  def table_metadata(table,options={})
29
29
  columns = schema table, options
30
30
  attributes = columns.instance_eval{ remove_instance_variable :@features }
31
- attributes[:columns] = Hash[ columns ]
31
+ attributes[:columns] = columns
32
32
 
33
33
  # Collect table partitioning information, if applicable.
34
34
  if attributes[:partitioning]
@@ -39,14 +39,16 @@ module Sequel
39
39
  ds = ds.where :owner => schema unless schema.nil?
40
40
 
41
41
  # Basic partitioning info.
42
- attributes[:partitioning] = ds.
43
- select(:partitioning_type.as(:type), :interval, :subpartitioning_type.as(:subtype)).
44
- from(:"#{who}_part_tables").where(:table_name=>table).first
42
+ attributes[:partitioning] = Hash[
43
+ ds.select(:partitioning_type.as(:type), :interval, :subpartitioning_type.as(:subtype)).
44
+ from(:"#{who}_part_tables").first(:table_name=>table).
45
+ map{|k,v| [k, k==:interval ? v : v.downcase.to_sym] }
46
+ ]
45
47
 
46
48
  # Partitioning key column info.
47
- attributes[:partitioning][:key] = ds.
48
- select(:column_name).from(:"#{who}_part_key_columns").order(:column_position).
49
- where(:object_type=>'TABLE', :name=>table).map{|r| r.values.flatten }
49
+ attributes[:partitioning][:key] =
50
+ ds.select(:column_name).from(:"#{who}_part_key_columns").order(:column_position).
51
+ where(:object_type=>'TABLE', :name=>table).map{|r| outm[r.values.first] }
50
52
  end
51
53
 
52
54
  attributes
@@ -125,19 +127,13 @@ module Sequel
125
127
  order(:status.desc, :index_name, :ic__column_position)
126
128
  ds = ds.where :i__owner => schema, :c__index_owner => schema unless schema.nil?
127
129
  ds = ds.where :i__status => (opts[:valid] ? 'VALID' : 'UNUSABLE') unless opts[:valid].nil?
128
- unless opts[:all]
129
- pk = from(:"#{who}_constraints".as(:c)).where(:c__constraint_type=>'P').
130
- where(:c__index_name => :i__index_name)
131
- pk = pk.where :c__owner => schema unless schema.nil?
132
- ds = ds.where ~pk.exists
133
- end
134
130
 
135
131
  # Collect the indexes as a hash of subhashes, including a column list.
136
- # As a followup, collect any additional metadata about the indexes (such as bitmap join columns).
137
132
  hash, join_indexes = {}, []
138
133
  ds.each do |row|
139
134
  key = outm[row[:index_name]]
140
135
  unless subhash = hash[key]
136
+ # Unconditional attributes
141
137
  subhash = hash[key] = {
142
138
  :columns=>[], :unique=>(row[:uniqueness]=='UNIQUE'),
143
139
  :db_type=>row[:index_type], :logging=>(row[:logging]=='YES'),
@@ -145,28 +141,38 @@ module Sequel
145
141
  :tablespace=>outm[row[:tablespace_name]], :partitioned=>(row[:partitioned]=='YES'),
146
142
  :visible=>(row[:visibility]=='VISIBLE'), :compress=>(row[:compression]!='DISABLED')
147
143
  }
148
- case subhash[:db_type]
149
- when /\b(BITMAP|NORMAL|DOMAIN)$/
150
- subhash[:type] = $1.downcase.intern
151
- end
144
+
145
+ # Conditional attributes
146
+ subhash[:type] = $1.downcase.intern if subhash[:db_type] =~ /\b(BITMAP|NORMAL|DOMAIN)$/i
152
147
  subhash[:function_based] = true if /^FUNCTION-BASED\b/ === subhash[:db_type]
153
148
  subhash[:valid] = (row[:status]=='VALID') unless row[:status]=='N/A'
154
- if row[:join_index]=='YES'
155
- join_indexes << row[:index_name]
156
- subhash[:join] = []
157
- end
149
+ join_indexes << row[:index_name] and subhash[:join] = [] if row[:join_index]=='YES'
158
150
  end
159
151
  subhash[:columns] << outm[row[:column_name]]
160
152
  end
161
- ds = metadata_dataset.from(:"#{who}_join_ind_columns").where(:index_name=>join_indexes)
162
- ds = ds.where :index_owner => schema unless schema.nil?
163
- ds.each do |row|
164
- subhash = hash[outm[row[:index_name]]]
165
- ref_column = outm[row[:outer_table_column]]
166
- pos = subhash[:columns].index ref_column
167
- subhash[:columns][pos] = outm["#{row[:outer_table_name]}__#{ref_column}"]
168
- subhash[:join][pos] = outm[row[:inner_table_column]]
153
+
154
+ # Exclude the primary key index, if required and applicable.
155
+ # NOTE: Disabled primary keys do not use any indexes, so they are not applicable here.
156
+ if ! opts[:all] and pk = primary_key(table)
157
+ if pk[:using_index] then hash.delete pk[:using_index]
158
+ elsif pk[:enabled] then hash.delete_if {|k,v| v[:columns]==pk[:columns] }
159
+ end
169
160
  end
161
+
162
+ # Collect any additional metadata about the indexes (such as bitmap join columns).
163
+ unless join_indexes.empty?
164
+ ds = metadata_dataset.from(:"#{who}_join_ind_columns").where(:index_name=>join_indexes)
165
+ ds = ds.where :index_owner => schema unless schema.nil?
166
+ ds.each do |row|
167
+ subhash = hash[outm[row[:index_name]]]
168
+ ref_column = outm[row[:outer_table_column]]
169
+ pos = subhash[:columns].index ref_column
170
+ subhash[:columns][pos] = outm["#{row[:outer_table_name]}__#{ref_column}"]
171
+ subhash[:join][pos] = outm[row[:inner_table_column]]
172
+ end
173
+ end
174
+
175
+ # Done.
170
176
  hash
171
177
  end
172
178
 
@@ -444,6 +450,7 @@ module Sequel
444
450
  order(:table_name, :status.desc, :constraint_name, :cc__position)
445
451
  ds = ds.where :c__owner => schema unless schema.nil?
446
452
  ds = ds.where :c__status => (options[:enabled] ? 'ENABLED' : 'DISABLED') unless options[:enabled].nil?
453
+ ds = ds.where :c__validated => (options[:validated] ? 'VALIDATED' : 'NOT VALIDATED') unless options[:validated].nil?
447
454
  if constraint_type == 'R'
448
455
  ds = ds.select_more(:c__r_constraint_name, :t__table_name.as(:r_table_name)).
449
456
  join(:"#{x_cons}traints___t", [ [:owner,:c__r_owner], [:constraint_name,:c__r_constraint_name] ]).
@@ -451,7 +458,6 @@ module Sequel
451
458
  else
452
459
  ds = ds.select_more(:c__index_name)
453
460
  end
454
- ds = ds.limit(1) if constraint_type == 'P'
455
461
 
456
462
  # Return the table constraints as a hash of subhashes, including a column list.
457
463
  hash = {}
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sequel_oracle_extensions}
8
- s.version = "0.6.4"
8
+ s.version = "0.6.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Joe Khoobyar"]
12
- s.date = %q{2011-08-24}
11
+ s.authors = [%q{Joe Khoobyar}]
12
+ s.date = %q{2011-08-26}
13
13
  s.description = %q{Oracle extensions for Sequel, including MERGE statements, optimizer hints, and schema extensions.}
14
14
  s.email = %q{joe@ankhcraft.com}
15
15
  s.extra_rdoc_files = [
@@ -34,14 +34,9 @@ Gem::Specification.new do |s|
34
34
  "spec/spec_helper.rb"
35
35
  ]
36
36
  s.homepage = %q{http://github.com/joekhoobyar/sequel_oracle_extensions}
37
- s.require_paths = ["lib"]
38
- s.rubygems_version = %q{1.7.2}
37
+ s.require_paths = [%q{lib}]
38
+ s.rubygems_version = %q{1.8.8}
39
39
  s.summary = %q{Oracle MERGE, optimizer hints, and schema extensions for Sequel}
40
- s.test_files = [
41
- "spec/sequel/oracle_extensions/hints_spec.rb",
42
- "spec/sequel/oracle_extensions/merge_spec.rb",
43
- "spec/spec_helper.rb"
44
- ]
45
40
 
46
41
  if s.respond_to? :specification_version then
47
42
  s.specification_version = 3
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_oracle_extensions
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 4
10
- version: 0.6.4
9
+ - 5
10
+ version: 0.6.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joe Khoobyar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-24 00:00:00 Z
18
+ date: 2011-08-26 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: sequel
@@ -103,11 +103,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  requirements: []
104
104
 
105
105
  rubyforge_project:
106
- rubygems_version: 1.7.2
106
+ rubygems_version: 1.8.8
107
107
  signing_key:
108
108
  specification_version: 3
109
109
  summary: Oracle MERGE, optimizer hints, and schema extensions for Sequel
110
- test_files:
111
- - spec/sequel/oracle_extensions/hints_spec.rb
112
- - spec/sequel/oracle_extensions/merge_spec.rb
113
- - spec/spec_helper.rb
110
+ test_files: []
111
+