Skip to content

Instantly share code, notes, and snippets.

@quamen
Created August 26, 2011 06:18
Show Gist options
  • Select an option

  • Save quamen/1172821 to your computer and use it in GitHub Desktop.

Select an option

Save quamen/1172821 to your computer and use it in GitHub Desktop.
Raise on INSERT in the PostgreSQLAdapter
module ActiveRecord
module ConnectionAdapters
class PostgreSQLAdapter < AbstractAdapter
def execute(sql, name = nil)
if sql.split(' ').include?("INSERT")
raise "\nDon't write to the database in your unit tests\n #{sql}".red
end
log(sql, name) do
if @async
@connection.async_exec(sql)
else
@connection.exec(sql)
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment