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

Make DatabaseCollation.supports? check database encoding #3683

Closed
lizconlan opened this issue Jan 19, 2017 · 2 comments
Closed

Make DatabaseCollation.supports? check database encoding #3683

lizconlan opened this issue Jan 19, 2017 · 2 comments
Assignees
Labels
bug Breaks expected functionality x:eu x:italy

Comments

@lizconlan
Copy link

lizconlan commented Jan 19, 2017

The DatabaseCollation.supports? method only checks whether a named collation is available to the current database, it does not check whether it is compatible with the database encoding.

This is currently preventing us from using the it_IT locale as this does exist in the database but is only available for UTF8 encoding (our database uses SQL_ASCII). If we try to use the incompatible location after having checked its availability, we get an error back from Postgres which prevents PublicBody#list from rendering:

ERROR:  collation "it_IT" for encoding "SQL_ASCII" does not exist

(Background - the lookup on pg_collation is intended to be a multi-part key which includes the encoding - ref: https://www.postgresql.org/docs/9.2/static/catalog-pg-collation.html)

Fixes mysociety/dirittodisapere-theme#106

@lizconlan lizconlan added 1 - new bug Breaks expected functionality x:eu x:italy labels Jan 19, 2017
@lizconlan
Copy link
Author

lizconlan commented Jan 19, 2017

Useful things:

SHOW server_encoding; retrieves the database encoding
SELECT pg_encoding_to_char(collencoding) FROM pg_collation where collname = 'it_IT'; gets a comparable encoding string for the named collation

(alternatively a collencoding of -1 is compatible with everything so that would also be fine - pg_encoding_to_char returns a blank string)

@lizconlan
Copy link
Author

merged as hotfix/0.27.04 and hotfix/0.26.0.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Breaks expected functionality x:eu x:italy
Projects
None yet
Development

No branches or pull requests

1 participant