From 9fc939055cb4661c72b4806586d9247d0c9f78fc Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Tue, 16 Jun 2020 13:29:30 +0200 Subject: [PATCH] DOC: update Changelog and some formatting of SQL statements --- CHANGELOG.md | 1 + .../backend/implementation/MySQL/MySQLGetIDByName.java | 5 ++++- .../implementation/MySQL/MySQLInsertEntityDatatype.java | 7 +++++-- .../implementation/MySQL/MySQLRetrieveDatatypes.java | 7 ++++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78cb02fb..616ab01c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +* #51 - name queries (e.g. `FIND ENTITY WITH name = ...`) - #27 - star matches slashes (e.g. for `FIND ... STORED AT /*.dat`). - #30 - file path cannot be in quotes - #46 - Server-side scripting failed as an unprivileged user because the was no diff --git a/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLGetIDByName.java b/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLGetIDByName.java index 6e5a55b5..a113020c 100644 --- a/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLGetIDByName.java +++ b/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLGetIDByName.java @@ -37,7 +37,10 @@ public class MySQLGetIDByName extends MySQLTransaction implements GetIDByNameImp } public static final String STMT_GET_ID_BY_NAME = - "Select n.entity_id AS id from name_data as n JOIN entities as e ON (n.domain_id=0 and n.property_id=20 and e.id = n.entity_id) and n.value=?"; + "Select n.entity_id AS id " + + "FROM name_data AS n JOIN entities AS e " + + "ON (n.domain_id=0 AND n.property_id=20 AND e.id = n.entity_id)" + + "WHERE n.value=?"; public static final String STMT_AND_ROLE = " AND e.role=?"; public static final String STMT_NOT_ROLE = " AND e.role!='ROLE'"; public static final String STMT_LIMIT = " LIMIT "; diff --git a/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLInsertEntityDatatype.java b/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLInsertEntityDatatype.java index 78b93ff8..dbc8b957 100644 --- a/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLInsertEntityDatatype.java +++ b/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLInsertEntityDatatype.java @@ -16,9 +16,12 @@ public class MySQLInsertEntityDatatype extends MySQLTransaction } public static final String STMT_INSERT_ENTITY_DATATYPE = - "INSERT INTO data_type (domain_id, entity_id, property_id, datatype) SELECT 0, 0, ?, ( SELECT entity_id from name_data where domain_id = 0 and property_id = 20 and value = ? LIMIT 1);"; + "INSERT INTO data_type (domain_id, entity_id, property_id, datatype) " + + "SELECT 0, 0, ?, " + + "( SELECT entity_id FROM name_data WHERE domain_id = 0 AND property_id = 20 AND value = ? LIMIT 1);"; public static final String STMT_INSERT_ENTITY_COLLECTION = - "INSERT INTO collection_type (domain_id, entity_id, property_id, collection) SELECT 0, 0, ?, ?;"; + "INSERT INTO collection_type (domain_id, entity_id, property_id, collection) " + + "SELECT 0, 0, ?, ?;"; @Override public void execute(final SparseEntity entity) { diff --git a/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLRetrieveDatatypes.java b/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLRetrieveDatatypes.java index 5ae77593..91d1e97a 100644 --- a/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLRetrieveDatatypes.java +++ b/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLRetrieveDatatypes.java @@ -39,7 +39,12 @@ public class MySQLRetrieveDatatypes extends MySQLTransaction implements Retrieve } private static final String STMT_GET_DATATYPE = - "select id AS ParentID, (SELECT value FROM name_data WHERE domain_id = 0 AND entity_ID = e.id AND property_id = 20) AS ParentName, description as ParentDescription, role as ParentRole, (SELECT acl FROM entity_acl as a WHERE a.id=e.acl) as ACL from entities as e where e.role='DATATYPE'"; + "SELECT id AS ParentID, " + + "(SELECT value FROM name_data WHERE domain_id = 0 AND entity_ID = e.id AND property_id = 20) AS ParentName, " + + "description AS ParentDescription, " + + "role AS ParentRole, " + + "(SELECT acl FROM entity_acl AS a WHERE a.id=e.acl) as ACL " + + "FROM entities AS e WHERE e.role='DATATYPE'"; @Override public ArrayList<VerySparseEntity> execute() throws TransactionException { -- GitLab