aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-07-24 09:09:17 -0700
committerAnton Tananaev <anton@traccar.org>2022-07-24 09:09:17 -0700
commit929240716f09627de9823d411a11fc0cdf6eb49b (patch)
treeada5de9c8240aa6e4b4244deced4ed482e4cec6a /src
parent4a24779dd6e72247dde96127791ab1f5055b1b53 (diff)
downloadtrackermap-server-929240716f09627de9823d411a11fc0cdf6eb49b.tar.gz
trackermap-server-929240716f09627de9823d411a11fc0cdf6eb49b.tar.bz2
trackermap-server-929240716f09627de9823d411a11fc0cdf6eb49b.zip
Fix group permissions
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/storage/DatabaseStorage.java28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/main/java/org/traccar/storage/DatabaseStorage.java b/src/main/java/org/traccar/storage/DatabaseStorage.java
index eec72b510..8ca464147 100644
--- a/src/main/java/org/traccar/storage/DatabaseStorage.java
+++ b/src/main/java/org/traccar/storage/DatabaseStorage.java
@@ -355,41 +355,45 @@ public class DatabaseStorage extends Storage {
result.append("SELECT DISTINCT ");
if (!expandDevices) {
- result.append(groupStorageName).append('.');
+ if (outputKey.equals("groupId")) {
+ result.append("all_groups.");
+ } else {
+ result.append(groupStorageName).append('.');
+ }
}
result.append(outputKey);
result.append(" FROM ");
result.append(groupStorageName);
result.append(" INNER JOIN (");
- result.append("SELECT id as parentid, id as groupid FROM ");
+ result.append("SELECT id as parentId, id as groupId FROM ");
result.append(getStorageName(Group.class));
result.append(" UNION ");
- result.append("SELECT groupid as parentid, id as groupid FROM ");
+ result.append("SELECT groupId as parentId, id as groupId FROM ");
result.append(getStorageName(Group.class));
- result.append(" WHERE groupid IS NOT NULL");
+ result.append(" WHERE groupId IS NOT NULL");
result.append(" UNION ");
- result.append("SELECT g2.groupid as parentid, g1.id as groupid FROM ");
+ result.append("SELECT g2.groupId as parentId, g1.id as groupId FROM ");
result.append(getStorageName(Group.class));
result.append(" AS g2");
result.append(" INNER JOIN ");
result.append(getStorageName(Group.class));
- result.append(" AS g1 ON g2.id = g1.groupid");
- result.append(" WHERE g2.groupid IS NOT NULL");
+ result.append(" AS g1 ON g2.id = g1.groupId");
+ result.append(" WHERE g2.groupId IS NOT NULL");
result.append(") AS all_groups ON ");
result.append(groupStorageName);
- result.append(".groupid = all_groups.parentid");
+ result.append(".groupId = all_groups.parentId");
if (expandDevices) {
result.append(" INNER JOIN (");
- result.append("SELECT groupid as parentid, id as deviceid FROM ");
+ result.append("SELECT groupId as parentId, id as deviceId FROM ");
result.append(getStorageName(Device.class));
- result.append(" WHERE groupid IS NOT NULL");
- result.append(") AS devices ON all_groups.groupid = devices.parentid");
+ result.append(" WHERE groupId IS NOT NULL");
+ result.append(") AS devices ON all_groups.groupId = devices.parentId");
}
result.append(" WHERE ");
- result.append(conditionKey); // TODO handle search for device / group
+ result.append(conditionKey);
result.append(" = :");
result.append(conditionKey);