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

leoric

Package Overview
Dependencies
Maintainers
1
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leoric - npm Package Compare versions

Comparing version 1.6.3 to 1.6.4

7

History.md

@@ -0,1 +1,8 @@

1.6.4 / 2021-07-16
==================
* refactor: connect({ Bone }) still necessary (#139)
* fix: formatting select join with subqueries should not tamper the subquery itself (#138)
* fix: describe table with more compatible syntax (#137)
1.6.3 / 2021-07-14

@@ -2,0 +9,0 @@ ==================

35

index.js

@@ -14,3 +14,3 @@ 'use strict';

const sequelize = require('./src/adapters/sequelize');
const { camelCase } = require('./src/utils/string');
const { camelCase, heresql } = require('./src/utils/string');
const Hint = require('./src/hint');

@@ -70,6 +70,6 @@

async function loadModels(Bone, models, opts) {
async function loadModels(Spine, models, opts) {
const { database } = opts;
const tables = models.map(model => model.physicTable);
const schemaInfo = await Bone.driver.querySchemaInfo(database, tables);
const schemaInfo = await Spine.driver.querySchemaInfo(database, tables);

@@ -80,3 +80,3 @@ for (const model of models) {

model.load(columns);
Bone.models[model.name] = model;
Spine.models[model.name] = model;
}

@@ -91,2 +91,3 @@

function createSpine(opts) {
if (opts.Bone && opts.Bone.prototype instanceof Bone) return opts.Bone;
if (opts.sequelize) return sequelize(Bone);

@@ -128,14 +129,5 @@ if (opts.subclass !== true) return Bone;

define(name, attributes, opts = {}, descriptors = {}) {
const { Bone } = this;
const Model = class extends Bone {
// export Model: instance.Model.name
get Model() {
return Model;
}
// export Model: class.Model.name
static get Model() {
return Model;
}
const Model = class extends this.Bone {
static name = name;
};
Object.defineProperty(Model, 'name', { value: name });
Model.init(attributes, opts, descriptors);

@@ -147,3 +139,2 @@ Bone.models[name] = Model;

async connect() {
const { Bone } = this;
const { models: dir } = this.options;

@@ -158,5 +149,7 @@

if (models.length > 0) await loadModels(Bone, models, this.options);
if (models.length > 0) {
await loadModels(this.Bone, models, this.options);
}
this.connected = true;
return Bone;
return this.Bone;
}

@@ -248,4 +241,5 @@

*/
const connect = async function connect(opts = {}) {
if (Bone.driver) throw new Error('connected already');
const connect = async function connect(opts) {
opts = { Bone, ...opts };
if (opts.Bone.driver) throw new Error('connected already');
const realm = new Realm(opts);

@@ -264,2 +258,3 @@ return await realm.connect();

sequelize,
heresql,
...Hint,

@@ -266,0 +261,0 @@ });

{
"name": "leoric",
"version": "1.6.3",
"version": "1.6.4",
"description": "JavaScript Object-relational mapping alchemy",

@@ -18,2 +18,3 @@ "main": "index.js",

"test:unit": "./test/start.sh unit",
"test:integration": "./test/start.sh integration",
"test:mysql": "./test/start.sh test/integration/mysql.test.js",

@@ -49,2 +50,3 @@ "test:mysql2": "./test/start.sh test/integration/mysql2.test.js",

"debug": "^3.1.0",
"heredoc": "^1.3.1",
"pluralize": "^7.0.0",

@@ -51,0 +53,0 @@ "sqlstring": "^2.3.0",

@@ -34,3 +34,3 @@ 'use strict';

const { escapeId } = this;
await this.query(`DESCRIBE TABLE ${escapeId(table)}`);
await this.query(`DESCRIBE ${escapeId(table)}`);
},

@@ -37,0 +37,0 @@

@@ -402,3 +402,3 @@ 'use strict';

if (internal) {
const token = copyExpr(JSON.parse(JSON.stringify(condition)), ({ type, value }) => {
const token = copyExpr(condition, ({ type, value }) => {
if (type === 'id') return { type, value };

@@ -405,0 +405,0 @@ });

@@ -439,5 +439,3 @@ 'use strict';

if (ast.args) {
for (let i = 0; i < ast.args.length; i++) {
ast.args[i] = copyExpr(ast.args[i], fn);
}
ast.args = ast.args.map(arg => copyExpr(arg, fn));
}

@@ -444,0 +442,0 @@ return ast;

@@ -940,7 +940,7 @@ 'use strict';

const len = havingConditions.length;
const condition = havingConditions.slice(1, len - 1).reduce((result, condition) => {
const combined = havingConditions.slice(1, len - 1).reduce((result, condition) => {
return { type: 'op', name: 'and', args: [result, condition] };
}, havingConditions[0]);
this.havingConditions = [
{ type: 'op', name: 'or', args: [condition, havingConditions[len - 1]] }
{ type: 'op', name: 'or', args: [combined, havingConditions[len - 1]] }
];

@@ -947,0 +947,0 @@ return this;

'use strict';
const heredoc = require('heredoc');
/**

@@ -46,6 +48,7 @@ * Convert the first charactor of the string from lowercase to uppercase.

* Convert multiline SQL into single line for better logging
* @param {string} text
* @param {string|Function} text
* @returns {string}
*/
function heresql(text) {
if (typeof text === 'function') text = heredoc(text);
return text.trim().split('\n').map(line => line.trim()).join(' ');

@@ -52,0 +55,0 @@ }

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