Permalink
Browse files

Fixed that SQLite3 exceptions are caught and reported properly #823 […

…yerejm]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@909 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 066988d commit bfa6bfc24a0034ae599861a6e8655df024973eed @dhh dhh committed Mar 14, 2005
View
@@ -1,5 +1,7 @@
*SVN*
+* Fixed that SQLite3 exceptions are caught and reported properly #823 [yerejm]
+
* Added that all types of after_find/after_initialized callbacks are triggered if the explicit implementation is present, not only the explicit implementation itself
* Fixed that symbols can be used on attribute assignment, like page.emails.create(:subject => data.subject, :body => data.body)
@@ -405,7 +405,7 @@ def log(sql, name, connection = nil)
log_info(sql, name, 0)
nil
end
- rescue => e
+ rescue Exception => e
log_info("#{e.message}: #{sql}", name, 0)
raise ActiveRecord::StatementInvalid, "#{e.message}: #{sql}"
end
@@ -453,4 +453,4 @@ def column(name, type, options = {})
end
end
end
-end
+end
@@ -13,7 +13,7 @@ class SqliteError < StandardError
def make_connection(clazz, db_file, db_definitions_file)
unless File.exist?(db_file)
puts "SQLite database not found at #{db_file}. Rebuilding it."
- sqlite_command = "sqlite #{db_file} 'create table a (a integer); drop table a;'"
+ sqlite_command = %Q{sqlite #{db_file} "create table a (a integer); drop table a;"}
puts "Executing '#{sqlite_command}'"
raise SqliteError.new("Seems that there is no sqlite executable available") unless system(sqlite_command)
clazz.establish_connection(
@@ -13,7 +13,7 @@ class SqliteError < StandardError
def make_connection(clazz, db_file, db_definitions_file)
unless File.exist?(db_file)
puts "SQLite3 database not found at #{db_file}. Rebuilding it."
- sqlite_command = "sqlite3 #{db_file} 'create table a (a integer); drop table a;'"
+ sqlite_command = %Q{sqlite3 #{db_file} "create table a (a integer); drop table a;"}
puts "Executing '#{sqlite_command}'"
raise SqliteError.new("Seems that there is no sqlite3 executable available") unless system(sqlite_command)
clazz.establish_connection(
@@ -233,6 +233,10 @@ def test_find_all_by_nil_and_not_nil_attributes
assert_equal "Mary", topics[0].author_name
end
+ def test_find_with_bad_sql
+ assert_raises(ActiveRecord::StatementInvalid) { Topic.find_by_sql "select 1 from badtable" }
+ end
+
protected
def bind(statement, *vars)
if vars.first.is_a?(Hash)

0 comments on commit bfa6bfc

Please sign in to comment.