leoric 2.10.0 → 2.10.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/Readme.md +33 -0
- package/package.json +1 -1
- package/src/realm.js +2 -1
- package/src/spell.js +2 -3
package/Readme.md
CHANGED
|
@@ -118,3 +118,36 @@ If you are interested in fixing issues and contributing directly to the code bas
|
|
|
118
118
|
## egg-orm
|
|
119
119
|
|
|
120
120
|
If developing web applications with [egg framework](https://eggjs.org/), it's highly recommended using the [egg-orm](https://github.com/eggjs/egg-orm) plugin. More detailed examples about setting up egg-orm with egg framework in either JavaScript or TypeScript can be found at <https://github.com/eggjs/egg-orm/tree/master/examples>
|
|
121
|
+
|
|
122
|
+
## mysql nuances
|
|
123
|
+
|
|
124
|
+
macOS binds localhost to ipv6 `::1`, yet both mysql and mysql2 connect database with localhost by default, which means both will try connecting to mysql with `::1`. However, the mysql distribution installed with HomeBrew sets `bind_address = 127.0.0.1`, hence causes following error:
|
|
125
|
+
|
|
126
|
+
```js
|
|
127
|
+
Error: connect ECONNREFUSED ::1:3306
|
|
128
|
+
at __node_internal_captureLargerStackTrace (node:internal/errors:490:5)
|
|
129
|
+
at __node_internal_exceptionWithHostPort (node:internal/errors:668:12)
|
|
130
|
+
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Please change the configuration as below:
|
|
134
|
+
|
|
135
|
+
```diff
|
|
136
|
+
diff --git a/usr/local/etc/my.cnf b/usr/local/etc/my.cnf
|
|
137
|
+
index 7218354..d31859c 100644
|
|
138
|
+
--- a/usr/local/etc/my.cnf
|
|
139
|
+
+++ b/usr/local/etc/my.cnf
|
|
140
|
+
@@ -1,5 +1,5 @@
|
|
141
|
+
# Default Homebrew MySQL server config
|
|
142
|
+
[mysqld]
|
|
143
|
+
# Only allow connections from localhost
|
|
144
|
+
-bind-address = 127.0.0.1
|
|
145
|
+
+bind-address = 127.0.0.1,::1
|
|
146
|
+
mysqlx-bind-address = 127.0.0.1
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
and restart the mysql service:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
brew services mysql restart
|
|
153
|
+
```
|
package/package.json
CHANGED
package/src/realm.js
CHANGED
|
@@ -35,7 +35,8 @@ async function findModels(dir) {
|
|
|
35
35
|
for (const entry of entries) {
|
|
36
36
|
const extname = path.extname(entry.name);
|
|
37
37
|
if (entry.isFile() && ['.js', '.mjs'].includes(extname)) {
|
|
38
|
-
const
|
|
38
|
+
const exports = require(path.join(dir, entry.name));
|
|
39
|
+
const model = exports.__esModule ? exports.default : exports;
|
|
39
40
|
if (isBone(model)) models.push(model);
|
|
40
41
|
}
|
|
41
42
|
}
|
package/src/spell.js
CHANGED
|
@@ -387,13 +387,11 @@ class Spell {
|
|
|
387
387
|
|
|
388
388
|
#emptySpell() {
|
|
389
389
|
Object.assign(this, {
|
|
390
|
-
columns: [],
|
|
391
390
|
whereConditions: [],
|
|
392
391
|
groups: [],
|
|
393
|
-
orders:
|
|
392
|
+
orders: JSON.parse(JSON.stringify(this.orders)),
|
|
394
393
|
havingConditions: [],
|
|
395
394
|
joins: {},
|
|
396
|
-
skip: 0,
|
|
397
395
|
subqueryIndex: 0,
|
|
398
396
|
rowCount: 0,
|
|
399
397
|
skip: 0,
|
|
@@ -807,6 +805,7 @@ class Spell {
|
|
|
807
805
|
$with(...qualifiers) {
|
|
808
806
|
if (this.rowCount > 0 || this.skip > 0) {
|
|
809
807
|
const spell = this.dup;
|
|
808
|
+
spell.columns = [];
|
|
810
809
|
this.#emptySpell();
|
|
811
810
|
this.table = { type: 'subquery', value: spell };
|
|
812
811
|
}
|