PostGIS/Introspect.pm

filter: Statementstmt 83.3% 20 / 24 Branchbran 100% 6 / 6 Conditioncond 83.3% 5 / 6 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 80.0% 4 / 5 Podpod n/a totaltotal 84.0% 37 / 44 CC 9 SCAR 18.9
CC
9
Cov
86%
_augment_geometry_columns
9.0
_build_model
2.0
BEGIN
1.0
CRAP 6.6
« PostGIS/Codec/WKT/Builder.pm ↑ Summary PostGIS/Geometry.pm »
1 package DBIO::PostgreSQL::PostGIS::Introspect;
2 # ABSTRACT: PostgreSQL introspector augmented with PostGIS geometry_columns
3  
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use base 'DBIO::PostgreSQL::Introspect';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 0 ▶sub _build_model {
Subroutine _build_model: not called CC=1 SCAR=6.9
11 0 my ($self) = @_;
12 0 my $model = $self->SUPER::_build_model();
13 0 _augment_geometry_columns($model->{columns});
14 0 return $model;
15 }
16  
17  
18 8 ▶sub _augment_geometry_columns {
Subroutine _augment_geometry_columns: called CC=9 SCAR=22.0
19 8 my ($columns_by_table) = @_;
20 8 ▶ for my $table_key (keys %{ $columns_by_table // {} }) {
Condition100%2/2
$columns_by_table // {}
l!l
71
MC/DC100%1/1
$columns_by_table // {}
$columns_by_table
Truth table100%2/2
A
A= $columns_by_table
Aresult
11
00
21 6 ▶ for my $col (@{ $columns_by_table->{$table_key} // [] }) {
Condition50%1/2
$columns_by_table->{$table_key} // []
l!l
60
MC/DC0%0/1
$columns_by_table->{$table_key} // []
$columns_by_table->{$table_key}
Truth table50%1/2
A
A= $columns_by_table->{$table_key}
Aresult
11
00
22 6 ▶ my $dt = lc($col->{data_type} // '');
Condition100%2/2
$col->{"data_type"} // ""
l!l
51
MC/DC100%1/1
$col->{"data_type"} // ""
$col->{"data_type"}
Truth table100%2/2
A
A= $col->{"data_type"}
Aresult
11
00
23 6 ▶ if ($dt =~ /\A(geometry|geography)(?:\((\w+)(?:,(\d+))?\))?\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt =~ /\A(geometry|geography)(?:\((\w+)(?:,(\d+))?\))?\z/) 4 2 6
24 4 $col->{base_type} = $1;
25 4 ▶ $col->{geometry_type} = $2 if $2;
Branch: 1 branch
BranchTrueFalseTotal
if $2 3 1 4
26 4 ▶ $col->{srid} = $3 + 0 if defined $3;
Branch: 1 branch
BranchTrueFalseTotal
if defined $3 2 2 4
27 }
28 }
29 }
30 }
31  
32  
33 3 1;
34  
35 __END__
36  
37 =pod
38  
39 =encoding UTF-8
40  
41 =head1 NAME
42  
43 DBIO::PostgreSQL::PostGIS::Introspect - PostgreSQL introspector augmented with PostGIS geometry_columns
44  
45 =head1 VERSION
46  
47 version 0.900001
48  
49 =head1 DESCRIPTION
50  
51 Extends L<DBIO::PostgreSQL::Introspect> for PostGIS-enabled databases.
52 After the standard introspection, augments geometry and geography column
53 metadata by parsing the C<data_type> string (e.g. C<geometry(Point,4326)>)
54 into discrete C<geometry_type> and C<srid> fields.
55  
56 This is used automatically when L<DBIO::PostgreSQL::PostGIS::Storage> is
57 active — the Deploy class uses this introspector via
58 L<DBIO::PostgreSQL::PostGIS::Deploy/_new_introspect>.
59  
60 =head1 METHODS
61  
62 =head2 _build_model
63  
64 Calls the parent C<_build_model> then augments geometry and geography
65 columns with C<geometry_type> and C<srid> parsed from the data_type string.
66  
67 =head2 _augment_geometry_columns
68  
69 Private helper. Iterates the columns-by-table hashref and parses PostGIS
70 C<data_type> strings such as C<geometry(Point,4326)> into discrete
71 C<base_type> (C<geometry> or C<geography>), C<geometry_type> (e.g.
72 C<Point>), and numeric C<srid> fields on each column hashref in place.
73  
74 =head1 AUTHOR
75  
76 DBIO Authors
77  
78 =head1 COPYRIGHT AND LICENSE
79  
80 Copyright (C) 2026 DBIO Authors
81  
82 This is free software; you can redistribute it and/or modify it under
83 the same terms as the Perl 5 programming language system itself.
84  
85 =cut
« PostGIS/Codec/WKT/Builder.pm ↑ Summary PostGIS/Geometry.pm »