| 1 | package DBIO::SQLite::Util; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Shared SQLite-specific helper functions for DBIO | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 217 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 217 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 217 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 217 | our @EXPORT_OK = qw(column_is_nullable); | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 21 | ▶ | sub column_is_nullable { | ||||||||||||||||||||||||||
|
Subroutine
column_is_nullable: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 14 | 21 | my ($not_null, $is_pk) = @_; | |||||||||||||||||||||||||||
| 15 | 21 | ▶ | return ($not_null || $is_pk) ? 0 : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$not_null or $is_pk
MC/DC100%2/2
$not_null or $is_pk
$not_null
$is_pk
Truth table100%3/3
A or B
A= $not_nullB= $is_pk
| |||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 217 | 1; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | __END__ | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =pod | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =head1 NAME | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | DBIO::SQLite::Util - Shared SQLite-specific helper functions for DBIO | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =head1 VERSION | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | version 0.900001 | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | Small helpers that capture SQLite-specific truths shared across the driver, | ||||||||||||||||||||||||||||
| 37 | so the same rule is not re-encoded in several places. | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | =func column_is_nullable | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | my $is_nullable = column_is_nullable($not_null, $is_pk); | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | The single source of truth for SQLite column nullability. A column is | ||||||||||||||||||||||||||||
| 44 | logically NOT NULL when it is either declared C<NOT NULL> B<or> part of the | ||||||||||||||||||||||||||||
| 45 | primary key -- C<PRAGMA table_info> reports PK columns as C<notnull=0> (the | ||||||||||||||||||||||||||||
| 46 | PK constraint is separate from the NOT NULL attribute), but a PK column is | ||||||||||||||||||||||||||||
| 47 | logically non-nullable. Returns C<1> when the column may hold NULL, C<0> | ||||||||||||||||||||||||||||
| 48 | otherwise. | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | DBIO & DBIx::Class Authors | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | Copyright (C) 2026 DBIO Authors | ||||||||||||||||||||||||||||
| 57 | Portions Copyright (C) 2005-2025 DBIx::Class Authors | ||||||||||||||||||||||||||||
| 58 | Based on DBIx::Class, heavily modified. | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 61 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =cut | ||||||||||||||||||||||||||||