diff options
author | Ralph Amissah <ralph@amissah.com> | 2014-05-18 09:39:31 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2014-05-18 09:39:31 -0400 |
commit | 808c9c74a72b95e6272c8927cce839d89626ba47 (patch) | |
tree | 8047b7cee667ca0c2b6b9bb12a4c3e33a34704fa /lib/sisu/v5/db_drop.rb | |
parent | debian/changelog (5.3.5-1) (diff) | |
parent | v5 v6: cgi, sample search forms: use ruby-pg & ruby-sqlite3; remove ruby-dbi (diff) |
Merge tag 'sisu_5.3.6' into debian/sid
SiSU 5.3.6
Diffstat (limited to 'lib/sisu/v5/db_drop.rb')
-rw-r--r-- | lib/sisu/v5/db_drop.rb | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/lib/sisu/v5/db_drop.rb b/lib/sisu/v5/db_drop.rb index b1ff634e..75e98faa 100644 --- a/lib/sisu/v5/db_drop.rb +++ b/lib/sisu/v5/db_drop.rb @@ -64,11 +64,11 @@ module SiSU_DbDrop class Drop require_relative 'response' # response.rb - def initialize(opt,conn,db_info,sql_type='') + def initialize(opt,conn,db_info,sql_type) @opt,@conn,@db_info,@sql_type=opt,conn,db_info,sql_type @ans=SiSU_Response::Response.new case @sql_type - when /sqlite/ + when :sqlite cascade='' else cascade='CASCADE' @@ -87,7 +87,7 @@ module SiSU_DbDrop begin msg_sqlite="as not all disk space is recovered after dropping the database << #{@db_info.sqlite.db} >>, you may be better off deleting the file, and recreating it as necessary" case @sql_type - when /sqlite/ + when :sqlite puts msg_sqlite ans=@ans.response?('remove sql database?') if ans \ @@ -118,24 +118,38 @@ module SiSU_DbDrop else @conn.transaction @drop_table.each do |d| - @conn.execute(d) - end + begin + @conn.exec_params(d) + rescue + next + end + end @conn.commit end - else + when :pg + @conn.transaction @drop_table.each do |d| - @conn.execute(d) + begin + @conn.exec_params(d) + rescue + next + end end + @conn.commit end rescue case @sql_type - when /sqlite/ + when :sqlite ans=@ans.response?('remove sql database?') if ans and File.exist?(@db_info.sqlite.db); File.unlink(@db_info.sqlite.db) end else @drop_table.each do |d| - @conn.execute(d) + begin + @conn.exec_params(d) + rescue + next + end end end ensure @@ -145,7 +159,11 @@ module SiSU_DbDrop def conn_execute_array(sql_arr) @conn.transaction do |conn| sql_arr.each do |sql| - conn.execute(sql) + begin + conn.exec_params(sql) + rescue + next + end end end end |