Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

orma

Package Overview
Dependencies
Maintainers
2
Versions
236
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

orma - npm Package Compare versions

Comparing version 1.0.22 to 1.0.23

4

build/index.d.ts

@@ -1,2 +0,2 @@

export declare const introspector: (db: string, fn: (s: string[]) => Promise<any[]>) => Promise<import("./introspector/introspector").orma_schema>;
export declare const orma_query: (raw_query: any, orma_schema: any, query_function: (sql_string: string) => Promise<Record<string, unknown>[]>) => Promise<{}>;
export declare const introspector: (db: string, fn: (s: string[]) => Promise<Record<string, unknown>[][]>) => Promise<import("./introspector/introspector").orma_schema>;
export declare const orma_query: (raw_query: any, orma_schema: any, query_function: (sql_string: string[]) => Promise<Record<string, unknown>[][]>) => Promise<{}>;

@@ -117,3 +117,3 @@ /**

export declare const generate_field_schema: (mysql_column: mysql_column) => orma_field_schema;
export declare const introspector: (db: string, fn: (s: string[]) => Promise<any[]>) => Promise<orma_schema>;
export declare const introspector: (db: string, fn: (s: string[]) => Promise<Record<string, unknown>[][]>) => Promise<orma_schema>;
export {};

@@ -129,2 +129,4 @@ "use strict";

mocha_1.test('Should allow UPPERCASE mysql responses', function () {
// see the hack around in orma_query where keys are mapped to lowercase
// consider adding this transform to the actual generate database schema?
chai_1.expect(1).to.equal(2);

@@ -131,0 +133,0 @@ });

@@ -41,3 +41,3 @@ import { orma_schema } from '../introspector/introspector';

export declare const orma_nester: (results: [string[], Record<string, unknown>[]][], orma_schema: orma_schema) => {};
export declare const orma_query: (raw_query: any, orma_schema: any, query_function: (sql_string: string) => Promise<Record<string, unknown>[]>) => Promise<{}>;
export declare const orma_query: (raw_query: any, orma_schema: any, query_function: (sql_string: string[]) => Promise<Record<string, unknown>[][]>) => Promise<{}>;
export {};

@@ -531,3 +531,3 @@ "use strict";

});
return [4 /*yield*/, Promise.all(sql_strings.map(function (sql_string) { return query_function(sql_string); }))
return [4 /*yield*/, query_function(sql_strings)
// Combine outputs

@@ -534,0 +534,0 @@ ];

@@ -62,3 +62,3 @@ "use strict";

});
mocha_1.test('\'not\' command works', function () {
mocha_1.test("'not' command works", function () {
var json = {

@@ -95,11 +95,8 @@ $not: {

var goal = [
[['vendors'], ['vendors', 'products']],
[
['vendors'],
['vendors', 'products']
],
[
['vendors', 'products', 'vins'],
['vendors', 'products', 'images'],
['vendors', 'products', 'images', 'image_urls']
], // then this will be queried
] // then this will be queried
];

@@ -119,5 +116,3 @@ chai_1.expect(result).to.deep.equal(goal);

// the split happens at variants because it has a where clause
var goal = [
[['vendors'], ['products']],
];
var goal = [[['vendors'], ['products']]];
chai_1.expect(result).to.deep.equal(goal);

@@ -134,5 +129,3 @@ });

// the split happens at variants because it has a where clause
var goal = [
[['my_products']],
];
var goal = [[['my_products']]];
chai_1.expect(result).to.deep.equal(goal);

@@ -159,16 +152,28 @@ });

var where = {
$and: [{
$any: [['images'], {
$and: [
{
$any: [
['images'],
{
$eq: ['id', 1]
}]
}, {
$any: [['vendors'], {
}
]
},
{
$any: [
['vendors'],
{
$eq: ['id', 1]
}]
}]
}
]
}
]
};
var converted_where = query_1.convert_any_path_macro(where, 'products', false, orma_schema);
var goal = {
$and: [{
$in: ['id', {
$and: [
{
$in: [
'id',
{
$select: ['product_id'],

@@ -179,6 +184,9 @@ $from: 'images',

}
}]
}
]
},
{
$in: ['vendor_id', {
$in: [
'vendor_id',
{
$select: ['id'],

@@ -189,4 +197,6 @@ $from: 'vendors',

}
}]
}]
}
]
}
]
};

@@ -197,13 +207,20 @@ chai_1.expect(converted_where).to.deep.equal(goal);

var where = {
$any: [['images', 'image_urls'], {
$any: [
['images', 'image_urls'],
{
$eq: ['id', 1]
}]
}
]
};
var converted_where = query_1.convert_any_path_macro(where, 'products', false, orma_schema);
var goal = {
$in: ['id', {
$in: [
'id',
{
$select: ['product_id'],
$from: 'images',
$where: {
$in: ['id', {
$in: [
'id',
{
$select: ['image_id'],

@@ -214,5 +231,7 @@ $from: 'image_urls',

}
}]
}
]
}
}]
}
]
};

@@ -223,15 +242,25 @@ chai_1.expect(converted_where).to.deep.equal(goal);

var where = {
$any: [['images'], {
$any: [['image_urls'], {
$any: [
['images'],
{
$any: [
['image_urls'],
{
$eq: ['id', 1]
}]
}]
}
]
}
]
};
var converted_where = query_1.convert_any_path_macro(where, 'products', false, orma_schema);
var goal = {
$in: ['id', {
$in: [
'id',
{
$select: ['product_id'],
$from: 'images',
$where: {
$in: ['id', {
$in: [
'id',
{
$select: ['image_id'],

@@ -242,5 +271,7 @@ $from: 'image_urls',

}
}]
}
]
}
}]
}
]
};

@@ -251,9 +282,14 @@ chai_1.expect(converted_where).to.deep.equal(goal);

var where = {
$any: [['images'], {
$any: [
['images'],
{
$eq: ['id', 1]
}]
}
]
};
var converted_where = query_1.convert_any_path_macro(where, 'products', true, orma_schema);
var goal = {
$in: ['id', {
$in: [
'id',
{
$select: ['product_id'],

@@ -264,3 +300,4 @@ $from: 'images',

}
}]
}
]
};

@@ -302,5 +339,3 @@ chai_1.expect(converted_where).to.deep.equal(goal);

};
var previous_results = [
[['products'], [{ id: 1 }, { id: 2 }]]
];
var previous_results = [[['products'], [{ id: 1 }, { id: 2 }]]];
var json_sql = query_1.query_to_json_sql(query, ['products', 'images'], previous_results, orma_schema);

@@ -323,5 +358,3 @@ var goal = {

};
var previous_results = [
[['products'], [{ id: 1 }, { id: 2 }]]
];
var previous_results = [[['products'], [{ id: 1 }, { id: 2 }]]];
var json_sql1 = query_1.query_to_json_sql(query, ['products'], previous_results, orma_schema);

@@ -355,5 +388,3 @@ var goal1 = {

};
var previous_results = [
[['products'], [{ id: 1 }, { id: 2 }]]
];
var previous_results = [[['products'], [{ id: 1 }, { id: 2 }]]];
var json_sql = query_1.query_to_json_sql(query, ['products', 'images', 'image_urls'], previous_results, orma_schema);

@@ -365,3 +396,5 @@ (_a = json_sql === null || json_sql === void 0 ? void 0 : json_sql.$select) === null || _a === void 0 ? void 0 : _a.sort();

$where: {
$in: ['image_id', {
$in: [
'image_id',
{
$select: ['id'],

@@ -372,3 +405,4 @@ $from: 'images',

}
}]
}
]
}

@@ -389,3 +423,3 @@ };

[['products'], [{ id: 1 }, { id: 2 }]],
[['products', 'images'], [{ id: 3 }]],
[['products', 'images'], [{ id: 3 }]]
];

@@ -402,3 +436,3 @@ var json_sql = query_1.query_to_json_sql(query, ['products', 'images', 'image_urls'], previous_results, orma_schema);

});
mocha_1.test('respects \'from\' clause', function () {
mocha_1.test("respects 'from' clause", function () {
var query = {

@@ -417,3 +451,3 @@ my_products: {

});
mocha_1.test.skip('handles \'any\' clause', function () {
mocha_1.test.skip("handles 'any' clause", function () {
var query = {

@@ -423,3 +457,3 @@ $where: {

},
id: true,
id: true
};

@@ -430,2 +464,28 @@ var json_sql = query_1.query_to_json_sql(query, ['products'], [], {});

});
mocha_1.test('should not put where or having when not required', function () {
var query = {
calls: {
id: true
}
};
var orma_schema = {
calls: {
$comment: '',
id: {
data_type: 'number',
required: true,
indexed: true,
unique: true,
primary_key: true,
character_count: 10
}
}
};
var actual_query = '';
var test = query_1.orma_query(query, orma_schema, function (sql_strings) {
actual_query = sql_strings[0];
return Promise.resolve([]);
});
chai_1.expect(actual_query).to.deep.equal('SELECT id FROM calls');
});
});

@@ -522,2 +582,2 @@ });

*/
*/
{
"name": "orma",
"version": "1.0.22",
"version": "1.0.23",
"description": "A declarative relational syncronous orm",

@@ -5,0 +5,0 @@ "main": "build/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc