diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2019-07-07 10:04:35 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2019-07-07 14:49:48 +0900 |
commit | aec52c0d1e82c1a9c5c0c4f2674f64d373330a53 (patch) | |
tree | ebe2b9d8c7d65b0d45e10098c1ac28cce025f4df /activerecord/test/cases/defaults_test.rb | |
parent | 74ef67b16de67d2ae2f996e50a18a93aebf68fe6 (diff) | |
download | rails-aec52c0d1e82c1a9c5c0c4f2674f64d373330a53.tar.gz rails-aec52c0d1e82c1a9c5c0c4f2674f64d373330a53.tar.bz2 rails-aec52c0d1e82c1a9c5c0c4f2674f64d373330a53.zip |
Make "bin/setup" works when using PostgreSQL with locales other than en locale
The PostgreSQL adapter uses an error message to determine if a database
exists or not.
https://github.com/rails/rails/blob/74ef67b16de67d2ae2f996e50a18a93aebf68fe6/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb#L49
However, this message is properly converted according to the locale.
So this check does not work correctly for non-en locales.
As a result, `db:prepare` cannot correctly determine if a database exists, and
`bin/setup`, which depends on the task, does not work correctly if the database
does not exist.
It checks to exist if the "does not exist" exists, but that message is also
used in other error messages(e.g. "role does not exist"). So cannot check
correctly also in en locale.
https://github.com/postgres/postgres/blob/master/src/backend/po/ja.po#L10542
It would be fine could check the status, but in my understanding, when a connecting
fails, only the status `CONNECTION_BAD` be used, and it seems that details cannot
be checked.
https://www.postgresql.org/docs/11/libpq-status.html#LIBPQ-PQSTATUS
I fixed to check whether the error message contains a database
name. This is probably not accurate but can check it better now.
Diffstat (limited to 'activerecord/test/cases/defaults_test.rb')
0 files changed, 0 insertions, 0 deletions