table_saw 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/.travis.yml +3 -1
- data/Gemfile.lock +1 -1
- data/lib/table_saw/dependency_graph/add_directive.rb +3 -2
- data/lib/table_saw/dependency_graph/build.rb +2 -1
- data/lib/table_saw/dependency_graph/has_many_directives.rb +4 -1
- data/lib/table_saw/information_schema.rb +0 -2
- data/lib/table_saw/manifest.rb +6 -4
- data/lib/table_saw/queries/foreign_key_relationships.rb +0 -2
- data/lib/table_saw/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33d3ff20492080ac1eb74a93466aa8c1d2b6f52b192b1b9fee8744a1755e6e2c
|
4
|
+
data.tar.gz: c1f5f2908a7b1f894e56696da3a3d37efb28ad9567527dc65ec57a7991506c11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 260d2f1af458bc4ed939a647e206cd1bb9cab56211ea1031e2abb5c002fa0e22981b497d6f6a350207d540f5be522600ae2f1b87cc880476b136ffb05219497f
|
7
|
+
data.tar.gz: a0e4e17955719d75410b173c8a85052d036c434fb0c88da3a1cdd623a75c7b3fca3eaa2c9e1f756f3ffa8440151eb2d94b9c9a5d9e2facbeeb036b98b3f19a76
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -3,13 +3,14 @@
|
|
3
3
|
module TableSaw
|
4
4
|
module DependencyGraph
|
5
5
|
class AddDirective
|
6
|
-
attr_reader :table_name, :partial
|
6
|
+
attr_reader :table_name, :partial, :has_many
|
7
7
|
attr_accessor :ids
|
8
8
|
|
9
|
-
def initialize(table_name, ids: [], partial: true)
|
9
|
+
def initialize(table_name, ids: [], partial: true, has_many: [])
|
10
10
|
@table_name = table_name
|
11
11
|
@ids = ids
|
12
12
|
@partial = partial
|
13
|
+
@has_many = has_many
|
13
14
|
end
|
14
15
|
|
15
16
|
alias partial? partial
|
@@ -12,7 +12,8 @@ module TableSaw
|
|
12
12
|
|
13
13
|
def call
|
14
14
|
manifest.tables.values.sort_by { |t| t.partial? ? 1 : 0 }.each do |table|
|
15
|
-
add TableSaw::DependencyGraph::AddDirective.new(table.name, ids: select_ids(table), partial: table.partial
|
15
|
+
add TableSaw::DependencyGraph::AddDirective.new(table.name, ids: select_ids(table), partial: table.partial?,
|
16
|
+
has_many: table.has_many)
|
16
17
|
end
|
17
18
|
|
18
19
|
records
|
@@ -26,13 +26,16 @@ module TableSaw
|
|
26
26
|
TableSaw.information_schema.has_many.fetch(directive.table_name, [])
|
27
27
|
end
|
28
28
|
|
29
|
+
# rubocop:disable Metrics/AbcSize
|
29
30
|
def valid_associations
|
30
31
|
associations.select do |table, _column|
|
31
32
|
next false if directive.partial? && !TableSaw.information_schema.primary_keys.key?(table)
|
33
|
+
next true if directive.has_many.include?(table)
|
32
34
|
|
33
|
-
manifest.
|
35
|
+
manifest.has_many.fetch(directive.table_name, []).include?(table)
|
34
36
|
end
|
35
37
|
end
|
38
|
+
# rubocop:enable Metrics/AbcSize
|
36
39
|
|
37
40
|
def query_result(table, column)
|
38
41
|
return [] unless directive.selectable?
|
@@ -6,11 +6,9 @@ module TableSaw
|
|
6
6
|
foreign_key_relationships.belongs_to
|
7
7
|
end
|
8
8
|
|
9
|
-
# rubocop:disable Naming/PredicateName
|
10
9
|
def has_many
|
11
10
|
foreign_key_relationships.has_many
|
12
11
|
end
|
13
|
-
# rubocop:enable Naming/PredicateName
|
14
12
|
|
15
13
|
def primary_keys
|
16
14
|
@primary_keys ||= TableSaw::Queries::PrimaryKeys.new.call
|
data/lib/table_saw/manifest.rb
CHANGED
@@ -27,6 +27,10 @@ module TableSaw
|
|
27
27
|
def partial?
|
28
28
|
config.key?('query')
|
29
29
|
end
|
30
|
+
|
31
|
+
def has_many
|
32
|
+
config.fetch('has_many', [])
|
33
|
+
end
|
30
34
|
end
|
31
35
|
|
32
36
|
def self.instance
|
@@ -51,10 +55,8 @@ module TableSaw
|
|
51
55
|
end
|
52
56
|
end
|
53
57
|
|
54
|
-
|
55
|
-
|
56
|
-
@has_many_mapping ||= config.fetch('has_many', {})
|
58
|
+
def has_many
|
59
|
+
@has_many ||= config.fetch('has_many', {})
|
57
60
|
end
|
58
|
-
# rubocop:enable Naming/PredicateName
|
59
61
|
end
|
60
62
|
end
|
@@ -21,13 +21,11 @@ module TableSaw
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
# rubocop:disable Naming/PredicateName
|
25
24
|
def has_many
|
26
25
|
@has_many ||= result.each_with_object(Hash.new { |h, k| h[k] = [] }) do |row, memo|
|
27
26
|
memo[row['to_table']].push([row['from_table'], row['from_column']])
|
28
27
|
end
|
29
28
|
end
|
30
|
-
# rubocop:enable Naming/PredicateName
|
31
29
|
|
32
30
|
private
|
33
31
|
|
data/lib/table_saw/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table_saw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hamed Asghari
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: connection_pool
|