diff --git a/README.md b/README.md index c12d723..dc96418 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ Backend mapping: | --- | --- | --- | | `create` | `({ parentId, sort })` | `id` | | `updateParentId` | `(id, parentId)` | `void` | -| `delete` | `(id)` | `void` | +| `delete` | `(id)` | `void` — blocked by FK if `categoryarticle` (or child categories) still reference it | | `getTree` | `(rootId)` | `{ id, parentId, sort }[]` | --- diff --git a/src/schema.js b/src/schema.js index b18d91d..0815bdd 100644 --- a/src/schema.js +++ b/src/schema.js @@ -332,7 +332,7 @@ BEGIN id INT IDENTITY(1,1) PRIMARY KEY, category_id INT NOT NULL, article_id INT NOT NULL, - CONSTRAINT FK_categoryarticle_category FOREIGN KEY (category_id) REFERENCES category(id) ON DELETE CASCADE, + CONSTRAINT FK_categoryarticle_category FOREIGN KEY (category_id) REFERENCES category(id) ON DELETE NO ACTION, CONSTRAINT FK_categoryarticle_article FOREIGN KEY (article_id) REFERENCES article(id) ON DELETE CASCADE, CONSTRAINT UQ_categoryarticle_category_article UNIQUE (category_id, article_id) ); diff --git a/src/sql/company.js b/src/sql/company.js index 84064e0..3f4f13b 100644 --- a/src/sql/company.js +++ b/src/sql/company.js @@ -46,11 +46,14 @@ SELECT c.name, c.root_category_id AS rootCategoryId, c.default_language_id AS languageId, - c.taxrate, - c.reducedtaxrate, - c.taxfreerate + tr.rate AS taxrate, + rtr.rate AS reducedtaxrate, + tfr.rate AS taxfreerate FROM company c INNER JOIN companyuser cu ON cu.company_id = c.id +LEFT JOIN tax tr ON tr.id = c.taxrate +LEFT JOIN tax rtr ON rtr.id = c.reducedtaxrate +LEFT JOIN tax tfr ON tfr.id = c.taxfreerate WHERE cu.google_auth_id = @authId `; diff --git a/src/store/category/delete.js b/src/store/category/delete.js index a33c788..7a48ec9 100644 --- a/src/store/category/delete.js +++ b/src/store/category/delete.js @@ -2,9 +2,6 @@ import { DELETE } from '../../sql/category.js'; export default function del(pool) { return async (id) => { - await pool - .request() - .input('id', id) - .query(DELETE); + await pool.request().input('id', id).query(DELETE); }; }