aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-07-15 01:02:37 +1200
committerGitHub <noreply@github.com>2016-07-15 01:02:37 +1200
commit2db5a3df91a76776cc214eca1e1fda6aecd0f36d (patch)
tree60934fa5dc97ed172a92a7773af2af0cf15c5eb7
parent6dfd599ef69fac9ea0851e3c07873c6368231610 (diff)
parenta8c7b44d06fd6112568c6ad0ed57c5af9db00ded (diff)
downloadtrackermap-server-2db5a3df91a76776cc214eca1e1fda6aecd0f36d.tar.gz
trackermap-server-2db5a3df91a76776cc214eca1e1fda6aecd0f36d.tar.bz2
trackermap-server-2db5a3df91a76776cc214eca1e1fda6aecd0f36d.zip
Merge pull request #2113 from Abyss777/master
Fixes for new foreign key constraints
-rw-r--r--debug.xml2
-rw-r--r--setup/unix/traccar.xml2
-rw-r--r--setup/windows/traccar.xml2
-rw-r--r--src/org/traccar/database/QueryBuilder.java12
-rw-r--r--web/app/view/GroupsController.js1
5 files changed, 14 insertions, 5 deletions
diff --git a/debug.xml b/debug.xml
index 73ddacc6a..09a575450 100644
--- a/debug.xml
+++ b/debug.xml
@@ -187,7 +187,7 @@
</entry>
<entry key='database.insertGroup'>
- INSERT INTO groups (name) VALUES (:name);
+ INSERT INTO groups (name, groupId) VALUES (:name, :groupId);
</entry>
<entry key='database.updateGroup'>
diff --git a/setup/unix/traccar.xml b/setup/unix/traccar.xml
index 83abb48fd..a8bf9c334 100644
--- a/setup/unix/traccar.xml
+++ b/setup/unix/traccar.xml
@@ -139,7 +139,7 @@
</entry>
<entry key='database.insertGroup'>
- INSERT INTO groups (name) VALUES (:name);
+ INSERT INTO groups (name, groupId) VALUES (:name, :groupId);
</entry>
<entry key='database.updateGroup'>
diff --git a/setup/windows/traccar.xml b/setup/windows/traccar.xml
index 72f04d0a0..a67d8c53c 100644
--- a/setup/windows/traccar.xml
+++ b/setup/windows/traccar.xml
@@ -139,7 +139,7 @@
</entry>
<entry key='database.insertGroup'>
- INSERT INTO groups (name) VALUES (:name);
+ INSERT INTO groups (name, groupId) VALUES (:name, :groupId);
</entry>
<entry key='database.updateGroup'>
diff --git a/src/org/traccar/database/QueryBuilder.java b/src/org/traccar/database/QueryBuilder.java
index 73569ac2a..1a83daab9 100644
--- a/src/org/traccar/database/QueryBuilder.java
+++ b/src/org/traccar/database/QueryBuilder.java
@@ -173,9 +173,17 @@ public final class QueryBuilder {
}
public QueryBuilder setLong(String name, long value) throws SQLException {
+ return setLong(name, value, false);
+ }
+
+ public QueryBuilder setLong(String name, long value, boolean nullIfZero) throws SQLException {
for (int i : indexes(name)) {
try {
- statement.setLong(i, value);
+ if (value == 0 && nullIfZero) {
+ statement.setNull(i, Types.INTEGER);
+ } else {
+ statement.setLong(i, value);
+ }
} catch (SQLException error) {
statement.close();
connection.close();
@@ -245,7 +253,7 @@ public final class QueryBuilder {
} else if (method.getReturnType().equals(int.class)) {
setInteger(name, (Integer) method.invoke(object));
} else if (method.getReturnType().equals(long.class)) {
- setLong(name, (Long) method.invoke(object));
+ setLong(name, (Long) method.invoke(object), name.endsWith("Id"));
} else if (method.getReturnType().equals(double.class)) {
setDouble(name, (Double) method.invoke(object));
} else if (method.getReturnType().equals(String.class)) {
diff --git a/web/app/view/GroupsController.js b/web/app/view/GroupsController.js
index 1764423d7..4cf1459a6 100644
--- a/web/app/view/GroupsController.js
+++ b/web/app/view/GroupsController.js
@@ -19,6 +19,7 @@ Ext.define('Traccar.view.GroupsController', {
alias: 'controller.groups',
requires: [
+ 'Traccar.view.GroupDialog',
'Traccar.view.GroupGeofences'
],