Hi:

Using the aggregate and JSON features of PostgreSQL I have created a 
subquery that returns full rows in a column of the main query

   $query = "SELECT document.id_document, document.title, document.content,
                    (SELECT array_to_json(array_agg(row_to_json(r)))
                        FROM (
                            SELECT *
                            FROM review
                            WHERE review.id_document = document.id_document
                            )r
                        )
                    FROM document
                    WHERE document.status = ?"; 


I render the result to the stash using

documents => $document->expand->hashes



The resulting column, array_to_json, is expanded with no problem in the 
template.

*BUT when any row contains spanish characters, like accented vocals (á, é. 
í,…) or our peculiar "ñ", it complains with error:*

Input is not UTF-8 encoded at 
/home/developer/perl5/perlbrew/perls/perl-5.20.1/lib/site_perl/5.20.1/Mojo/Pg/Results.pm
 
line 51.


I also tried to "not expand" the hashes in the controller and decode the 
resulting JSON directly in the template. But it's the same. When spanish 
characters appears in the result, it doesn´t work.

Database is using UTF8 encoding.

Everything that comes in regular columns works fine with all the spanish 
characters. Even when using HStore. It only breaks with the JSON result.

Any ideas? What should I try?

Regards:
Nacho

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to