meadow 2.0.4 → 2.0.6
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/.config/configstore/update-notifier-npm-check-updates.json +1 -1
- package/.config/configstore/update-notifier-npm.json +1 -1
- package/.config/vscode-sqltools/runningInfo.json +13 -0
- package/Dockerfile_LUXURYCode +39 -13
- package/debug/Harness.js +2 -2
- package/package.json +11 -7
- package/source/providers/Meadow-Provider-MSSQL.js +308 -0
- package/source/providers/Meadow-Provider-MySQL.js +87 -81
- package/test/Meadow-Provider-MSSQL-AnimalReadQuery.sql +5 -0
- package/test/Meadow-Provider-MSSQL_tests.js +1194 -0
- package/test/Meadow-Provider-MySQL_tests.js +49 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"numericVersion": 10000,
|
|
3
|
+
"releaseNotes": "https://vscode-sqltools.mteixeira.dev/changelog#v-1-0-0",
|
|
4
|
+
"run": 1690759233978,
|
|
5
|
+
"updated": false,
|
|
6
|
+
"version": "1.0.0",
|
|
7
|
+
"lastNotificationDate": 0,
|
|
8
|
+
"installedExtPlugins": {
|
|
9
|
+
"driver": [
|
|
10
|
+
"mtxr.sqltools-driver-mysql"
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
}
|
package/Dockerfile_LUXURYCode
CHANGED
|
@@ -27,19 +27,45 @@ RUN ( sudo mysqld_safe --skip-grant-tables --skip-networking & ) && sleep 5 &&
|
|
|
27
27
|
RUN sudo service mariadb restart && sleep 5 && mysql -u root -p"123456789" -e "CREATE DATABASE FableTest;"
|
|
28
28
|
|
|
29
29
|
RUN echo "...installing vscode extensions..."
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
# Mocha unit testing in the sidebar
|
|
31
|
+
RUN code-server --install-extension hbenl.vscode-mocha-test-adapter
|
|
32
|
+
RUN code-server --install-extension hbenl.test-adapter-converter
|
|
33
|
+
RUN code-server --install-extension hbenl.vscode-test-explorer
|
|
34
|
+
|
|
35
|
+
# Magic indentation rainbow
|
|
36
|
+
RUN code-server --install-extension oderwat.indent-rainbow
|
|
37
|
+
RUN code-server --install-extension dbaeumer.vscode-eslint
|
|
38
|
+
|
|
39
|
+
# Contextual git
|
|
40
|
+
RUN code-server --install-extension eamodio.gitlens
|
|
41
|
+
|
|
42
|
+
# Other extensions (uncomment them to have them automagic, or run this from a terminal to install in the container):
|
|
43
|
+
|
|
44
|
+
# SQL Tools
|
|
45
|
+
RUN code-server --install-extension mtxr.sqltools
|
|
46
|
+
RUN code-server --install-extension mtxr.sqltools-driver-mysql
|
|
47
|
+
|
|
48
|
+
# Microsoft's AI code completion
|
|
49
|
+
# RUN code-server --install-extension VisualStudioExptTeam.vscodeintellicode
|
|
50
|
+
|
|
51
|
+
# Live server -- make sure to open up the port on the docker image
|
|
52
|
+
# RUN code-server --install-extension ritwickdey.LiveServer
|
|
53
|
+
|
|
54
|
+
# Quick link to required modules' documentation
|
|
55
|
+
# RUN code-server --install-extension bengreenier.vscode-node-readme
|
|
56
|
+
|
|
57
|
+
# Switch up fonts
|
|
58
|
+
# RUN code-server --install-extension evan-buss.font-switcher
|
|
59
|
+
|
|
60
|
+
# Icons
|
|
61
|
+
# RUN code-server --install-extension vscode-icons-team.vscode-icons
|
|
62
|
+
# RUN code-server --install-extension PKief.material-icon-theme
|
|
63
|
+
|
|
64
|
+
# Hover over CSS colors to see them previewed
|
|
65
|
+
# RUN code-server --install-extension bierner.color-info
|
|
66
|
+
|
|
67
|
+
# An easy on the eyes color theme
|
|
68
|
+
# RUN code-server --install-extension daylerees.rainglow
|
|
43
69
|
|
|
44
70
|
SHELL ["/bin/bash", "-c"]
|
|
45
71
|
USER coder
|
package/debug/Harness.js
CHANGED
|
@@ -38,7 +38,7 @@ const _AnimalDefault = (
|
|
|
38
38
|
{
|
|
39
39
|
IDAnimal: null,
|
|
40
40
|
GUIDAnimal: '',
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
CreateDate: false,
|
|
43
43
|
CreatingIDUser: 0,
|
|
44
44
|
UpdateDate: false,
|
|
@@ -46,7 +46,7 @@ const _AnimalDefault = (
|
|
|
46
46
|
Deleted: 0,
|
|
47
47
|
DeleteDate: false,
|
|
48
48
|
DeletingIDUser: 0,
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
Name: 'Unknown',
|
|
51
51
|
Type: 'Unclassified'
|
|
52
52
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meadow",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "A data access library.",
|
|
5
5
|
"main": "source/Meadow.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
"test": "./node_modules/mocha/bin/_mocha -u tdd --exit -R spec",
|
|
10
10
|
"tests": "./node_modules/mocha/bin/_mocha -u tdd --exit -R spec --grep",
|
|
11
11
|
"build": "./node_modules/.bin/gulp build --full-paths",
|
|
12
|
-
"docker-dev-build
|
|
13
|
-
"docker-dev-run": "docker run -it -d --name meadow-dev -p
|
|
12
|
+
"docker-dev-build": "docker build ./ -f Dockerfile_LUXURYCode -t retold/meadow:local",
|
|
13
|
+
"docker-dev-run": "docker run -it -d --name meadow-dev -p 12342:8080 -p 12106:3306 -v \"$PWD/.config:/home/coder/.config\" -v \"$PWD:/home/coder/meadow\" -u \"$(id -u):$(id -g)\" -e \"DOCKER_USER=$USER\" retold/meadow:local",
|
|
14
|
+
"docker-dev-shell": "docker exec -it meadow-dev /bin/bash"
|
|
14
15
|
},
|
|
15
16
|
"mocha": {
|
|
16
17
|
"diff": true,
|
|
@@ -48,22 +49,25 @@
|
|
|
48
49
|
"alasql": "^3.1.0",
|
|
49
50
|
"browserify": "^17.0.0",
|
|
50
51
|
"chai": "4.3.7",
|
|
52
|
+
"fable": "^3.0.46",
|
|
51
53
|
"gulp": "^4.0.2",
|
|
52
54
|
"gulp-babel": "^8.0.0",
|
|
53
55
|
"gulp-sourcemaps": "^3.0.0",
|
|
54
56
|
"gulp-terser": "^2.1.0",
|
|
55
|
-
"fable": "^3.0.11",
|
|
56
57
|
"gulp-util": "^3.0.8",
|
|
58
|
+
"meadow-connection-mssql": "^1.0.1",
|
|
59
|
+
"meadow-connection-mysql": "^1.0.2",
|
|
57
60
|
"mocha": "10.2.0",
|
|
61
|
+
"mysql2": "^3.3.2",
|
|
58
62
|
"nyc": "^15.1.0",
|
|
59
63
|
"vinyl-buffer": "^1.0.1",
|
|
60
|
-
"vinyl-source-stream": "^2.0.0"
|
|
61
|
-
"mysql2": "^3.1.2"
|
|
64
|
+
"vinyl-source-stream": "^2.0.0"
|
|
62
65
|
},
|
|
63
66
|
"dependencies": {
|
|
64
67
|
"async": "3.2.4",
|
|
65
|
-
"foxhound": "^2.0.
|
|
68
|
+
"foxhound": "^2.0.4",
|
|
66
69
|
"is-my-json-valid": "2.20.6",
|
|
70
|
+
"npm-check-updates": "^16.10.12",
|
|
67
71
|
"simple-get": "^4.0.1"
|
|
68
72
|
}
|
|
69
73
|
}
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
// ##### Part of the **[retold](https://stevenvelozo.github.io/retold/)** system
|
|
2
|
+
/**
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author <steven@velozo.com>
|
|
5
|
+
*/
|
|
6
|
+
var MeadowProvider = function ()
|
|
7
|
+
{
|
|
8
|
+
function createNew(pFable)
|
|
9
|
+
{
|
|
10
|
+
// If a valid Fable object isn't passed in, return a constructor
|
|
11
|
+
if (typeof (pFable) !== 'object')
|
|
12
|
+
{
|
|
13
|
+
return { new: createNew };
|
|
14
|
+
}
|
|
15
|
+
var _Fable = pFable;
|
|
16
|
+
var _GlobalLogLevel = 0;
|
|
17
|
+
if (_Fable.settings.MSSQL)
|
|
18
|
+
{
|
|
19
|
+
_GlobalLogLevel = _Fable.settings.MSSQL.GlobalLogLevel || 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Build a connection pool, shared within this provider.
|
|
24
|
+
* This may be more performant as a shared object.
|
|
25
|
+
*/
|
|
26
|
+
var getSQLPool = function ()
|
|
27
|
+
{
|
|
28
|
+
// New-style default connection pool provider
|
|
29
|
+
// There are no legacy MSSQL open source connectors.
|
|
30
|
+
if (typeof (_Fable.MeadowMSSQLProvider) == 'object' && _Fable.MeadowMSSQLProvider.connected)
|
|
31
|
+
{
|
|
32
|
+
return _Fable.MeadowMSSQLProvider.pool;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return false;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// The Meadow marshaller also passes in the Schema as the third parameter, but this is a blunt function ATM.
|
|
39
|
+
var marshalRecordFromSourceToObject = function (pObject, pRecord)
|
|
40
|
+
{
|
|
41
|
+
// For now, crudely assign everything in pRecord to pObject
|
|
42
|
+
// This is safe in this context, and we don't want to slow down marshalling with millions of hasOwnProperty checks
|
|
43
|
+
for (var tmpColumn in pRecord)
|
|
44
|
+
{
|
|
45
|
+
pObject[tmpColumn] = pRecord[tmpColumn];
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
var Create = function (pQuery, fCallback)
|
|
50
|
+
{
|
|
51
|
+
var tmpResult = pQuery.parameters.result;
|
|
52
|
+
|
|
53
|
+
pQuery.setDialect('MSSQL').buildCreateQuery();
|
|
54
|
+
|
|
55
|
+
// TODO: Test the query before executing
|
|
56
|
+
if (pQuery.logLevel > 0 ||
|
|
57
|
+
_GlobalLogLevel > 0)
|
|
58
|
+
{
|
|
59
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
getSQLPool().getConnection(function (pError, pDBConnection)
|
|
63
|
+
{
|
|
64
|
+
pDBConnection.query(
|
|
65
|
+
pQuery.query.body,
|
|
66
|
+
pQuery.query.parameters,
|
|
67
|
+
// The MSSQL library also returns the Fields as the third parameter
|
|
68
|
+
function (pError, pRows)
|
|
69
|
+
{
|
|
70
|
+
pDBConnection.release();
|
|
71
|
+
tmpResult.error = pError;
|
|
72
|
+
tmpResult.value = false;
|
|
73
|
+
try
|
|
74
|
+
{
|
|
75
|
+
tmpResult.value = pRows.insertId;
|
|
76
|
+
}
|
|
77
|
+
catch (pErrorGettingRowcount)
|
|
78
|
+
{
|
|
79
|
+
_Fable.log.warn('Error getting insert ID during create query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
tmpResult.executed = true;
|
|
83
|
+
return fCallback();
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// This is a synchronous read, good for a few records.
|
|
90
|
+
// TODO: Add a pipe-able read for huge sets
|
|
91
|
+
var Read = function (pQuery, fCallback)
|
|
92
|
+
{
|
|
93
|
+
var tmpResult = pQuery.parameters.result;
|
|
94
|
+
|
|
95
|
+
pQuery.setDialect('MSSQL').buildReadQuery();
|
|
96
|
+
|
|
97
|
+
if (pQuery.logLevel > 0 ||
|
|
98
|
+
_GlobalLogLevel > 0)
|
|
99
|
+
{
|
|
100
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
let tmpPreparedStatement = _Fable.MeadowMSSQLProvider.preparedStatement;
|
|
104
|
+
// Now define the inputs for the prepared statement based on the parameters and the schema.
|
|
105
|
+
|
|
106
|
+
//tmpPreparedStatement.input('param', _Fable.MeadowMSSQLProvider.MSSQL.Int);
|
|
107
|
+
tmpPreparedStatement.prepare(pQuery.query.body,
|
|
108
|
+
(pPrepareError) =>
|
|
109
|
+
{
|
|
110
|
+
tmpPreparedStatement.execute(pQuery.query.parameters,
|
|
111
|
+
(pPreparedExecutionError, pPreparedResult) =>
|
|
112
|
+
{
|
|
113
|
+
_Fable.log.info(`Prepared statement returned...`, pPreparedResult);
|
|
114
|
+
// release the connection after queries are executed
|
|
115
|
+
tmpPreparedStatement.unprepare(
|
|
116
|
+
(pPreparedStatementUnprepareError) =>
|
|
117
|
+
{
|
|
118
|
+
_Fable.log.trace(`Prepared statement unprepared.`);
|
|
119
|
+
return fCallback(pPreparedStatementUnprepareError);
|
|
120
|
+
});
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
getSQLPool().getConnection(function (pError, pDBConnection)
|
|
124
|
+
{
|
|
125
|
+
pDBConnection.query(
|
|
126
|
+
pQuery.query.body,
|
|
127
|
+
pQuery.query.parameters,
|
|
128
|
+
// The MSSQL library also returns the Fields as the third parameter
|
|
129
|
+
function (pError, pRows)
|
|
130
|
+
{
|
|
131
|
+
pDBConnection.release();
|
|
132
|
+
tmpResult.error = pError;
|
|
133
|
+
tmpResult.value = pRows;
|
|
134
|
+
tmpResult.executed = true;
|
|
135
|
+
return fCallback();
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
var Update = function (pQuery, fCallback)
|
|
142
|
+
{
|
|
143
|
+
var tmpResult = pQuery.parameters.result;
|
|
144
|
+
|
|
145
|
+
pQuery.setDialect('MSSQL').buildUpdateQuery();
|
|
146
|
+
|
|
147
|
+
if (pQuery.logLevel > 0 ||
|
|
148
|
+
_GlobalLogLevel > 0)
|
|
149
|
+
{
|
|
150
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
getSQLPool().getConnection(function (pError, pDBConnection)
|
|
154
|
+
{
|
|
155
|
+
pDBConnection.query(
|
|
156
|
+
pQuery.query.body,
|
|
157
|
+
pQuery.query.parameters,
|
|
158
|
+
// The MSSQL library also returns the Fields as the third parameter
|
|
159
|
+
function (pError, pRows)
|
|
160
|
+
{
|
|
161
|
+
pDBConnection.release();
|
|
162
|
+
tmpResult.error = pError;
|
|
163
|
+
tmpResult.value = pRows;
|
|
164
|
+
tmpResult.executed = true;
|
|
165
|
+
return fCallback();
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
var Delete = function (pQuery, fCallback)
|
|
172
|
+
{
|
|
173
|
+
var tmpResult = pQuery.parameters.result;
|
|
174
|
+
|
|
175
|
+
pQuery.setDialect('MSSQL').buildDeleteQuery();
|
|
176
|
+
|
|
177
|
+
if (pQuery.logLevel > 0 ||
|
|
178
|
+
_GlobalLogLevel > 0)
|
|
179
|
+
{
|
|
180
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
getSQLPool().getConnection(function (pError, pDBConnection)
|
|
184
|
+
{
|
|
185
|
+
pDBConnection.query
|
|
186
|
+
(
|
|
187
|
+
pQuery.query.body,
|
|
188
|
+
pQuery.query.parameters,
|
|
189
|
+
// The MSSQL library also returns the Fields as the third parameter
|
|
190
|
+
function (pError, pRows)
|
|
191
|
+
{
|
|
192
|
+
pDBConnection.release();
|
|
193
|
+
tmpResult.error = pError;
|
|
194
|
+
tmpResult.value = false;
|
|
195
|
+
try
|
|
196
|
+
{
|
|
197
|
+
tmpResult.value = pRows.affectedRows;
|
|
198
|
+
}
|
|
199
|
+
catch (pErrorGettingRowcount)
|
|
200
|
+
{
|
|
201
|
+
_Fable.log.warn('Error getting affected rowcount during delete query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
|
|
202
|
+
}
|
|
203
|
+
tmpResult.executed = true;
|
|
204
|
+
return fCallback();
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
var Undelete = function (pQuery, fCallback)
|
|
211
|
+
{
|
|
212
|
+
var tmpResult = pQuery.parameters.result;
|
|
213
|
+
|
|
214
|
+
pQuery.setDialect('MSSQL').buildUndeleteQuery();
|
|
215
|
+
|
|
216
|
+
if (pQuery.logLevel > 0 ||
|
|
217
|
+
_GlobalLogLevel > 0)
|
|
218
|
+
{
|
|
219
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
getSQLPool().getConnection(function (pError, pDBConnection)
|
|
223
|
+
{
|
|
224
|
+
pDBConnection.query
|
|
225
|
+
(
|
|
226
|
+
pQuery.query.body,
|
|
227
|
+
pQuery.query.parameters,
|
|
228
|
+
// The MSSQL library also returns the Fields as the third parameter
|
|
229
|
+
function (pError, pRows)
|
|
230
|
+
{
|
|
231
|
+
pDBConnection.release();
|
|
232
|
+
tmpResult.error = pError;
|
|
233
|
+
tmpResult.value = false;
|
|
234
|
+
try
|
|
235
|
+
{
|
|
236
|
+
tmpResult.value = pRows.affectedRows;
|
|
237
|
+
}
|
|
238
|
+
catch (pErrorGettingRowcount)
|
|
239
|
+
{
|
|
240
|
+
_Fable.log.warn('Error getting affected rowcount during delete query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
|
|
241
|
+
}
|
|
242
|
+
tmpResult.executed = true;
|
|
243
|
+
return fCallback();
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
var Count = function (pQuery, fCallback)
|
|
250
|
+
{
|
|
251
|
+
var tmpResult = pQuery.parameters.result;
|
|
252
|
+
|
|
253
|
+
pQuery.setDialect('MSSQL').buildCountQuery();
|
|
254
|
+
|
|
255
|
+
if (pQuery.logLevel > 0 ||
|
|
256
|
+
_GlobalLogLevel > 0)
|
|
257
|
+
{
|
|
258
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
getSQLPool().getConnection(function (pError, pDBConnection)
|
|
262
|
+
{
|
|
263
|
+
pDBConnection.query(
|
|
264
|
+
pQuery.query.body,
|
|
265
|
+
pQuery.query.parameters,
|
|
266
|
+
// The MSSQL library also returns the Fields as the third parameter
|
|
267
|
+
function (pError, pRows)
|
|
268
|
+
{
|
|
269
|
+
pDBConnection.release();
|
|
270
|
+
tmpResult.executed = true;
|
|
271
|
+
tmpResult.error = pError;
|
|
272
|
+
tmpResult.value = false;
|
|
273
|
+
try
|
|
274
|
+
{
|
|
275
|
+
tmpResult.value = pRows[0].RowCount;
|
|
276
|
+
}
|
|
277
|
+
catch (pErrorGettingRowcount)
|
|
278
|
+
{
|
|
279
|
+
_Fable.log.warn('Error getting rowcount during count query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
|
|
280
|
+
}
|
|
281
|
+
return fCallback();
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
var tmpNewProvider = (
|
|
288
|
+
{
|
|
289
|
+
marshalRecordFromSourceToObject: marshalRecordFromSourceToObject,
|
|
290
|
+
|
|
291
|
+
Create: Create,
|
|
292
|
+
Read: Read,
|
|
293
|
+
Update: Update,
|
|
294
|
+
Delete: Delete,
|
|
295
|
+
Undelete: Undelete,
|
|
296
|
+
Count: Count,
|
|
297
|
+
|
|
298
|
+
new: createNew
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
return tmpNewProvider;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return createNew();
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
module.exports = new MeadowProvider();
|