leoric 1.13.1 → 1.13.2

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/History.md CHANGED
@@ -1,3 +1,12 @@
1
+ 1.13.2 / 2021-10-18
2
+ ===================
3
+
4
+ ## What's Changed
5
+ * fix: attribute.uncast([]) and realm.connect with synchronized models by @cyjake in https://github.com/cyjake/leoric/pull/201
6
+
7
+
8
+ **Full Changelog**: https://github.com/cyjake/leoric/compare/v1.13.1...v1.13.2
9
+
1
10
  1.13.1 / 2021-10-18
2
11
  ===================
3
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leoric",
3
- "version": "1.13.1",
3
+ "version": "1.13.2",
4
4
  "description": "JavaScript Object-relational mapping alchemy",
5
5
  "main": "index.js",
6
6
  "types": "types/index.d.ts",
@@ -20,6 +20,7 @@
20
20
  "test:mysql2": "./test/start.sh test/integration/mysql2.test.js",
21
21
  "test:postgres": "./test/start.sh test/integration/postgres.test.js",
22
22
  "test:sqlite": "./test/start.sh test/integration/sqlite.test.js",
23
+ "test:sqlcipher": "./test/start.sh test/integration/sqlcipher.test.js",
23
24
  "test:dts": "./test/start.sh test/types/dts.test.js",
24
25
  "test:coverage": "nyc ./test/start.sh && nyc report --reporter=lcov",
25
26
  "lint": "eslint ./",
@@ -127,7 +127,9 @@ class Attribute {
127
127
  }
128
128
 
129
129
  uncast(value) {
130
- if (Array.isArray(value)) return value.map(entry => this.type.uncast(entry));
130
+ if (Array.isArray(value) && this.jsType !== JSON) {
131
+ return value.map(entry => this.type.uncast(entry));
132
+ }
131
133
  return this.type.uncast(value);
132
134
  }
133
135
  }
package/src/realm.js CHANGED
@@ -130,8 +130,11 @@ class Realm {
130
130
  models = Object.values(this.models);
131
131
  }
132
132
 
133
+ // models could be connected already if cached
134
+ models = models.filter(model => !model.synchronized);
135
+
133
136
  if (models.length > 0) {
134
- await loadModels(this.Bone, models.filter(model => !model.synchronized), this.options);
137
+ await loadModels(this.Bone, models, this.options);
135
138
  }
136
139
  this.connected = true;
137
140
  return this.Bone;