| 1 | package CXC::DB::DDL::Field::Pg; | ||||||||||
| 2 | |||||||||||
| 3 | # ABSTRACT: DBD::Pg specific Field class | ||||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use v5.26; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | our $VERSION = '0.16'; | |||||||||
| 7 | 1 | ▶ | use experimental 'signatures'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | use Scalar::Util (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use Ref::Util (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | package ## no critic (Modules::ProhibitMultiplePackages) | ||||||||||
| 13 | 1 | CXC::DB::DDL::Field::PgType { | |||||||||
| 14 | 1 | ▶ | use base 'CXC::DB::DDL::FieldType'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 0 | ▶ | sub pg_type_name ( $self ) { $self->name =~ s/^PG_//ri; } | ||||||||
|
Subroutine
pg_type_name: not called CC=1 SCAR=6.9
| |||||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 1 | ▶ | use CXC::DB::DDL::Util 0.15 { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 1 | add_dbd => { | |||||||||
| 21 | dbd => 'Pg', | ||||||||||
| 22 | tag => ':pg_types', | ||||||||||
| 23 | field_class => __PACKAGE__, | ||||||||||
| 24 | type_class => __PACKAGE__ . 'Type', | ||||||||||
| 25 | }, | ||||||||||
| 26 | }, | ||||||||||
| 27 | 'SQL_TYPE_NAMES', | ||||||||||
| 28 | 1 | 'SQL_TYPE_VALUES'; | |||||||||
| 29 | |||||||||||
| 30 | 1 | ▶ | use Types::Standard 'ArrayRef', 'Enum', 'Int', 'InstanceOf'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 31 | |||||||||||
| 32 | 1 | ▶ | use constant DataType => Enum->of( grep { !Ref::Util::is_ref $_ } SQL_TYPE_VALUES ) | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 33 | 1 | | InstanceOf ['CXC::DB::DDL::Field::PgType']; | |||||||||
| 34 | |||||||||||
| 35 | 1 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 36 | |||||||||||
| 37 | 1 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 38 | |||||||||||
| 39 | 1 | extends 'CXC::DB::DDL::Field'; | |||||||||
| 40 | |||||||||||
| 41 | has '+data_type' => ( | ||||||||||
| 42 | is => 'ro', | ||||||||||
| 43 | 0 | ▶ | isa => ArrayRef->of( DataType )->plus_coercions( DataType, sub { [$_] } ), | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 44 | coerce => 1, | ||||||||||
| 45 | ); | ||||||||||
| 46 | |||||||||||
| 47 | |||||||||||
| 48 | |||||||||||
| 49 | |||||||||||
| 50 | |||||||||||
| 51 | |||||||||||
| 52 | |||||||||||
| 53 | |||||||||||
| 54 | |||||||||||
| 55 | 0 | ▶ | sub type_name ( $self, $dbh ) { | ||||||||
|
Subroutine
type_name: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 56 | |||||||||||
| 57 | # if the type is an object, it's guaranteed to be one of ours, so | ||||||||||
| 58 | # use it directly | ||||||||||
| 59 | 0 | for my $type ( $self->data_type->@* ) { | |||||||||
| 60 | 0 | ▶ | return $type->pg_type_name if Scalar::Util::blessed( $type ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | 0 | return $self->next::method( $dbh ); | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 1 | 1; | |||||||||
| 67 | |||||||||||
| 68 | # | ||||||||||
| 69 | # This file is part of CXC-DB-DDL-Field-Pg | ||||||||||
| 70 | # | ||||||||||
| 71 | # This software is Copyright (c) 2024 by Smithsonian Astrophysical Observatory. | ||||||||||
| 72 | # | ||||||||||
| 73 | # This is free software, licensed under: | ||||||||||
| 74 | # | ||||||||||
| 75 | # The GNU General Public License, Version 3, June 2007 | ||||||||||
| 76 | # | ||||||||||
| 77 | |||||||||||
| 78 | __END__ | ||||||||||