DB/Schema/Result/StoredItemAttachment.pm

filter: Statementstmt 100% 15 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 18 / 18 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« DB/Schema/Result/StoredItem.pm ↑ Summary DB/Schema/Result/SyncDeleteLog.pm »
1 package Biblio::Zotero::DB::Schema::Result::StoredItemAttachment;
2 13 $Biblio::Zotero::DB::Schema::Result::StoredItemAttachment::VERSION = '0.004';
3 # TODO: document
4  
5 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶use base qw/Biblio::Zotero::DB::Schema::Result::ItemAttachment/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 13 __PACKAGE__->table_class('DBIx::Class::ResultSource::View');
10 13 __PACKAGE__->table('storedItemAttachments');
11 13 __PACKAGE__->result_source_instance->is_virtual(1);
12  
13 # NOTE: SQL
14 13 __PACKAGE__->result_source_instance->view_definition(
15 q[
16 SELECT * FROM itemAttachments me
17 WHERE (
18 itemid NOT IN ( SELECT me.itemid FROM deletedItems me )
19 AND
20 (
21 sourceitemid IS NULL
22 OR
23 sourceitemid NOT IN ( SELECT me.itemid FROM deletedItems me )
24 )
25 )
26 ]
27 );
28 # the above view_definition is the same as:
29 # ----------------------------------------
30 # my $deleted = $schema->resultset('DeletedItem')
31 # ->get_column('itemid')
32 # ->as_query;
33 # $schema
34 # ->resultset('ItemAttachment')
35 # ->search(
36 # { -and => [ { itemid => { -not_in => $deleted } },
37 # { -or => [ { sourceitemid => undef },
38 # { sourceitemid => { -not_in => $deleted } }] }
39 # ] }
40 # )->as_query
41 # ####
42 # the clause checking the sourceitemid is for when only the source item is
43 # marked as deleted, but the attachment is not
44  
45 13 1;
46  
47 __END__
« DB/Schema/Result/StoredItem.pm ↑ Summary DB/Schema/Result/SyncDeleteLog.pm »