line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Biblio::Zotero::DB::Schema::Result::StoredItemAttachment; |
2
|
|
|
|
|
|
|
$Biblio::Zotero::DB::Schema::Result::StoredItemAttachment::VERSION = '0.003'; |
3
|
|
|
|
|
|
|
# TODO: document |
4
|
|
|
|
|
|
|
|
5
|
13
|
|
|
13
|
|
10268
|
use strict; |
|
13
|
|
|
|
|
29
|
|
|
13
|
|
|
|
|
515
|
|
6
|
13
|
|
|
13
|
|
73
|
use warnings; |
|
13
|
|
|
|
|
28
|
|
|
13
|
|
|
|
|
362
|
|
7
|
13
|
|
|
13
|
|
65
|
use base qw/Biblio::Zotero::DB::Schema::Result::ItemAttachment/; |
|
13
|
|
|
|
|
28
|
|
|
13
|
|
|
|
|
4618
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
__PACKAGE__->table_class('DBIx::Class::ResultSource::View'); |
10
|
|
|
|
|
|
|
__PACKAGE__->table('storedItemAttachments'); |
11
|
|
|
|
|
|
|
__PACKAGE__->result_source_instance->is_virtual(1); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# NOTE: SQL |
14
|
|
|
|
|
|
|
__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
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |