Permalink
Browse files

Remove exception dependency on Mysql and ActiveRecord, and make it work

with mysql2 (by not using fetch_row)
  • Loading branch information...
1 parent 9fe3eef commit 6eb665df37a4254a469ca3c053b195fbbf0b9b35 @tiegz tiegz committed Mar 16, 2012
Showing with 7 additions and 3 deletions.
  1. +2 −2 lib/lhm/sql_helper.rb
  2. +5 −1 lib/lhm/table.rb
View
@@ -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
View
@@ -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

0 comments on commit 6eb665d

Please sign in to comment.