From e8990b3265f34ec8d63af28725e0db451bf2c828 Mon Sep 17 00:00:00 2001 From: Karolis Narkevicius Date: Fri, 20 Nov 2020 16:23:34 +0000 Subject: [PATCH 1/2] Fix id extraction in _create --- lib/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 89cbc1e..c744eff 100644 --- a/lib/index.js +++ b/lib/index.js @@ -230,7 +230,15 @@ class Service extends AdapterService { return this.db(params) .insert(data, returning) .then(rows => { - const id = data[this.id] !== undefined ? data[this.id] : rows[0]; + let id + + if (data[this.id] !== undefined) { + id = data[this.id] + } else if (rows[0] && rows[0][this.id]) { + id = rows[0][this.id] + } + + if (!id) return rows return this._get(id, params); }) From cc8fd374742d21c3d0ef9098c59e907c288d48ae Mon Sep 17 00:00:00 2001 From: Karolis Narkevicius Date: Thu, 17 Dec 2020 12:50:14 +0000 Subject: [PATCH 2/2] Unbreak sqlite support, extract id correctly for all DBs --- lib/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/index.js b/lib/index.js index c744eff..86a4e3e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -234,6 +234,8 @@ class Service extends AdapterService { if (data[this.id] !== undefined) { id = data[this.id] + } else if (!returning.length) { + id = rows[0] } else if (rows[0] && rows[0][this.id]) { id = rows[0][this.id] }