Skip to content

Commit

Permalink
Remove exception dependency on Mysql and ActiveRecord, and make it work
Browse files Browse the repository at this point in the history
with mysql2 (by not using fetch_row)
  • Loading branch information
tiegz committed Mar 16, 2012
1 parent 9fe3eef commit 6eb665d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/lhm/sql_helper.rb
Expand Up @@ -28,15 +28,15 @@ def sql(statements)
[statements].flatten.each do |statement|
connection.execute(tagged(statement))
end
rescue ActiveRecord::StatementInvalid, Mysql::Error => e
rescue => e
error e.message
end

def update(statements)
[statements].flatten.inject(0) do |memo, statement|
memo += connection.update(tagged(statement))
end
rescue ActiveRecord::StatementInvalid, Mysql::Error => e
rescue => e
error e.message
end

Expand Down
6 changes: 5 additions & 1 deletion lib/lhm/table.rb
Expand Up @@ -38,7 +38,11 @@ def initialize(table_name, connection)

def ddl
sql = "show create table `#{ @table_name }`"
@connection.execute(sql).fetch_row.last
results = []
@connection.execute(sql).each(:as => :array) do |r|
results << r
end
results.first.last
end

def parse
Expand Down

0 comments on commit 6eb665d

Please sign in to comment.