mythix-orm 1.0.1 → 1.0.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/package.json +1 -1
- package/.eslintrc.js +0 -94
- package/.vscode/launch.json +0 -34
- package/.vscode/settings.json +0 -10
- package/playground/test01.js +0 -15
- package/spec/connection/connection-base-spec.js +0 -126
- package/spec/connection/literals/average-literal-spec.js +0 -45
- package/spec/connection/literals/count-literal-spec.js +0 -42
- package/spec/connection/literals/distinct-literal-spec.js +0 -42
- package/spec/connection/literals/literal-spec.js +0 -26
- package/spec/connection/literals/max-literal-spec.js +0 -42
- package/spec/connection/literals/min-literal-spec.js +0 -42
- package/spec/connection/literals/sum-literal-spec.js +0 -42
- package/spec/helpers/default-helpers-spec.js +0 -108
- package/spec/model-spec.js +0 -736
- package/spec/proxy-class/proxy-class-spec.js +0 -173
- package/spec/query-engine/__snapshots__/QueryEngine-operations-query_operations_and_chaining-can_chain_query_conditions-001.snapshot +0 -94
- package/spec/query-engine/__snapshots__/QueryEngine-operations-query_operations_and_chaining-can_construct_a_query_context_with_a_model_call-001.snapshot +0 -35
- package/spec/query-engine/__snapshots__/QueryEngine-operations-query_operations_and_chaining-can_construct_a_query_context_with_a_model_sub-001.snapshot +0 -35
- package/spec/query-engine/__snapshots__/QueryEngine-operations-query_operations_and_chaining-can_set_a_default_scope_on_a_model-001.snapshot +0 -57
- package/spec/query-engine/__snapshots__/QueryEngine-operations-query_operations_and_chaining-can_unscope_default_scope_on_a_model-001.snapshot +0 -35
- package/spec/query-engine/query-engine-spec.js +0 -99
- package/spec/support/jasmine.json +0 -13
- package/spec/support/models/blob-test-model.js +0 -19
- package/spec/support/models/extended-user-model.js +0 -38
- package/spec/support/models/index.js +0 -27
- package/spec/support/models/number-model.js +0 -24
- package/spec/support/models/role-model.js +0 -26
- package/spec/support/models/role-thing-model.js +0 -41
- package/spec/support/models/scoped-user-model.js +0 -13
- package/spec/support/models/time-model.js +0 -36
- package/spec/support/models/user-model.js +0 -70
- package/spec/support/models/user-role-model.js +0 -36
- package/spec/support/models/user-thing-model.js +0 -46
- package/spec/support/models/validation-test-model.js +0 -40
- package/spec/support/snapshots.js +0 -293
- package/spec/support/test-helpers.js +0 -13
- package/spec/types/concrete/bigint-type-spec.js +0 -84
- package/spec/types/concrete/boolean-type-spec.js +0 -83
- package/spec/types/concrete/date-type-spec.js +0 -85
- package/spec/types/concrete/datetime-type-spec.js +0 -87
- package/spec/types/concrete/float-type-spec.js +0 -71
- package/spec/types/concrete/foreign-key-type-spec.js +0 -64
- package/spec/types/concrete/integer-type-spec.js +0 -71
- package/spec/types/concrete/string-type-spec.js +0 -91
- package/spec/types/concrete/uuid-v1-type-spec.js +0 -73
- package/spec/types/concrete/uuid-v4-type-spec.js +0 -65
- package/spec/types/type-spec.js +0 -101
- package/spec/types/virtual/model-types-spec.js +0 -401
- package/spec/utils/misc-utils-spec.js +0 -61
- package/spec/utils/model-utils-spec.js +0 -55
- package/spec/utils/query-utils-spec.js +0 -105
package/package.json
CHANGED
package/.eslintrc.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-magic-numbers */
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
'env': {
|
|
7
|
-
'browser': true,
|
|
8
|
-
'commonjs': true,
|
|
9
|
-
'es2021': true,
|
|
10
|
-
},
|
|
11
|
-
'extends': [
|
|
12
|
-
'eslint:recommended',
|
|
13
|
-
],
|
|
14
|
-
'parserOptions': {
|
|
15
|
-
'ecmaVersion': 'latest',
|
|
16
|
-
},
|
|
17
|
-
'plugins': [
|
|
18
|
-
'@spothero/eslint-plugin-spothero',
|
|
19
|
-
],
|
|
20
|
-
'rules': {
|
|
21
|
-
'@spothero/spothero/ternary-parentheses': 'error',
|
|
22
|
-
'arrow-parens': 'error',
|
|
23
|
-
'arrow-spacing': [ 'error', { before: true, after: true } ],
|
|
24
|
-
'block-scoped-var': 'warn',
|
|
25
|
-
'block-spacing': 'error',
|
|
26
|
-
'brace-style': [ 'error', '1tbs' ],
|
|
27
|
-
'camelcase': 'warn',
|
|
28
|
-
'comma-dangle': [ 'error', 'always-multiline' ],
|
|
29
|
-
'comma-spacing': [ 'error', { before: false, after: true } ],
|
|
30
|
-
'comma-style': [ 'error', 'last' ],
|
|
31
|
-
'curly': [ 'error', 'multi-or-nest', 'consistent' ],
|
|
32
|
-
'default-case-last': 'error',
|
|
33
|
-
'default-param-last': 'error',
|
|
34
|
-
'eqeqeq': [ 'error', 'smart' ],
|
|
35
|
-
'func-call-spacing': [ 'error', 'never' ],
|
|
36
|
-
'guard-for-in': 'error',
|
|
37
|
-
'implicit-arrow-linebreak': [ 'error', 'beside' ],
|
|
38
|
-
'indent': [ 'error', 2, { 'SwitchCase': 1, 'MemberExpression': 'off' } ],
|
|
39
|
-
'jsx-quotes': [ 'error', 'prefer-double' ],
|
|
40
|
-
'key-spacing': [ 'error', { beforeColon: false, afterColon: true, mode: 'minimum', 'align': 'value' } ],
|
|
41
|
-
'keyword-spacing': [ 'error', { before: true, after: true } ],
|
|
42
|
-
'linebreak-style': [ 'error', 'unix' ],
|
|
43
|
-
'lines-between-class-members': 'error',
|
|
44
|
-
'max-classes-per-file': [ 'error', 3 ],
|
|
45
|
-
'new-cap': [ 'error', { 'properties': false } ],
|
|
46
|
-
'new-parens': 'error',
|
|
47
|
-
'no-array-constructor': 'warn',
|
|
48
|
-
'no-caller': 'error',
|
|
49
|
-
'no-confusing-arrow': 'error',
|
|
50
|
-
'no-empty': 'warn',
|
|
51
|
-
'no-eq-null': 0,
|
|
52
|
-
'no-eval': 'error',
|
|
53
|
-
'no-extend-native': 'error',
|
|
54
|
-
'no-extra-label': 'error',
|
|
55
|
-
'no-floating-decimal': 'error',
|
|
56
|
-
'no-global-assign': 'error',
|
|
57
|
-
'no-implied-eval': 'error',
|
|
58
|
-
'no-labels': 'error',
|
|
59
|
-
'no-lone-blocks': 'warn',
|
|
60
|
-
'no-loop-func': 0,
|
|
61
|
-
'no-magic-numbers': [ 'warn', { ignoreArrayIndexes: true, ignoreDefaultValues: true, ignore: [ -1, 0, 1, 2, 16, 32, 64, 128, 256, 1024, 2048, 200, 301, 302, 400, 401, 404, 500 ] } ],
|
|
62
|
-
'no-nested-ternary': 'error',
|
|
63
|
-
'no-param-reassign': 'error',
|
|
64
|
-
'no-promise-executor-return': 'error',
|
|
65
|
-
'no-return-assign': 'error',
|
|
66
|
-
'no-sequences': 'error',
|
|
67
|
-
'no-shadow': 0,
|
|
68
|
-
'no-throw-literal': 'warn',
|
|
69
|
-
'no-trailing-spaces': 'error',
|
|
70
|
-
'no-unmodified-loop-condition': 'warn',
|
|
71
|
-
'no-unreachable-loop': 'warn',
|
|
72
|
-
'no-unreachable': 'warn',
|
|
73
|
-
'no-unused-private-class-members': 'warn',
|
|
74
|
-
'no-unused-vars': 'warn',
|
|
75
|
-
'no-whitespace-before-property': 'error',
|
|
76
|
-
'nonblock-statement-body-position': [ 'error', 'below' ],
|
|
77
|
-
'one-var': [ 'error', 'never' ],
|
|
78
|
-
'quotes': [ 'error', 'single' ],
|
|
79
|
-
'radix': 'error',
|
|
80
|
-
'rest-spread-spacing': [ 'error', 'never' ],
|
|
81
|
-
'semi-spacing': [ 'error', { before: false, after: true } ],
|
|
82
|
-
'semi-style': [ 'error', 'last' ],
|
|
83
|
-
'semi': 'error',
|
|
84
|
-
'space-before-blocks': 'error',
|
|
85
|
-
'space-infix-ops': 'error',
|
|
86
|
-
'space-unary-ops': [ 'error', { words: false, nonwords: false } ],
|
|
87
|
-
'strict': 'error',
|
|
88
|
-
'switch-colon-spacing': [ 'error', { before: false, after: true } ],
|
|
89
|
-
'template-curly-spacing': 'error',
|
|
90
|
-
'template-tag-spacing': 'error',
|
|
91
|
-
'wrap-iife': [ 'error', 'inside' ],
|
|
92
|
-
'yoda': 'error',
|
|
93
|
-
},
|
|
94
|
-
};
|
package/.vscode/launch.json
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// Use IntelliSense to learn about possible attributes.
|
|
3
|
-
// Hover to view descriptions of existing attributes.
|
|
4
|
-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
-
"version": "0.2.0",
|
|
6
|
-
"configurations": [
|
|
7
|
-
{
|
|
8
|
-
"type": "pwa-node",
|
|
9
|
-
"request": "launch",
|
|
10
|
-
"name": "Debug Unit Tests",
|
|
11
|
-
"skipFiles": [
|
|
12
|
-
"<node_internals>/**",
|
|
13
|
-
"node_modules/**/*.js",
|
|
14
|
-
"**/node_modules/**",
|
|
15
|
-
"async_hooks.js",
|
|
16
|
-
"inspector_async_hook.js"
|
|
17
|
-
],
|
|
18
|
-
"program": "${workspaceFolder}/node_modules/.bin/jasmine",
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"type": "pwa-node",
|
|
22
|
-
"request": "launch",
|
|
23
|
-
"name": "Playground Test 01",
|
|
24
|
-
"skipFiles": [
|
|
25
|
-
"<node_internals>/**",
|
|
26
|
-
"node_modules/**/*.js",
|
|
27
|
-
"**/node_modules/**",
|
|
28
|
-
"async_hooks.js",
|
|
29
|
-
"inspector_async_hook.js"
|
|
30
|
-
],
|
|
31
|
-
"program": "${workspaceFolder}/playground/test01.js",
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
-
}
|
package/.vscode/settings.json
DELETED
package/playground/test01.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-magic-numbers */
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
/* global describe, it, expect, beforeAll, fail, spyOn */
|
|
6
|
-
|
|
7
|
-
const { Model, ConnectionBase, Types } = require('../../lib');
|
|
8
|
-
const { User } = require('../support/models');
|
|
9
|
-
|
|
10
|
-
class TestModel extends Model {
|
|
11
|
-
static fields = {
|
|
12
|
-
'id': {
|
|
13
|
-
type: Types.UUIDV4,
|
|
14
|
-
defaultValue: Types.UUIDV4.Default.UUIDV4,
|
|
15
|
-
allowNull: false,
|
|
16
|
-
primaryKey: true,
|
|
17
|
-
},
|
|
18
|
-
'firstName': {
|
|
19
|
-
type: Types.STRING(64),
|
|
20
|
-
allowNull: true,
|
|
21
|
-
index: true,
|
|
22
|
-
},
|
|
23
|
-
'lastName': {
|
|
24
|
-
type: Types.STRING(64),
|
|
25
|
-
allowNull: true,
|
|
26
|
-
index: true,
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
describe('ConnectionBase', () => {
|
|
32
|
-
let connection;
|
|
33
|
-
|
|
34
|
-
beforeAll(() => {
|
|
35
|
-
try {
|
|
36
|
-
connection = new ConnectionBase({ models: [ TestModel ] });
|
|
37
|
-
} catch (error) {
|
|
38
|
-
console.error('Error in BeforeAll: ', error);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
describe('Model', () => {
|
|
43
|
-
describe('where', () => {
|
|
44
|
-
it('should be able to get a query engine from where', () => {
|
|
45
|
-
expect(User.where(connection)._getRawQuery()[0].rootModelName).toEqual('User');
|
|
46
|
-
expect(User.where(connection)._getRawQuery()[0].Model.getModelName()).toEqual('User');
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
describe('getUnscopedQueryEngine', () => {
|
|
51
|
-
it('should be able to get a query engine from getUnscopedQueryEngine', () => {
|
|
52
|
-
let user = new TestModel();
|
|
53
|
-
|
|
54
|
-
expect(user.getUnscopedQueryEngine()._getRawQuery()[0].rootModelName).toEqual('TestModel');
|
|
55
|
-
expect(user.getUnscopedQueryEngine()._getRawQuery()[0].Model.getModelName()).toEqual('TestModel');
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
describe('getQueryEngine', () => {
|
|
60
|
-
it('should be able to get a query engine from getQueryEngine', () => {
|
|
61
|
-
let user = new TestModel();
|
|
62
|
-
|
|
63
|
-
expect(user.getQueryEngine()._getRawQuery()[0].rootModelName).toEqual('TestModel');
|
|
64
|
-
expect(user.getQueryEngine()._getRawQuery()[0].Model.getModelName()).toEqual('TestModel');
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
describe('getModel', () => {
|
|
70
|
-
it('should be able to get a model by name', () => {
|
|
71
|
-
let model = connection.getModel('TestModel');
|
|
72
|
-
expect(model.getModelName()).toEqual('TestModel');
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('should be able to get a model by a fully qualified name', () => {
|
|
76
|
-
let model = connection.getModel('TestModel:id');
|
|
77
|
-
expect(model.getModelName()).toEqual('TestModel');
|
|
78
|
-
|
|
79
|
-
model = connection.getModel('TestModel::id.field');
|
|
80
|
-
expect(model.getModelName()).toEqual('TestModel');
|
|
81
|
-
|
|
82
|
-
model = connection.getModel('TestModel::');
|
|
83
|
-
expect(model.getModelName()).toEqual('TestModel');
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
describe('getField', () => {
|
|
88
|
-
it('should fail if model not defined', () => {
|
|
89
|
-
let field = connection.getField('firstName');
|
|
90
|
-
expect(field).toBe(undefined);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('should be able to get a field by name', () => {
|
|
94
|
-
let field = connection.getField('firstName', 'TestModel');
|
|
95
|
-
expect(field.fieldName).toEqual('firstName');
|
|
96
|
-
expect(field.Model.getModelName()).toEqual('TestModel');
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('should be able to get a field by a fully qualified name', () => {
|
|
100
|
-
let field = connection.getField('TestModel:firstName');
|
|
101
|
-
expect(field.fieldName).toEqual('firstName');
|
|
102
|
-
expect(field.Model.getModelName()).toEqual('TestModel');
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
describe('start', () => {
|
|
107
|
-
it('should throw an unimplemented error', async () => {
|
|
108
|
-
try {
|
|
109
|
-
await connection.start();
|
|
110
|
-
fail('unreachable');
|
|
111
|
-
} catch (error) {
|
|
112
|
-
expect(error).toBeInstanceOf(Error);
|
|
113
|
-
expect(error.message).toEqual('ConnectionBase::start: Child class is required to implement "start".');
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
describe('stop', () => {
|
|
119
|
-
it('should unbind all event listeners', async () => {
|
|
120
|
-
spyOn(connection, 'removeAllListeners').and.callThrough();
|
|
121
|
-
await connection.stop();
|
|
122
|
-
|
|
123
|
-
expect(connection.removeAllListeners.calls.count()).toEqual(1);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-magic-numbers */
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
/* global describe, it, expect, beforeAll */
|
|
6
|
-
|
|
7
|
-
const ConnectionBase = require('../../../lib/connection/connection-base');
|
|
8
|
-
const { AverageLiteral, Literal } = require('../../../lib/connection/literals');
|
|
9
|
-
|
|
10
|
-
describe('AverageLiteral', () => {
|
|
11
|
-
let connection;
|
|
12
|
-
let User;
|
|
13
|
-
|
|
14
|
-
beforeAll(async () => {
|
|
15
|
-
try {
|
|
16
|
-
connection = new ConnectionBase({
|
|
17
|
-
bindModels: false,
|
|
18
|
-
models: require('../../support/models'),
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
let models = connection.getModels();
|
|
22
|
-
User = models.User;
|
|
23
|
-
} catch (error) {
|
|
24
|
-
console.error('Error in beforeAll: ', error);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
describe('toString', () => {
|
|
29
|
-
it('can turn a fully qualified name into a min projection', () => {
|
|
30
|
-
expect((new AverageLiteral('User:id')).toString(connection)).toEqual('AVG("users"."id")');
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('will throw an exception if no field is present', () => {
|
|
34
|
-
expect(() => (new AverageLiteral()).toString(connection)).toThrow(new TypeError('AverageLiteral::fullyQualifiedNameToDefinition: Unable to find field for fully qualified name "undefined".'));
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('can turn a raw field into a projection field', () => {
|
|
38
|
-
expect((new AverageLiteral(User.fields.firstName)).toString(connection)).toEqual('AVG("users"."firstName")');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('can provide a SQL literal', () => {
|
|
42
|
-
expect((new AverageLiteral(new Literal('test'))).toString(connection)).toEqual('AVG(test)');
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-magic-numbers */
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
/* global describe, it, expect, beforeAll */
|
|
6
|
-
|
|
7
|
-
const ConnectionBase = require('../../../lib/connection/connection-base');
|
|
8
|
-
const { CountLiteral, Literal } = require('../../../lib/connection/literals');
|
|
9
|
-
|
|
10
|
-
describe('CountLiteral', () => {
|
|
11
|
-
let connection;
|
|
12
|
-
let User;
|
|
13
|
-
|
|
14
|
-
beforeAll(async () => {
|
|
15
|
-
connection = new ConnectionBase({
|
|
16
|
-
bindModels: false,
|
|
17
|
-
models: require('../../support/models'),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
let models = connection.getModels();
|
|
21
|
-
|
|
22
|
-
User = models.User;
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe('toString', () => {
|
|
26
|
-
it('can turn a fully qualified name into a count projection', () => {
|
|
27
|
-
expect((new CountLiteral('User:id')).toString(connection)).toEqual('COUNT("users"."id")');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('will default to star if no field is present', () => {
|
|
31
|
-
expect((new CountLiteral()).toString(connection)).toEqual('COUNT(*)');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('can turn a raw field into a projection field', () => {
|
|
35
|
-
expect((new CountLiteral(User.fields.firstName)).toString(connection)).toEqual('COUNT("users"."firstName")');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('can provide a SQL literal', () => {
|
|
39
|
-
expect((new CountLiteral(new Literal('test'))).toString(connection)).toEqual('COUNT(test)');
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-magic-numbers */
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
/* global describe, it, expect, beforeAll */
|
|
6
|
-
|
|
7
|
-
const ConnectionBase = require('../../../lib/connection/connection-base');
|
|
8
|
-
const { DistinctLiteral, Literal } = require('../../../lib/connection/literals');
|
|
9
|
-
|
|
10
|
-
describe('DistinctLiteral', () => {
|
|
11
|
-
let connection;
|
|
12
|
-
let User;
|
|
13
|
-
|
|
14
|
-
beforeAll(async () => {
|
|
15
|
-
connection = new ConnectionBase({
|
|
16
|
-
bindModels: false,
|
|
17
|
-
models: require('../../support/models'),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
let models = connection.getModels();
|
|
21
|
-
|
|
22
|
-
User = models.User;
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe('toString', () => {
|
|
26
|
-
it('can turn a fully qualified name into a projection field', () => {
|
|
27
|
-
expect((new DistinctLiteral('User:id')).toString(connection)).toEqual('DISTINCT "users"."id" AS "User:id"');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('will throw an exception if no field is present', () => {
|
|
31
|
-
expect(() => (new DistinctLiteral()).toString(connection)).toThrow(new TypeError('DistinctLiteral::fullyQualifiedNameToDefinition: Unable to find field for fully qualified name "undefined".'));
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('can turn a raw field into a projection field', () => {
|
|
35
|
-
expect((new DistinctLiteral(User.fields.firstName)).toString(connection)).toEqual('DISTINCT "users"."firstName" AS "User:firstName"');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('can provide a SQL literal', () => {
|
|
39
|
-
expect((new DistinctLiteral(new Literal('test'))).toString(connection)).toEqual('DISTINCT test');
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-magic-numbers */
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
/* global describe, it, expect, beforeAll */
|
|
6
|
-
|
|
7
|
-
const ConnectionBase = require('../../../lib/connection/connection-base');
|
|
8
|
-
const { Literal } = require('../../../lib/connection/literals');
|
|
9
|
-
|
|
10
|
-
describe('Literal', () => {
|
|
11
|
-
let connection;
|
|
12
|
-
|
|
13
|
-
beforeAll(async () => {
|
|
14
|
-
connection = new ConnectionBase({
|
|
15
|
-
bindModels: false,
|
|
16
|
-
models: require('../../support/models'),
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
describe('toString', () => {
|
|
21
|
-
it('can return anything as a literal', () => {
|
|
22
|
-
expect((new Literal('test')).toString(connection)).toEqual('test');
|
|
23
|
-
expect((new Literal('DERP(stuff)')).toString(connection)).toEqual('DERP(stuff)');
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-magic-numbers */
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
/* global describe, it, expect, beforeAll */
|
|
6
|
-
|
|
7
|
-
const ConnectionBase = require('../../../lib/connection/connection-base');
|
|
8
|
-
const { MaxLiteral, Literal } = require('../../../lib/connection/literals');
|
|
9
|
-
|
|
10
|
-
describe('MaxLiteral', () => {
|
|
11
|
-
let connection;
|
|
12
|
-
let User;
|
|
13
|
-
|
|
14
|
-
beforeAll(async () => {
|
|
15
|
-
connection = new ConnectionBase({
|
|
16
|
-
bindModels: false,
|
|
17
|
-
models: require('../../support/models'),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
let models = connection.getModels();
|
|
21
|
-
|
|
22
|
-
User = models.User;
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe('toString', () => {
|
|
26
|
-
it('can turn a fully qualified name into a min projection', () => {
|
|
27
|
-
expect((new MaxLiteral('User:id')).toString(connection)).toEqual('MAX("users"."id")');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('will throw an exception if no field is present', () => {
|
|
31
|
-
expect(() => (new MaxLiteral()).toString(connection)).toThrow(new TypeError('MaxLiteral::fullyQualifiedNameToDefinition: Unable to find field for fully qualified name "undefined".'));
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('can turn a raw field into a projection field', () => {
|
|
35
|
-
expect((new MaxLiteral(User.fields.firstName)).toString(connection)).toEqual('MAX("users"."firstName")');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('can provide a SQL literal', () => {
|
|
39
|
-
expect((new MaxLiteral(new Literal('test'))).toString(connection)).toEqual('MAX(test)');
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-magic-numbers */
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
/* global describe, it, expect, beforeAll */
|
|
6
|
-
|
|
7
|
-
const ConnectionBase = require('../../../lib/connection/connection-base');
|
|
8
|
-
const { MinLiteral, Literal } = require('../../../lib/connection/literals');
|
|
9
|
-
|
|
10
|
-
describe('MinLiteral', () => {
|
|
11
|
-
let connection;
|
|
12
|
-
let User;
|
|
13
|
-
|
|
14
|
-
beforeAll(async () => {
|
|
15
|
-
connection = new ConnectionBase({
|
|
16
|
-
bindModels: false,
|
|
17
|
-
models: require('../../support/models'),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
let models = connection.getModels();
|
|
21
|
-
|
|
22
|
-
User = models.User;
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe('toString', () => {
|
|
26
|
-
it('can turn a fully qualified name into a min projection', () => {
|
|
27
|
-
expect((new MinLiteral('User:id')).toString(connection)).toEqual('MIN("users"."id")');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('will throw an exception if no field is present', () => {
|
|
31
|
-
expect(() => (new MinLiteral()).toString(connection)).toThrow(new TypeError('MinLiteral::fullyQualifiedNameToDefinition: Unable to find field for fully qualified name "undefined".'));
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('can turn a raw field into a projection field', () => {
|
|
35
|
-
expect((new MinLiteral(User.fields.firstName)).toString(connection)).toEqual('MIN("users"."firstName")');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('can provide a SQL literal', () => {
|
|
39
|
-
expect((new MinLiteral(new Literal('test'))).toString(connection)).toEqual('MIN(test)');
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-magic-numbers */
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
/* global describe, it, expect, beforeAll */
|
|
6
|
-
|
|
7
|
-
const ConnectionBase = require('../../../lib/connection/connection-base');
|
|
8
|
-
const { SumLiteral, Literal } = require('../../../lib/connection/literals');
|
|
9
|
-
|
|
10
|
-
describe('SumLiteral', () => {
|
|
11
|
-
let connection;
|
|
12
|
-
let User;
|
|
13
|
-
|
|
14
|
-
beforeAll(async () => {
|
|
15
|
-
connection = new ConnectionBase({
|
|
16
|
-
bindModels: false,
|
|
17
|
-
models: require('../../support/models'),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
let models = connection.getModels();
|
|
21
|
-
|
|
22
|
-
User = models.User;
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe('toString', () => {
|
|
26
|
-
it('can turn a fully qualified name into a min projection', () => {
|
|
27
|
-
expect((new SumLiteral('User:id')).toString(connection)).toEqual('SUM("users"."id")');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('will throw an exception if no field is present', () => {
|
|
31
|
-
expect(() => (new SumLiteral()).toString(connection)).toThrow(new TypeError('SumLiteral::fullyQualifiedNameToDefinition: Unable to find field for fully qualified name "undefined".'));
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('can turn a raw field into a projection field', () => {
|
|
35
|
-
expect((new SumLiteral(User.fields.firstName)).toString(connection)).toEqual('SUM("users"."firstName")');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('can provide a SQL literal', () => {
|
|
39
|
-
expect((new SumLiteral(new Literal('test'))).toString(connection)).toEqual('SUM(test)');
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|