aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2017-05-29 00:07:17 +0930
committerGitHub <noreply@github.com>2017-05-29 00:07:17 +0930
commit919bc57747924d77700db656ab7be34f4ff3a61f (patch)
tree40dbf8dc9ccff4919b72c7c516ab3dc1f72fad08 /activerecord/lib
parent7eb66b1617d9bda33860ce9869b07ff1a98fbef3 (diff)
parentb731f598fc076acbcaeb273636e646dfebeef796 (diff)
downloadrails-919bc57747924d77700db656ab7be34f4ff3a61f.tar.gz
rails-919bc57747924d77700db656ab7be34f4ff3a61f.tar.bz2
rails-919bc57747924d77700db656ab7be34f4ff3a61f.zip
Merge pull request #29253 from kamipo/prevent_extra_query
Prevent extra `current_database` query for `encoding`/`collation`/`ctype`
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
index 5b483ad4ab..3eff9e2f83 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
@@ -186,17 +186,17 @@ module ActiveRecord
# Returns the current database encoding format.
def encoding
- select_value("SELECT pg_encoding_to_char(encoding) FROM pg_database WHERE datname LIKE '#{current_database}'", "SCHEMA")
+ select_value("SELECT pg_encoding_to_char(encoding) FROM pg_database WHERE datname = current_database()", "SCHEMA")
end
# Returns the current database collation.
def collation
- select_value("SELECT datcollate FROM pg_database WHERE datname LIKE '#{current_database}'", "SCHEMA")
+ select_value("SELECT datcollate FROM pg_database WHERE datname = current_database()", "SCHEMA")
end
# Returns the current database ctype.
def ctype
- select_value("SELECT datctype FROM pg_database WHERE datname LIKE '#{current_database}'", "SCHEMA")
+ select_value("SELECT datctype FROM pg_database WHERE datname = current_database()", "SCHEMA")
end
# Returns an array of schema names.