sequel_oracle_extensions 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/sequel/oracle_extensions/schemata.rb +26 -8
- data/sequel_oracle_extensions.gemspec +2 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
@@ -41,19 +41,37 @@ ORDER BY status DESC, constraint_name, cc.position
|
|
41
41
|
ixs
|
42
42
|
end
|
43
43
|
|
44
|
-
# Returns the primary key for the given table.
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
# Returns the primary key for the given table, as a hash.
|
45
|
+
#
|
46
|
+
# * <tt>:enabled</tt> - Only look for keys that are enabled (true) or disabled (false). By default (nil),
|
47
|
+
# looks for all matching keys.
|
48
|
+
# * <tt>:all</tt> - Returns all matching keys. By default, returns the first matching key - provided
|
49
|
+
# that either there is only one key or that only the key is enabled.
|
50
|
+
# * <tt>:first</tt> - Returns the first matching key.
|
51
|
+
def primary_key(table, options={})
|
52
|
+
sql, m = SELECT_PRIMARY_KEY_SQL, output_identifier_meth
|
53
|
+
table, pks = m[table], []
|
54
|
+
pkh = Hash.new{|h,k| pks.push(h[k]=v={:table_name=>table, :columns=>[]}); v }
|
55
|
+
|
56
|
+
unless (z = options[:enabled]).nil?
|
57
|
+
sql = sql.sub /WHERE /, "WHERE c.status = #{z ? 'ENABLED' : 'DISABLED'}"
|
58
|
+
end
|
59
|
+
|
60
|
+
metadata_dataset.with_sql(sql, table.to_s.upcase).each do |r|
|
61
|
+
if options[:first] && pks.length==1 && r[:constraint_name] != pks[:constraint_name]
|
62
|
+
return pks.first
|
63
|
+
end
|
64
|
+
|
50
65
|
r = Hash[ r.map{|k,v| [k, (k==:status || v.nil? || v=='') ? v : m[v]]} ]
|
51
|
-
pk =
|
66
|
+
pk = pkh[m.call r[:constraint_name]]
|
52
67
|
pk[:enabled] = r.delete(:status)=='ENABLED'
|
53
68
|
pk[:columns] << r.delete(:column_name)
|
54
69
|
pk.update r
|
55
70
|
end
|
56
|
-
|
71
|
+
|
72
|
+
unless options[:all] or (pks.length>1 and pks[0][:enabled] != pks[1][:enabled])
|
73
|
+
return pks.first
|
74
|
+
end
|
57
75
|
pks
|
58
76
|
end
|
59
77
|
end
|
@@ -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.5.
|
8
|
+
s.version = "0.5.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Joe Khoobyar"]
|
12
|
-
s.date = %q{2010-05-
|
12
|
+
s.date = %q{2010-05-27}
|
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 = [
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 0.5.
|
8
|
+
- 1
|
9
|
+
version: 0.5.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Joe Khoobyar
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-27 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|