File: CursorUtils.pm

package info (click to toggle)
libdbix-class-perl 0.082841-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 5,236 kB
  • sloc: perl: 26,763; sql: 322; makefile: 10
file content (42 lines) | stat: -rw-r--r-- 922 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package # hide from PAUSE
    DBIx::Class::Storage::DBI::ADO::CursorUtils;

use strict;
use warnings;
use base 'Exporter';

our @EXPORT_OK = qw/_normalize_guids _strip_trailing_binary_nulls/;

sub _strip_trailing_binary_nulls {
  my ($select, $col_infos, $data, $storage) = @_;

  foreach my $select_idx (0..$#$select) {

    next unless defined $data->[$select_idx];

    my $data_type = $col_infos->{$select->[$select_idx]}{data_type}
      or next;

    $data->[$select_idx] =~ s/\0+\z//
      if $storage->_is_binary_type($data_type);
  }
}

sub _normalize_guids {
  my ($select, $col_infos, $data, $storage) = @_;

  foreach my $select_idx (0..$#$select) {

    next unless defined $data->[$select_idx];

    my $data_type = $col_infos->{$select->[$select_idx]}{data_type}
      or next;

    $data->[$select_idx] =~ s/\A \{ (.+) \} \z/$1/xs
      if $storage->_is_guid_type($data_type);
  }
}

1;

# vim:sts=2 sw=2: