Merge the relationship resolution rework
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / ADO / CursorUtils.pm
CommitLineData
2edf3352 1package # hide from PAUSE
2 DBIx::Class::Storage::DBI::ADO::CursorUtils;
3
4use strict;
5use warnings;
6use base 'Exporter';
7
8our @EXPORT_OK = qw/_normalize_guids _strip_trailing_binary_nulls/;
9
10sub _strip_trailing_binary_nulls {
5efba7fc 11 my ($select, $col_infos, $data, $storage) = @_;
2edf3352 12
13 foreach my $select_idx (0..$#$select) {
14
15 next unless defined $data->[$select_idx];
16
17 my $data_type = $col_infos->{$select->[$select_idx]}{data_type}
18 or next;
19
20 $data->[$select_idx] =~ s/\0+\z//
5efba7fc 21 if $storage->_is_binary_type($data_type);
2edf3352 22 }
23}
24
25sub _normalize_guids {
26 my ($select, $col_infos, $data, $storage) = @_;
27
28 foreach my $select_idx (0..$#$select) {
29
30 next unless defined $data->[$select_idx];
31
32 my $data_type = $col_infos->{$select->[$select_idx]}{data_type}
33 or next;
34
35 $data->[$select_idx] =~ s/\A \{ (.+) \} \z/$1/xs
36 if $storage->_is_guid_type($data_type);
37 }
38}
39
401;
41
42# vim:sts=2 sw=2: