torque-postgresql 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/torque/postgresql/schema_cache.rb +16 -6
- data/lib/torque/postgresql/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6422949dcd6390bea82ed290528491efd5b0effe
|
4
|
+
data.tar.gz: 797f069fd9b3a3207e39abfc781fc9c816ef3e72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf0c65ecca84216b3cf185fbeb4b5c4ef15de3a1e793a9071bf47e37dc0467ee6278ad4caba2db041874b39a3164689f3daa34b012055f38b82d52818ac3f487
|
7
|
+
data.tar.gz: 76d427aa302b392caa4552107f23252acb6c18608de0692b607f407e56c2fe5bba6a07fce2688708c702cd42c4b97e167bb331ab1098064a55c1b876975edc8e
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Torque
|
2
2
|
module PostgreSQL
|
3
|
+
LookupError = Class.new(ArgumentError)
|
4
|
+
|
3
5
|
# :TODO: Create the +add+ to load inheritance info
|
4
6
|
module SchemaCache
|
5
7
|
|
@@ -41,7 +43,7 @@ module Torque
|
|
41
43
|
@data_sources_model_names.delete name
|
42
44
|
@inheritance_dependencies.delete name
|
43
45
|
@inheritance_associations.delete name
|
44
|
-
@inheritance_cache
|
46
|
+
@inheritance_cache = inheritance_cache_key
|
45
47
|
end
|
46
48
|
|
47
49
|
def marshal_dump # :nodoc:
|
@@ -102,7 +104,11 @@ module Torque
|
|
102
104
|
scopes.pop
|
103
105
|
end
|
104
106
|
|
105
|
-
|
107
|
+
# If this part is reach, no model name was found
|
108
|
+
raise LookupError.new(<<~MSG.squish)
|
109
|
+
Unable to find a valid model that is associated with the '#{table_name}' table.
|
110
|
+
Please, check if they correctly inherit from ActiveRecord::Base
|
111
|
+
MSG
|
106
112
|
end
|
107
113
|
|
108
114
|
private
|
@@ -125,10 +131,14 @@ module Torque
|
|
125
131
|
# Now iterate over
|
126
132
|
while (condition = conditions.shift)
|
127
133
|
ns_places.each{ |i| pieces[i] = condition.include?(i) ? '::' : '' }
|
128
|
-
|
134
|
+
|
135
|
+
candidate = pieces.join
|
136
|
+
candidate.prepend("#{scope.name}::") unless scope === Object
|
137
|
+
|
138
|
+
klass = candidate.safe_constantize
|
139
|
+
next if klass.nil?
|
129
140
|
|
130
141
|
# Check if the class match the table name
|
131
|
-
klass = scope.const_get(pieces.join)
|
132
142
|
return klass if klass < ::ActiveRecord::Base && klass.table_name == table_name
|
133
143
|
end
|
134
144
|
end
|
@@ -146,8 +156,8 @@ module Torque
|
|
146
156
|
return unless @inheritance_cache != cache_key
|
147
157
|
@inheritance_cache = cache_key
|
148
158
|
|
149
|
-
@inheritance_dependencies = connection.inherited_tables
|
150
|
-
@inheritance_associations = generate_associations
|
159
|
+
@inheritance_dependencies = connection.inherited_tables
|
160
|
+
@inheritance_associations = generate_associations
|
151
161
|
end
|
152
162
|
|
153
163
|
# Calculates the inverted dependency (association), where even indirect
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: torque-postgresql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|