iobroker.sql 2.1.8 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -520,6 +520,10 @@ sendTo('sql.0', 'getEnabledDPs', {}, function (result) {
520
520
  -->
521
521
 
522
522
  ## Changelog
523
+ ### 2.2.0 (2022-09-19)
524
+ * IMPORTANT: Node.js 14.x is now needed at minimum!
525
+ * (Apollon77) Fix potential crash cases with upcoming js-controller versions
526
+
523
527
  ### 2.1.8 (2022-08-13)
524
528
  * (riversource/Apollon77) Optimize getHistory query by using "UNION ALL"
525
529
  * (Apollon77) Fix crash cases reported by Sentry
package/io-package.json CHANGED
@@ -26,8 +26,20 @@
26
26
  "pl": "Rejestrowanie stanów w SQL DB",
27
27
  "zh-cn": "将状态记录到SQL DB"
28
28
  },
29
- "version": "2.1.8",
29
+ "version": "2.2.0",
30
30
  "news": {
31
+ "2.2.0": {
32
+ "en": "IMPORTANT: Node.js 14.x is now needed at minimum!\nFix potential crash cases with upcoming js-controller versions",
33
+ "de": "WICHTIG: Node.js 14.x wird jetzt mindestens benötigt!\nBeheben Sie mögliche Crash-Fälle mit anstehenden js-Controller-Versionen",
34
+ "ru": "ВАЖНО: Node.js 14.x теперь нужен минимум!\nИсправление потенциальных кейсов с предстоящими версиями js-controller",
35
+ "pt": "IMPORTANTE: Node.js 14.x é agora necessário no mínimo!\nCorrigir casos potenciais de acidente com versões js-controller",
36
+ "nl": "Node is 14.x is nu nodig op minimum!\nVertaling:",
37
+ "fr": "IMPORTANT: Node.js 14.x est maintenant nécessaire au minimum!\nRéparer les cas de crash potentiels avec les versions de js-controller à venir",
38
+ "it": "IMPORTANTE: Node.js 14.x è ora necessario al minimo!\nRisolvere potenziali casi di crash con le prossime versioni js-controller",
39
+ "es": "IMPORTANTE: Node.js 14.x ahora es necesario al mínimo!\nFijar posibles casos de choque con las próximas versiones js-controller",
40
+ "pl": "IMPORTANT: Nodejs 14.x jest obecnie potrzebny na minimum!\nFix ma problemy z nadchodzącymi wersjami js-controllerowymi",
41
+ "zh-cn": "IMPORTANT: Nodejs 14x现在至少需要!\n九件潜在的事故,即将出版的丛书控制字"
42
+ },
31
43
  "2.1.8": {
32
44
  "en": "Optimize getHistory query by using \"UNION ALL\"\nFix crash cases reported by Sentry",
33
45
  "de": "Optimieren Sie Geschichte Anfrage mit \"UNION ALL\"\nReparieren Crashfälle gemeldet von Sentry",
@@ -99,18 +111,6 @@
99
111
  "es": "Amplias optimizaciones de rendimiento para llamadas GetHistory",
100
112
  "pl": "Optymalizacja wyników Huge'a dla GetHistory'ego nawołuje się do optymalizacji wydajności",
101
113
  "zh-cn": "GetHistory呼声的优越性"
102
- },
103
- "2.1.1": {
104
- "en": "Fix crash cases reported by Sentry",
105
- "de": "Von Sentry gemeldete Absturzfälle beheben",
106
- "ru": "Исправить случаи сбоев, о которых сообщил Sentry",
107
- "pt": "Corrigir casos de travamento relatados pelo Sentinela",
108
- "nl": "Herstel crashgevallen gemeld door Sentry",
109
- "fr": "Correction des cas de plantage signalés par Sentry",
110
- "it": "Risolvi i casi di crash segnalati da Sentry",
111
- "es": "Solucionar casos de fallas informados por Sentry",
112
- "pl": "Napraw przypadki awarii zgłoszone przez Sentry",
113
- "zh-cn": "修复 Sentry 报告的崩溃案例"
114
114
  }
115
115
  },
116
116
  "mode": "daemon",
package/main.js CHANGED
@@ -8,6 +8,7 @@ const adapterName = require('./package.json').name.split('.').pop();
8
8
  const SQL = require('sql-client');
9
9
  const commons = require('./lib/aggregate');
10
10
  const fs = require('fs');
11
+ const path = require('path');
11
12
  let SQLFuncs = null;
12
13
 
13
14
  const clients = {
@@ -610,18 +611,14 @@ function getSqlLiteDir(fileName) {
610
611
  } else {
611
612
  // normally /opt/iobroker/node_modules/iobroker.js-controller
612
613
  // but can be /example/ioBroker.js-controller
613
- const tools = require(`${utils.controllerDir}/lib/tools`);
614
- let config = tools.getConfigFileName().replace(/\\/g, '/');
615
- const parts = config.split('/');
616
- parts.pop();
617
- config = `${parts.join('/')}/sqlite`;
614
+ let config = path.join(utils.getAbsoluteDefaultDataDir(), 'sqlite');
618
615
 
619
616
  // create sqlite directory
620
617
  if (!fs.existsSync(config)) {
621
618
  fs.mkdirSync(config);
622
619
  }
623
620
 
624
- return `${config}/${fileName}`;
621
+ return path.normalize(path.join(config, fileName));
625
622
  }
626
623
  }
627
624
 
@@ -2877,9 +2874,10 @@ function storeStatePushData(id, state, applyRules) {
2877
2874
  let pushFunc = applyRules ? pushHistory : pushHelper;
2878
2875
  if (!sqlDPs[id] || !sqlDPs[id][adapter.namespace]) {
2879
2876
  if (applyRules) {
2880
- throw new Error(`history not enabled for ${id}, so can not apply the rules as requested`);
2877
+ throw new Error(`sql not enabled for ${id}, so can not apply the rules as requested`);
2881
2878
  }
2882
2879
  sqlDPs[id] = sqlDPs[id] || {};
2880
+ sqlDPs[id].realId = id;
2883
2881
  }
2884
2882
  return new Promise((resolve, reject) => {
2885
2883
  pushFunc(id, state , err => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "iobroker.sql",
3
3
  "description": "Log state sql in a two-stages process (first to Redis, then to CouchDB)",
4
- "version": "2.1.8",
4
+ "version": "2.2.0",
5
5
  "author": "bluefox <dogafox@gmail.com>",
6
6
  "contributors": [
7
7
  "bluefox <dogafox@gmail.com>",
@@ -13,7 +13,7 @@
13
13
  "url": "https://github.com/ioBroker/ioBroker.sql"
14
14
  },
15
15
  "engines": {
16
- "node": ">=10.0.0"
16
+ "node": ">=14.0.0"
17
17
  },
18
18
  "keywords": [
19
19
  "ioBroker",
@@ -22,9 +22,9 @@
22
22
  ],
23
23
  "optionalDependencies": {
24
24
  "mysql2": "^2.3.3",
25
- "pg": "^8.7.3",
25
+ "pg": "^8.8.0",
26
26
  "sqlite3": "^5.0.11",
27
- "mssql": "^8.1.2"
27
+ "mssql": "^9.0.1"
28
28
  },
29
29
  "dependencies": {
30
30
  "sql-client": "^3.0.0",