Class: Ruport::Query::SqlSplit
- Defined in:
- lib/ruport/query/sql_split.rb
Overview
This class properly splits up multi-statement SQL input for use with Ruby/DBI
Instance Method Summary collapse
-
#initialize(sql) ⇒ SqlSplit
constructor
A new instance of SqlSplit.
Methods inherited from Array
Constructor Details
#initialize(sql) ⇒ SqlSplit
Returns a new instance of SqlSplit.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ruport/query/sql_split.rb', line 16 def initialize( sql ) super() next_sql = '' sql.each do |line| unless line =~ /^--/ or line =~ %r{^/\*.*\*/;} or line =~ /^\s*$/ next_sql << line if line =~ /;$/ next_sql.gsub!( /;\s$/, '' ) self << next_sql next_sql = '' end end end self << next_sql if next_sql != '' end |