Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
Akonadi
Commits
25039495
Commit
25039495
authored
May 10, 2021
by
Konrad Czapla
Browse files
Use table names for items from QueryBuilder
parent
55d4c729
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/server/storage/itemqueryhelper.cpp
View file @
25039495
...
...
@@ -21,17 +21,17 @@ using namespace Akonadi::Server;
void
ItemQueryHelper
::
itemSetToQuery
(
const
ImapSet
&
set
,
QueryBuilder
&
qb
,
const
Collection
&
collection
)
{
if
(
!
set
.
isEmpty
())
{
QueryHelper
::
setToQuery
(
set
,
PimItem
::
id
Full
Column
Name
(),
qb
);
QueryHelper
::
setToQuery
(
set
,
qb
.
getTable
()
+
QLatin1Char
(
'.'
)
+
PimItem
::
idColumn
(),
qb
);
}
if
(
collection
.
isValid
())
{
if
(
collection
.
isVirtual
()
||
collection
.
resource
().
isVirtual
())
{
qb
.
addJoin
(
QueryBuilder
::
InnerJoin
,
CollectionPimItemRelation
::
tableName
(),
CollectionPimItemRelation
::
rightFullColumnName
(),
PimItem
::
id
Full
Column
Name
());
qb
.
getTable
()
+
QLatin1Char
(
'.'
)
+
PimItem
::
idColumn
());
qb
.
addValueCondition
(
CollectionPimItemRelation
::
leftFullColumnName
(),
Query
::
Equals
,
collection
.
id
());
}
else
{
qb
.
addValueCondition
(
PimItem
::
collectionId
Full
Column
Name
(),
Query
::
Equals
,
collection
.
id
());
qb
.
addValueCondition
(
qb
.
getTable
()
+
QLatin1Char
(
'.'
)
+
PimItem
::
collectionIdColumn
(),
Query
::
Equals
,
collection
.
id
());
}
}
}
...
...
@@ -48,10 +48,10 @@ void ItemQueryHelper::itemSetToQuery(const ImapSet &set, const CommandContext &c
if
(
tagId
.
has_value
())
{
// When querying for items by tag, only return matches from that resource
if
(
context
.
resource
().
isValid
())
{
qb
.
addJoin
(
QueryBuilder
::
InnerJoin
,
Collection
::
tableName
(),
PimItem
::
collectionId
Full
Column
Name
(),
Collection
::
idFullColumnName
());
qb
.
addJoin
(
QueryBuilder
::
InnerJoin
,
Collection
::
tableName
(),
qb
.
getTable
()
+
QLatin1Char
(
'.'
)
+
PimItem
::
collectionIdColumn
(),
Collection
::
idFullColumnName
());
qb
.
addValueCondition
(
Collection
::
resourceIdFullColumnName
(),
Query
::
Equals
,
context
.
resource
().
id
());
}
qb
.
addJoin
(
QueryBuilder
::
InnerJoin
,
PimItemTagRelation
::
tableName
(),
PimItem
::
id
Full
Column
Name
(),
PimItemTagRelation
::
leftFullColumnName
());
qb
.
addJoin
(
QueryBuilder
::
InnerJoin
,
PimItemTagRelation
::
tableName
(),
qb
.
getTable
()
+
QLatin1Char
(
'.'
)
+
PimItem
::
idColumn
(),
PimItemTagRelation
::
leftFullColumnName
());
qb
.
addValueCondition
(
PimItemTagRelation
::
rightFullColumnName
(),
Query
::
Equals
,
*
tagId
);
}
}
...
...
@@ -59,22 +59,22 @@ void ItemQueryHelper::itemSetToQuery(const ImapSet &set, const CommandContext &c
void
ItemQueryHelper
::
remoteIdToQuery
(
const
QStringList
&
rids
,
const
CommandContext
&
context
,
QueryBuilder
&
qb
)
{
if
(
rids
.
size
()
==
1
)
{
qb
.
addValueCondition
(
PimItem
::
remoteId
Full
Column
Name
(),
Query
::
Equals
,
rids
.
first
());
qb
.
addValueCondition
(
qb
.
getTable
()
+
QLatin1Char
(
'.'
)
+
PimItem
::
remoteIdColumn
(),
Query
::
Equals
,
rids
.
first
());
}
else
{
qb
.
addValueCondition
(
PimItem
::
remoteId
Full
Column
Name
(),
Query
::
In
,
rids
);
qb
.
addValueCondition
(
qb
.
getTable
()
+
QLatin1Char
(
'.'
)
+
PimItem
::
remoteIdColumn
(),
Query
::
In
,
rids
);
}
if
(
context
.
resource
().
isValid
())
{
qb
.
addJoin
(
QueryBuilder
::
InnerJoin
,
Collection
::
tableName
(),
PimItem
::
collectionId
Full
Column
Name
(),
Collection
::
idFullColumnName
());
qb
.
addJoin
(
QueryBuilder
::
InnerJoin
,
Collection
::
tableName
(),
qb
.
getTable
()
+
QLatin1Char
(
'.'
)
+
PimItem
::
collectionIdColumn
(),
Collection
::
idFullColumnName
());
qb
.
addValueCondition
(
Collection
::
resourceIdFullColumnName
(),
Query
::
Equals
,
context
.
resource
().
id
());
}
if
(
context
.
collectionId
()
>
0
)
{
qb
.
addValueCondition
(
PimItem
::
collectionId
Full
Column
Name
(),
Query
::
Equals
,
context
.
collectionId
());
qb
.
addValueCondition
(
qb
.
getTable
()
+
QLatin1Char
(
'.'
)
+
PimItem
::
collectionIdColumn
(),
Query
::
Equals
,
context
.
collectionId
());
}
const
auto
tagId
=
context
.
tagId
();
if
(
tagId
.
has_value
())
{
qb
.
addJoin
(
QueryBuilder
::
InnerJoin
,
PimItemTagRelation
::
tableName
(),
PimItem
::
id
Full
Column
Name
(),
PimItemTagRelation
::
leftFullColumnName
());
qb
.
addJoin
(
QueryBuilder
::
InnerJoin
,
PimItemTagRelation
::
tableName
(),
qb
.
getTable
()
+
QLatin1Char
(
'.'
)
+
PimItem
::
idColumn
(),
PimItemTagRelation
::
leftFullColumnName
());
qb
.
addValueCondition
(
PimItemTagRelation
::
rightFullColumnName
(),
Query
::
Equals
,
*
tagId
);
}
}
...
...
@@ -82,19 +82,19 @@ void ItemQueryHelper::remoteIdToQuery(const QStringList &rids, const CommandCont
void
ItemQueryHelper
::
gidToQuery
(
const
QStringList
&
gids
,
const
CommandContext
&
context
,
QueryBuilder
&
qb
)
{
if
(
gids
.
size
()
==
1
)
{
qb
.
addValueCondition
(
PimItem
::
gid
Full
Column
Name
(),
Query
::
Equals
,
gids
.
first
());
qb
.
addValueCondition
(
qb
.
getTable
()
+
QLatin1Char
(
'.'
)
+
PimItem
::
gidColumn
(),
Query
::
Equals
,
gids
.
first
());
}
else
{
qb
.
addValueCondition
(
PimItem
::
gid
Full
Column
Name
(),
Query
::
In
,
gids
);
qb
.
addValueCondition
(
qb
.
getTable
()
+
QLatin1Char
(
'.'
)
+
PimItem
::
gidColumn
(),
Query
::
In
,
gids
);
}
const
auto
tagId
=
context
.
tagId
();
if
(
tagId
.
has_value
())
{
// When querying for items by tag, only return matches from that resource
if
(
context
.
resource
().
isValid
())
{
qb
.
addJoin
(
QueryBuilder
::
InnerJoin
,
Collection
::
tableName
(),
PimItem
::
collectionId
Full
Column
Name
(),
Collection
::
idFullColumnName
());
qb
.
addJoin
(
QueryBuilder
::
InnerJoin
,
Collection
::
tableName
(),
qb
.
getTable
()
+
QLatin1Char
(
'.'
)
+
PimItem
::
collectionIdColumn
(),
Collection
::
idFullColumnName
());
qb
.
addValueCondition
(
Collection
::
resourceIdFullColumnName
(),
Query
::
Equals
,
context
.
resource
().
id
());
}
qb
.
addJoin
(
QueryBuilder
::
InnerJoin
,
PimItemTagRelation
::
tableName
(),
PimItem
::
id
Full
Column
Name
(),
PimItemTagRelation
::
leftFullColumnName
());
qb
.
addJoin
(
QueryBuilder
::
InnerJoin
,
PimItemTagRelation
::
tableName
(),
qb
.
getTable
()
+
QLatin1Char
(
'.'
)
+
PimItem
::
idColumn
(),
PimItemTagRelation
::
leftFullColumnName
());
qb
.
addValueCondition
(
PimItemTagRelation
::
rightFullColumnName
(),
Query
::
Equals
,
*
tagId
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment