diff options
author | José Valim <jose.valim@gmail.com> | 2011-04-29 19:55:33 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-04-29 20:30:20 +0200 |
commit | 58ad5e1859caa5e384cc3df2360efc3cfd66c48b (patch) | |
tree | 4f3bf8c9d928cfd3a635c45042940e7ccded5c91 | |
parent | 146474256cf2f09f9706980032688b2c7d484e24 (diff) | |
download | rails-58ad5e1859caa5e384cc3df2360efc3cfd66c48b.tar.gz rails-58ad5e1859caa5e384cc3df2360efc3cfd66c48b.tar.bz2 rails-58ad5e1859caa5e384cc3df2360efc3cfd66c48b.zip |
Make postgresql faster on development (thanks to @tapajos).
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 255da7d183..b1f2f93462 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -122,6 +122,14 @@ module ActiveRecord # Extracts the value from a PostgreSQL column default definition. def self.extract_value_from_default(default) case default + # This is a performance optimization for Ruby 1.9.2 in development. + # If the value is nil, we return nil straight away without checking + # the regular expressions. If we check each regular expression, + # Regexp#=== will call NilClass#to_str, which will trigger + # method_missing (defined by whiny nil in ActiveSupport) which + # makes this method very very slow. + when NilClass + nil # Numeric types when /\A\(?(-?\d+(\.\d*)?\)?)\z/ $1 |