Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow spaces in postgres table names #34561

Merged
merged 1 commit into from Nov 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions 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
Expand Down
Expand Up @@ -68,7 +68,7 @@ module Utils # :nodoc:
# * <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
Expand Down
5 changes: 5 additions & 0 deletions activerecord/test/cases/adapters/postgresql/quoting_test.rb
Expand Up @@ -39,6 +39,11 @@ def test_quote_bit_string
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
Expand Down