diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2018-11-28 17:48:10 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-28 17:48:10 -0500 |
commit | 7d0c8ebe3550b52f750e249dd8ea312327d26d39 (patch) | |
tree | 4d25e2a5d5d90a8da453c9a2c84cedd104c4802d | |
parent | a01e0d0fabeef83e690f6eaf714ecd28b8f211a7 (diff) | |
parent | 03fadebe0ed1fd384a14e46ba4c828b9a36ab4bf (diff) | |
download | rails-7d0c8ebe3550b52f750e249dd8ea312327d26d39.tar.gz rails-7d0c8ebe3550b52f750e249dd8ea312327d26d39.tar.bz2 rails-7d0c8ebe3550b52f750e249dd8ea312327d26d39.zip |
Merge pull request #34561 from gmcgibbon/allow_spaces_in_table_names
Allow spaces in postgres table names
-rw-r--r-- | activerecord/CHANGELOG.md | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/utils.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/quoting_test.rb | 5 |
3 files changed, 12 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 9d7bfbcef1..d32c6c3c5d 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,9 @@ +* Allow spaces in postgres table names. + + Fixes issue where "user post" is misinterpreted as "\"user\".\"post\"" when quoting table names with the postgres adapter. + + *Gannon McGibbon* + * Cached columns_hash fields should be excluded from ResultSet#column_types PR #34528 addresses the inconsistent behaviour when attribute is defined for an ignored column. The following test diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/utils.rb b/activerecord/lib/active_record/connection_adapters/postgresql/utils.rb index bfd300723d..f2f4701500 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/utils.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/utils.rb @@ -68,7 +68,7 @@ module ActiveRecord # * <tt>"schema_name".table_name</tt> # * <tt>"schema.name"."table name"</tt> def extract_schema_qualified_name(string) - schema, table = string.scan(/[^".\s]+|"[^"]*"/) + schema, table = string.scan(/[^".]+|"[^"]*"/) if table.nil? table = schema schema = nil diff --git a/activerecord/test/cases/adapters/postgresql/quoting_test.rb b/activerecord/test/cases/adapters/postgresql/quoting_test.rb index d50dc49276..d571355a9c 100644 --- a/activerecord/test/cases/adapters/postgresql/quoting_test.rb +++ b/activerecord/test/cases/adapters/postgresql/quoting_test.rb @@ -39,6 +39,11 @@ module ActiveRecord type = OID::Bit.new assert_nil @conn.quote(type.serialize(value)) end + + def test_quote_table_name_with_spaces + value = "user posts" + assert_equal "\"user posts\"", @conn.quote_table_name(value) + end end end end |