diff options
Diffstat (limited to 'perllib/FixMyStreet/DB/RABXColumn.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/RABXColumn.pm | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/DB/RABXColumn.pm b/perllib/FixMyStreet/DB/RABXColumn.pm index d14b48dc8..76eb21030 100644 --- a/perllib/FixMyStreet/DB/RABXColumn.pm +++ b/perllib/FixMyStreet/DB/RABXColumn.pm @@ -52,6 +52,8 @@ set_filtered_column behaviour to not trust the cache. sub rabx_column { my ($class, $col) = @_; + my $data_type = $class->column_info($col)->{data_type}; + # Apply the filtering for this column $class->filter_column( $col => { @@ -59,6 +61,10 @@ sub rabx_column { my $self = shift; my $ser = shift; return undef unless defined $ser; + # Some RABX columns are text, when they should be bytea. For + # these we must re-encode the string returned from the + # database, so that it is decoded again by RABX. + utf8::encode($ser) if $data_type ne 'bytea'; my $h = new IO::String($ser); return RABX::wire_rd($h); }, @@ -68,6 +74,10 @@ sub rabx_column { my $ser = ''; my $h = new IO::String($ser); RABX::wire_wr( $data, $h ); + # Some RABX columns are text, when they should be bytea. For + # these, we must re-decode the string encoded by RABX, so that + # it is encoded again when saved to the db. + utf8::decode($ser) if $data_type ne 'bytea'; return $ser; }, } @@ -77,14 +87,6 @@ sub rabx_column { $RABX_COLUMNS{ _get_class_identifier($class) }{$col} = 1; } -# The underlying column should always be UTF-8 encoded bytes. -sub get_column { - my ($self, $col) = @_; - my $res = $self->next::method ($col); - utf8::encode($res) if $RABX_COLUMNS{_get_class_identifier($self)}{$col} && utf8::is_utf8($res); - return $res; -} - sub set_filtered_column { my ($self, $col, $val) = @_; |