flattendb 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/lib/flattendb/types/mdb.rb +1 -5
- data/lib/flattendb/types/mysql.rb +7 -6
- data/lib/flattendb/version.rb +1 -1
- metadata +5 -5
data/README
CHANGED
data/lib/flattendb/types/mdb.rb
CHANGED
@@ -47,11 +47,7 @@ module FlattenDB
|
|
47
47
|
abort "Command not found: #{cmd}! Please install `mdbtools' first."
|
48
48
|
}
|
49
49
|
|
50
|
-
|
51
|
-
%x{mdb-tables -1 #{database}}.split($/).each { |table|
|
52
|
-
FasterCSV.parse(%x{mdb-export #{database} #{table}}, :headers => true)
|
53
|
-
}
|
54
|
-
}
|
50
|
+
# ...
|
55
51
|
end
|
56
52
|
|
57
53
|
def flatten!(options = {}, builder_options = {})
|
@@ -164,15 +164,16 @@ module FlattenDB
|
|
164
164
|
def inject_foreign(tables, primary_table, foreign_table, local_key, foreign_key = local_key, foreign_tables = tables, foreign_table_name = foreign_table)
|
165
165
|
raise ArgumentError, "no such foreign table: #{foreign_table}" unless foreign_tables.has_key?(foreign_table)
|
166
166
|
|
167
|
-
foreign_rows =
|
167
|
+
foreign_rows = Hash.new { |h, k| h[k] = [] }
|
168
|
+
|
169
|
+
foreign_tables[foreign_table].each { |foreign_row|
|
170
|
+
foreign_rows[foreign_row[foreign_key]] << foreign_row
|
171
|
+
}
|
168
172
|
|
169
173
|
tables[primary_table].each { |row|
|
170
174
|
if row.has_key?(local_key)
|
171
|
-
|
172
|
-
|
173
|
-
}
|
174
|
-
|
175
|
-
row[foreign_table_name] = foreign_content unless foreign_content.empty?
|
175
|
+
rows = foreign_rows[row[local_key]]
|
176
|
+
row[foreign_table_name] = rows unless rows.empty?
|
176
177
|
end
|
177
178
|
}
|
178
179
|
end
|
data/lib/flattendb/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flattendb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jens Wille
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-07-
|
18
|
+
date: 2011-07-18 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: libxml-ruby
|
@@ -118,7 +118,7 @@ rdoc_options:
|
|
118
118
|
- --main
|
119
119
|
- README
|
120
120
|
- --title
|
121
|
-
- flattendb Application documentation (v0.1.
|
121
|
+
- flattendb Application documentation (v0.1.2)
|
122
122
|
- --line-numbers
|
123
123
|
- --all
|
124
124
|
require_paths:
|