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
This commit is contained in:
David Heinemeier Hansson 2005-03-14 23:48:39 +00:00
parent 066988d2f3
commit bfa6bfc24a
5 changed files with 10 additions and 4 deletions

View File

@ -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)

View File

@ -405,7 +405,7 @@ module ActiveRecord
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 @@ module ActiveRecord
end
end
end
end
end

View File

@ -13,7 +13,7 @@ sqlite_test_db2 = "#{BASE_DIR}/fixture_database_2.sqlite"
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(

View File

@ -13,7 +13,7 @@ sqlite_test_db2 = "#{BASE_DIR}/fixture_database_2.sqlite3"
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(

View File

@ -233,6 +233,10 @@ class FinderTest < Test::Unit::TestCase
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)