Created
August 26, 2011 06:18
-
-
Save quamen/1172821 to your computer and use it in GitHub Desktop.
Raise on INSERT in the PostgreSQLAdapter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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