load_data_infile 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/load_data_infile.rb +11 -11
  3. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.3.0
@@ -66,33 +66,33 @@ module LoadDataInfile
66
66
 
67
67
  c.file_name = quote_value options[:path]
68
68
 
69
- c.replace_or_ignore = options[:on_duplicates] if options[:on_duplicates] # REPLACE or IGNORE
69
+ c.replace_or_ignore = options[:on_duplicates] if [:REPLACE, :IGNORE].include?(options[:on_duplicates])
70
70
 
71
71
  c.table_name = options[:table] ? "`#{ options[:table] }`" : quoted_table_name
72
72
 
73
- c.charset = "CHARACTER SET #{quote_value options[:charset]}" if options[:charset]
73
+ c.charset = "CHARACTER SET #{options[:charset]}" if options[:charset]
74
74
 
75
75
  if options[:terminated_by] || options[:enclosed_by] || options[:optionally_enclosed_by] || options[:escaped_by]
76
76
  c.fields_definitions = " FIELDS " # or COLUMNS
77
- c.fields_definitions << " TERMINATED BY #{ quote_value options[:terminated_by] } " if options[:terminated_by]
78
- c.fields_definitions << " ENCLOSED BY #{ quote_value options[:enclosed_by] } " if options[:enclosed_by]
79
- c.fields_definitions << " OPTIONALLY ENCLOSED BY #{ quote_value options[:optionally_enclosed_by] } " if options[:optionally_enclosed_by]
80
- c.fields_definitions << " ESCAPED BY #{ quote_value options[:escaped_by] } " if options[:escaped_by]
77
+ c.fields_definitions << " TERMINATED BY '#{ options[:terminated_by] }' " if options[:terminated_by]
78
+ c.fields_definitions << " ENCLOSED BY '#{ options[:enclosed_by] }' " if options[:enclosed_by]
79
+ c.fields_definitions << " OPTIONALLY ENCLOSED BY '#{ options[:optionally_enclosed_by] }' " if options[:optionally_enclosed_by]
80
+ c.fields_definitions << " ESCAPED BY '#{ options[:escaped_by] }' " if options[:escaped_by]
81
81
  end
82
82
 
83
83
  if options[:lines_terminated_by] || options[:lines_starting_by]
84
84
  c.lines_defitions = " LINES "
85
- c.lines_defitions << " STARTING BY #{quote_value options[:lines_starting_by]} " if options[:lines_starting_by]
86
- c.lines_defitions << " TERMINATED BY #{quote_value options[:lines_terminated_by]} " if options[:lines_terminated_by]
85
+ c.lines_defitions << " STARTING BY '#{options[:lines_starting_by]}' " if options[:lines_starting_by]
86
+ c.lines_defitions << " TERMINATED BY '#{options[:lines_terminated_by]}' " if options[:lines_terminated_by]
87
87
  end
88
88
 
89
- c.ignores = "IGNORE #{options[:ignore]} LINES" if options[:ignore]
89
+ c.ignores = "IGNORE #{options[:ignore].to_i} LINES" if options[:ignore].to_i > 0
90
90
 
91
91
  c.columns = " (#{options[:columns].join(", ")}) " if options[:columns]
92
92
 
93
93
  if options[:mappings] && options[:mappings].length > 0
94
- s = options[:mappings].map{|column, mapping| "#{column} = #{mapping}" }.join(",")
95
- c.mappings = "SET #{s}"
94
+ s = options[:mappings].map{|column, mapping| "#{column} = #{mapping}" }.join(", ")
95
+ c.mappings = " SET #{s} "
96
96
  end
97
97
 
98
98
  disable_keys(c.table_name) if disable_keys_option
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- - 1
9
- version: 0.2.1
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Emmanuel Oga