1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108 |
#############################
# Query call on /posts/view/1
#############################
SELECT `Comment`.`id`, `Comment`.`post_id`, `Comment`.`created`, `Comment`.`modified`, `Comment`.`author`, `Comment`.`url`, `Comment`.`comment` FROM `comments` AS `Comment` WHERE `Comment`.`post_id` = (1)
#########################
# Query call on /comments
#########################
SELECT `Comment`.`id`, `Comment`.`post_id`, `Comment`.`created`, `Comment`.`modified`, `Comment`.`author`, `Comment`.`url`, `Comment`.`comment`, `Post`.`id`, `Post`.`created`, `Post`.`modified`, `Post`.`user_id`, `Post`.`title`, `Post`.`body` FROM `comments` AS `Comment` LEFT JOIN `posts` AS `Post` ON (`Comment`.`post_id` = `Post`.`id`) WHERE `Comment`.`id` IN (SELECT DISTINCT
`Object`.`id`
FROM comments AS Object,
users AS User,
privileges AS Privilege
WHERE `User`.`id` = 2
AND `Privilege`.`user_id` = 2
AND (
`Privilege`.`id` IN (
SELECT `Privilege`.`id`
FROM privileges AS Privilege
WHERE `Privilege`.`domaintype` = 'global'
AND `Privilege`.`operation` LIKE "%|list|%"
)
OR `Privilege`.`id` IN (
SELECT `privilege`.`id`
FROM Privileges AS privilege
WHERE `Privilege`.`domaintype` = 'model'
AND `Privilege`.`modelname` = 'comments'
AND `Privilege`.`operation` LIKE "%|list|%"
)
OR (
`Privilege`.`objectid` = `Object`.`id`
AND `Privilege`.`id` IN (
SELECT `Privilege`.`id`
FROM privileges AS Privilege
WHERE `Privilege`.`domaintype` = 'object'
AND `Privilege`.`modelname` = 'comments'
AND `Privilege`.`operation` LIKE "%|list|%"
)
AND `Object`.`id` IN (
SELECT `Privilege`.`objectid`
FROM privileges AS Privilege
WHERE `Privilege`.`domaintype` = 'object'
AND `Privilege`.`modelname` = 'comments'
AND `Privilege`.`operation` LIKE "%|list|%"
)
)
)
ORDER BY `Object`.`id` ASC) LIMIT 20
################################################
# Query call that should happen on /posts/view/1
################################################
SELECT `Comment`.`id`, `Comment`.`post_id`, `Comment`.`created`, `Comment`.`modified`, `Comment`.`author`, `Comment`.`url`, `Comment`.`comment`, `Post`.`id`, `Post`.`created`, `Post`.`modified`, `Post`.`user_id`, `Post`.`title`, `Post`.`body` FROM `comments` AS `Comment` LEFT JOIN `posts` AS `Post` ON (`Comment`.`post_id` = `Post`.`id`) WHERE `Comment`.`id` IN (SELECT DISTINCT
`Object`.`id`
FROM comments AS Object,
users AS User,
privileges AS Privilege
WHERE `User`.`id` = 2
AND `Privilege`.`user_id` = 2
AND (
`Privilege`.`id` IN (
SELECT `Privilege`.`id`
FROM privileges AS Privilege
WHERE `Privilege`.`domaintype` = 'global'
AND `Privilege`.`operation` LIKE "%|list|%"
)
OR `Privilege`.`id` IN (
SELECT `privilege`.`id`
FROM Privileges AS privilege
WHERE `Privilege`.`domaintype` = 'model'
AND `Privilege`.`modelname` = 'comments'
AND `Privilege`.`operation` LIKE "%|list|%"
)
OR (
`Privilege`.`objectid` = `Object`.`id`
AND `Privilege`.`id` IN (
SELECT `Privilege`.`id`
FROM privileges AS Privilege
WHERE `Privilege`.`domaintype` = 'object'
AND `Privilege`.`modelname` = 'comments'
AND `Privilege`.`operation` LIKE "%|list|%"
)
AND `Object`.`id` IN (
SELECT `Privilege`.`objectid`
FROM privileges AS Privilege
WHERE `Privilege`.`domaintype` = 'object'
AND `Privilege`.`modelname` = 'comments'
AND `Privilege`.`operation` LIKE "%|list|%"
)
)
)
ORDER BY `Object`.`id` ASC)
AND `Comment`.`post_id` = (1)
|
