| 1 | package Geoffrey::Converter::SQLite::Index; | ||||||||||
| 2 | |||||||||||
| 3 | 5 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 5 | ▶ | use 5.016; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 5 | $Geoffrey::Converter::SQLite::Index::VERSION = '0.000206'; | |||||||||
| 9 | |||||||||||
| 10 | 5 | ▶ | use parent 'Geoffrey::Role::ConverterType'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 8 | ▶ | sub add { | ||||||||
|
Subroutine
add: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||
| 13 | 8 | my ( $self, $params ) = @_; | |||||||||
| 14 | 8 | ▶ | if ( !$params ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | 1 | require Geoffrey::Exception::General; | |||||||||
| 16 | 1 | Geoffrey::Exception::General::throw_no_params(); | |||||||||
| 17 | } | ||||||||||
| 18 | 7 | ▶ | if ( !$params->{table} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 1 | require Geoffrey::Exception::RequiredValue; | |||||||||
| 20 | 1 | Geoffrey::Exception::RequiredValue::throw_table_name(); | |||||||||
| 21 | } | ||||||||||
| 22 | 6 | ▶ | if ( !$params->{column} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 1 | require Geoffrey::Exception::RequiredValue; | |||||||||
| 24 | 1 | Geoffrey::Exception::RequiredValue::throw_refcolumn_missing(); | |||||||||
| 25 | } | ||||||||||
| 26 | 5 | require Ref::Util; | |||||||||
| 27 | 5 | require Geoffrey::Utils; | |||||||||
| 28 | return Geoffrey::Utils::replace_spare( | ||||||||||
| 29 | q~CREATE INDEX {0} ON {1} ({2})~, | ||||||||||
| 30 | [ Geoffrey::Utils::add_name( | ||||||||||
| 31 | { prefix => 'ix', | ||||||||||
| 32 | name => $params->{name}, | ||||||||||
| 33 | context => $params->{table} | ||||||||||
| 34 | } | ||||||||||
| 35 | ), | ||||||||||
| 36 | $params->{table}, | ||||||||||
| 37 | ( join ', ', | ||||||||||
| 38 | Ref::Util::is_arrayref( $params->{column} ) | ||||||||||
| 39 | 2 | ? @{ $params->{column} } | |||||||||
| 40 | : ( $params->{column} ) | ||||||||||
| 41 | 5 | ▶ | ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | ] | ||||||||||
| 43 | ); | ||||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 5 | ▶ | sub drop { | ||||||||
|
Subroutine
drop: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 47 | 5 | my ( $self, $name ) = @_; | |||||||||
| 48 | 5 | ▶ | if ( !$name ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 1 | require Geoffrey::Exception::RequiredValue; | |||||||||
| 50 | 1 | Geoffrey::Exception::RequiredValue::throw_index_name(); | |||||||||
| 51 | } | ||||||||||
| 52 | 4 | return qq~DROP INDEX $name~; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 4 | ▶ | sub list { | ||||||||
|
Subroutine
list: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 56 | 4 | my ( $self, $schema ) = @_; | |||||||||
| 57 | 4 | require Geoffrey::Utils; | |||||||||
| 58 | return | ||||||||||
| 59 | 4 | q~SELECT * FROM ~ | |||||||||
| 60 | . Geoffrey::Utils::add_schema($schema) | ||||||||||
| 61 | . q~sqlite_master WHERE type='index'~; | ||||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | 5 | 1; # End of Geoffrey::Converter::SQLite::Index | |||||||||
| 65 | |||||||||||
| 66 | __END__ | ||||||||||