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

@simplysm/sd-orm-common

Package Overview
Dependencies
Maintainers
1
Versions
617
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@simplysm/sd-orm-common - npm Package Compare versions

Comparing version 3.5.9 to 3.5.12

2

.eslintrc.js

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

typescript: {
directory: require("path").join(__dirname, "tsconfig.json")
project: require("path").join(__dirname, "tsconfig.json")
}

@@ -17,0 +17,0 @@ }

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

case 1:
isDbExists = (_v.sent()).length > 0;
isDbExists = (_v.sent())[0].length > 0;
if (!isDbExists) return [3, 11];

@@ -235,3 +235,3 @@ return [4, this.executeDefsAsync([

case 2:
hasMigrationTable = (_v.sent()).length > 0;
hasMigrationTable = (_v.sent())[0].length > 0;
if (!hasMigrationTable) return [3, 10];

@@ -363,28 +363,33 @@ return [4, this.systemMigration

var fkDef = _a[_i];
var targetTableDef = DbDefinitionUtils_1.DbDefinitionUtils.getTableDef(fkDef.targetTypeFwd());
if (targetTableDef.columns.length < 1) {
throw new Error(targetTableDef.name + "\uC758 \uCEEC\uB7FC \uC124\uC815\uC774 \uC798\uBABB\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
try {
var targetTableDef = DbDefinitionUtils_1.DbDefinitionUtils.getTableDef(fkDef.targetTypeFwd());
if (targetTableDef.columns.length < 1) {
throw new Error(targetTableDef.name + "\uC758 \uCEEC\uB7FC \uC124\uC815\uC774 \uC798\uBABB\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
}
var targetPkNames = targetTableDef.columns
.filter(function (item) { return item.primaryKey !== undefined; })
.orderBy(function (item) { return item.primaryKey; })
.map(function (item) { return item.name; });
addFkQueryDefs.push({
type: "addForeignKey",
table: {
database: (_c = tableDef.database) !== null && _c !== void 0 ? _c : this_1.schema.database,
schema: (_d = tableDef.schema) !== null && _d !== void 0 ? _d : this_1.schema.schema,
name: tableDef.name
},
foreignKey: {
name: fkDef.name,
fkColumns: fkDef.columnPropertyKeys.map(function (propKey) { return tableDef.columns.single(function (col) { return col.propertyKey === propKey; }).name; }),
targetTable: {
database: (_e = targetTableDef.database) !== null && _e !== void 0 ? _e : this_1.schema.database,
schema: (_f = targetTableDef.schema) !== null && _f !== void 0 ? _f : this_1.schema.schema,
name: targetTableDef.name
},
targetPkColumns: targetPkNames
}
});
}
var targetPkNames = targetTableDef.columns
.filter(function (item) { return item.primaryKey !== undefined; })
.orderBy(function (item) { return item.primaryKey; })
.map(function (item) { return item.name; });
addFkQueryDefs.push({
type: "addForeignKey",
table: {
database: (_c = tableDef.database) !== null && _c !== void 0 ? _c : this_1.schema.database,
schema: (_d = tableDef.schema) !== null && _d !== void 0 ? _d : this_1.schema.schema,
name: tableDef.name
},
foreignKey: {
name: fkDef.name,
fkColumns: fkDef.columnPropertyKeys.map(function (propKey) { return tableDef.columns.single(function (col) { return col.propertyKey === propKey; }).name; }),
targetTable: {
database: (_e = targetTableDef.database) !== null && _e !== void 0 ? _e : this_1.schema.database,
schema: (_f = targetTableDef.schema) !== null && _f !== void 0 ? _f : this_1.schema.schema,
name: targetTableDef.name
},
targetPkColumns: targetPkNames
}
});
catch (err) {
throw new sd_core_common_1.SdError(err, tableDef.name + " > " + fkDef.name + ": 오류");
}
}

@@ -391,0 +396,0 @@ };

@@ -304,4 +304,5 @@ "use strict";

var subFrom = clone.getSelectDef();
var unknownOrderBys;
if (subFrom.orderBy) {
var unknownOrderBys = subFrom.orderBy.filter(function (item) { return !Object.values(subFrom.select).includes(item[0]); });
unknownOrderBys = subFrom.orderBy.filter(function (item) { return !Object.values(subFrom.select).includes(item[0]); });
var seq = 0;

@@ -313,5 +314,16 @@ for (var _b = 0, unknownOrderBys_1 = unknownOrderBys; _b < unknownOrderBys_1.length; _b++) {

}
delete subFrom.orderBy;
}
var currEntity = this._getParentEntity(clone._entity, this._as, undefined);
return new Queryable(this.db, tableType, this._as, currEntity, { from: subFrom });
var result = new Queryable(this.db, tableType, this._as, currEntity, { from: subFrom });
if (unknownOrderBys && unknownOrderBys.length > 0) {
result._def.orderBy = [];
var seq = 0;
for (var _c = 0, unknownOrderBys_2 = unknownOrderBys; _c < unknownOrderBys_2.length; _c++) {
var unknownOrderBy = unknownOrderBys_2[_c];
seq++;
result._def.orderBy.push(["__order_" + seq, unknownOrderBy[1]]);
}
}
return result;
};

@@ -639,7 +651,7 @@ Queryable.prototype.getSelectDef = function () {

Queryable.prototype.countAsync = function () {
var _a, _b;
var _a;
return tslib_1.__awaiter(this, void 0, Promise, function () {
var queryable, item;
return tslib_1.__generator(this, function (_c) {
switch (_c.label) {
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:

@@ -652,8 +664,8 @@ if (this._def.distinct) {

queryable = this.select(function () { return ({ cnt: new QueryUnit_1.QueryUnit(Number, "COUNT(*)") }); });
(_a = queryable._def.orderBy) === null || _a === void 0 ? void 0 : _a.remove(function (item1) { return item1[0] === "[__searchOrder]"; });
delete queryable._def.orderBy;
delete queryable._entity["__searchOrder"];
return [4, queryable.singleAsync()];
case 1:
item = _c.sent();
return [2, ((_b = item === null || item === void 0 ? void 0 : item.cnt) !== null && _b !== void 0 ? _b : 0)];
item = _b.sent();
return [2, ((_a = item === null || item === void 0 ? void 0 : item.cnt) !== null && _a !== void 0 ? _a : 0)];
}

@@ -660,0 +672,0 @@ });

@@ -48,2 +48,8 @@ "use strict";

};
QueryHelper.prototype.isFalse = function (source) {
return this.or([
this.isNull(source),
this.equal(source, false)
]);
};
QueryHelper.prototype.lessThen = function (source, target) {

@@ -358,3 +364,4 @@ return [this.getQueryValue(source), " < ", this.getQueryValue(target)];

var _a;
this._type = SdOrmUtils_1.SdOrmUtils.getQueryValueType(then);
var _b;
this._type = (_b = SdOrmUtils_1.SdOrmUtils.getQueryValueType(then)) !== null && _b !== void 0 ? _b : this._type;
(_a = this._cases).push.apply(_a, [" WHEN ", this._qh.getQueryValue(predicate), " THEN ", this._qh.getQueryValue(then)]);

@@ -364,3 +371,4 @@ return this;

CaseQueryHelper.prototype.else = function (then) {
this._type = SdOrmUtils_1.SdOrmUtils.getQueryValueType(then);
var _a;
this._type = (_a = SdOrmUtils_1.SdOrmUtils.getQueryValueType(then)) !== null && _a !== void 0 ? _a : this._type;
return new QueryUnit_1.QueryUnit(this._type, tslib_1.__spreadArrays(["CASE "], this._cases, [" ELSE ", this._qh.getQueryValue(then), " END"]));

@@ -367,0 +375,0 @@ };

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

{ type: "getDatabaseInfo", database: this.schema.database }
])).length > 0;
]))[0].length > 0;
if (isDbExists) {

@@ -134,3 +134,3 @@ const hasMigrationTable = (await this.executeDefsAsync([

}
])).length > 0;
]))[0].length > 0;
if (hasMigrationTable) {

@@ -230,28 +230,33 @@ const dbMigrationCodes = (await this.systemMigration

for (const fkDef of tableDef.foreignKeys) {
const targetTableDef = DbDefinitionUtils_1.DbDefinitionUtils.getTableDef(fkDef.targetTypeFwd());
if (targetTableDef.columns.length < 1) {
throw new Error(`${targetTableDef.name}의 컬럼 설정이 잘못되었습니다.`);
try {
const targetTableDef = DbDefinitionUtils_1.DbDefinitionUtils.getTableDef(fkDef.targetTypeFwd());
if (targetTableDef.columns.length < 1) {
throw new Error(`${targetTableDef.name}의 컬럼 설정이 잘못되었습니다.`);
}
const targetPkNames = targetTableDef.columns
.filter(item => item.primaryKey !== undefined)
.orderBy(item => item.primaryKey)
.map(item => item.name);
addFkQueryDefs.push({
type: "addForeignKey",
table: {
database: (_c = tableDef.database) !== null && _c !== void 0 ? _c : this.schema.database,
schema: (_d = tableDef.schema) !== null && _d !== void 0 ? _d : this.schema.schema,
name: tableDef.name
},
foreignKey: {
name: fkDef.name,
fkColumns: fkDef.columnPropertyKeys.map(propKey => tableDef.columns.single(col => col.propertyKey === propKey).name),
targetTable: {
database: (_e = targetTableDef.database) !== null && _e !== void 0 ? _e : this.schema.database,
schema: (_f = targetTableDef.schema) !== null && _f !== void 0 ? _f : this.schema.schema,
name: targetTableDef.name
},
targetPkColumns: targetPkNames
}
});
}
const targetPkNames = targetTableDef.columns
.filter(item => item.primaryKey !== undefined)
.orderBy(item => item.primaryKey)
.map(item => item.name);
addFkQueryDefs.push({
type: "addForeignKey",
table: {
database: (_c = tableDef.database) !== null && _c !== void 0 ? _c : this.schema.database,
schema: (_d = tableDef.schema) !== null && _d !== void 0 ? _d : this.schema.schema,
name: tableDef.name
},
foreignKey: {
name: fkDef.name,
fkColumns: fkDef.columnPropertyKeys.map(propKey => tableDef.columns.single(col => col.propertyKey === propKey).name),
targetTable: {
database: (_e = targetTableDef.database) !== null && _e !== void 0 ? _e : this.schema.database,
schema: (_f = targetTableDef.schema) !== null && _f !== void 0 ? _f : this.schema.schema,
name: targetTableDef.name
},
targetPkColumns: targetPkNames
}
});
catch (err) {
throw new sd_core_common_1.SdError(err, tableDef.name + " > " + fkDef.name + ": 오류");
}
}

@@ -258,0 +263,0 @@ }

@@ -283,4 +283,5 @@ "use strict";

const subFrom = clone.getSelectDef();
let unknownOrderBys;
if (subFrom.orderBy) {
const unknownOrderBys = subFrom.orderBy.filter(item => !Object.values(subFrom.select).includes(item[0]));
unknownOrderBys = subFrom.orderBy.filter(item => !Object.values(subFrom.select).includes(item[0]));
let seq = 0;

@@ -291,5 +292,15 @@ for (const unknownOrderBy of unknownOrderBys) {

}
delete subFrom.orderBy;
}
const currEntity = this._getParentEntity(clone._entity, this._as, undefined);
return new Queryable(this.db, tableType, this._as, currEntity, { from: subFrom });
const result = new Queryable(this.db, tableType, this._as, currEntity, { from: subFrom });
if (unknownOrderBys && unknownOrderBys.length > 0) {
result._def.orderBy = [];
let seq = 0;
for (const unknownOrderBy of unknownOrderBys) {
seq++;
result._def.orderBy.push(["__order_" + seq, unknownOrderBy[1]]);
}
}
return result;
}

@@ -582,3 +593,3 @@ getSelectDef() {

async countAsync() {
var _a, _b;
var _a;
if (this._def.distinct) {

@@ -590,6 +601,6 @@ throw new Error("distinct 이후엔 'countAsync'를 사용할 수 없습니다." +

const queryable = this.select(() => ({ cnt: new QueryUnit_1.QueryUnit(Number, "COUNT(*)") }));
(_a = queryable._def.orderBy) === null || _a === void 0 ? void 0 : _a.remove(item1 => item1[0] === "[__searchOrder]");
delete queryable._def.orderBy;
delete queryable._entity["__searchOrder"];
const item = await queryable.singleAsync();
return ((_b = item === null || item === void 0 ? void 0 : item.cnt) !== null && _b !== void 0 ? _b : 0);
return ((_a = item === null || item === void 0 ? void 0 : item.cnt) !== null && _a !== void 0 ? _a : 0);
}

@@ -596,0 +607,0 @@ async insertAsync(...records) {

@@ -12,2 +12,3 @@ import { ISelectQueryDef, TDbDateSeparator, TEntityValue, TEntityValueOrQueryableOrArray, TQueryBuilderValue, TQueryValue } from "./commons";

isNotNull<T extends TQueryValue>(source: TEntityValue<T>): TQueryBuilderValue[];
isFalse<T extends TQueryValue>(source: TEntityValue<T>): TQueryBuilderValue[];
lessThen<T extends number | Number | DateOnly | DateTime | Time>(source: TEntityValue<T | undefined>, target: TEntityValue<T | undefined>): TQueryBuilderValue[];

@@ -14,0 +15,0 @@ lessThenOrEqual<T extends number | Number | DateOnly | DateTime | Time>(source: TEntityValue<T | undefined>, target: TEntityValue<T | undefined>): TQueryBuilderValue[];

@@ -46,2 +46,8 @@ "use strict";

}
isFalse(source) {
return this.or([
this.isNull(source),
this.equal(source, false)
]);
}
lessThen(source, target) {

@@ -338,3 +344,4 @@ return [this.getQueryValue(source), " < ", this.getQueryValue(target)];

case(predicate, then) {
this._type = SdOrmUtils_1.SdOrmUtils.getQueryValueType(then);
var _a;
this._type = (_a = SdOrmUtils_1.SdOrmUtils.getQueryValueType(then)) !== null && _a !== void 0 ? _a : this._type;
this._cases.push(...[" WHEN ", this._qh.getQueryValue(predicate), " THEN ", this._qh.getQueryValue(then)]);

@@ -344,3 +351,4 @@ return this;

else(then) {
this._type = SdOrmUtils_1.SdOrmUtils.getQueryValueType(then);
var _a;
this._type = (_a = SdOrmUtils_1.SdOrmUtils.getQueryValueType(then)) !== null && _a !== void 0 ? _a : this._type;
return new QueryUnit_1.QueryUnit(this._type, ["CASE ", ...this._cases, " ELSE ", this._qh.getQueryValue(then), " END"]);

@@ -347,0 +355,0 @@ }

{
"name": "@simplysm/sd-orm-common",
"version": "3.5.9",
"version": "3.5.12",
"description": "심플리즘 패키지 - ORM 모듈 (browser/node)",

@@ -13,4 +13,4 @@ "author": "김석래",

"dependencies": {
"@simplysm/sd-core-common": "3.5.9"
"@simplysm/sd-core-common": "3.5.12"
}
}

@@ -5,3 +5,3 @@ import { QueryBuilder } from "./QueryBuilder";

import { IQueryResultParseOption, TQueryDef } from "./commons";
import { NeverEntryError, ObjectUtils, Type } from "@simplysm/sd-core-common";
import { NeverEntryError, ObjectUtils, SdError, Type } from "@simplysm/sd-core-common";
import { IDbMigration } from "./IDbMigration";

@@ -12,2 +12,4 @@ import { Queryable } from "./Queryable";

// TODO: 모든 데이터를 CSV로 백업하는 기능 추가
export abstract class DbContext {

@@ -157,3 +159,3 @@ public static readonly selectCache = new Map<string, { result: any[]; timeout: any } | undefined>();

])
).length > 0;
)[0].length > 0;

@@ -173,3 +175,3 @@ if (isDbExists) {

])
).length > 0;
)[0].length > 0;

@@ -291,30 +293,35 @@ if (hasMigrationTable) {

for (const fkDef of tableDef.foreignKeys) {
const targetTableDef = DbDefinitionUtils.getTableDef(fkDef.targetTypeFwd());
if (targetTableDef.columns.length < 1) {
throw new Error(`${targetTableDef.name}의 컬럼 설정이 잘못되었습니다.`);
}
try {
const targetTableDef = DbDefinitionUtils.getTableDef(fkDef.targetTypeFwd());
if (targetTableDef.columns.length < 1) {
throw new Error(`${targetTableDef.name}의 컬럼 설정이 잘못되었습니다.`);
}
const targetPkNames = targetTableDef.columns
.filter(item => item.primaryKey !== undefined)
.orderBy(item => item.primaryKey!)
.map(item => item.name);
const targetPkNames = targetTableDef.columns
.filter(item => item.primaryKey !== undefined)
.orderBy(item => item.primaryKey!)
.map(item => item.name);
addFkQueryDefs.push({
type: "addForeignKey",
table: {
database: tableDef.database ?? this.schema.database,
schema: tableDef.schema ?? this.schema.schema,
name: tableDef.name
},
foreignKey: {
name: fkDef.name,
fkColumns: fkDef.columnPropertyKeys.map(propKey => tableDef.columns.single(col => col.propertyKey === propKey)!.name),
targetTable: {
database: targetTableDef.database ?? this.schema.database,
schema: targetTableDef.schema ?? this.schema.schema,
name: targetTableDef.name
addFkQueryDefs.push({
type: "addForeignKey",
table: {
database: tableDef.database ?? this.schema.database,
schema: tableDef.schema ?? this.schema.schema,
name: tableDef.name
},
targetPkColumns: targetPkNames
}
});
foreignKey: {
name: fkDef.name,
fkColumns: fkDef.columnPropertyKeys.map(propKey => tableDef.columns.single(col => col.propertyKey === propKey)!.name),
targetTable: {
database: targetTableDef.database ?? this.schema.database,
schema: targetTableDef.schema ?? this.schema.schema,
name: targetTableDef.name
},
targetPkColumns: targetPkNames
}
});
}
catch (err) {
throw new SdError(err, tableDef.name + " > " + fkDef.name + ": 오류");
}
}

@@ -321,0 +328,0 @@ }

@@ -428,4 +428,5 @@ import { DbContext } from "./DbContext";

const subFrom = clone.getSelectDef();
let unknownOrderBys;
if (subFrom.orderBy) {
const unknownOrderBys = subFrom.orderBy.filter(item => !Object.values(subFrom.select).includes(item[0]));
unknownOrderBys = subFrom.orderBy.filter(item => !Object.values(subFrom.select).includes(item[0]));
let seq = 0;

@@ -436,2 +437,3 @@ for (const unknownOrderBy of unknownOrderBys) {

}
delete subFrom.orderBy;
}

@@ -441,3 +443,14 @@

return new Queryable<D, T | R>(this.db, tableType, this._as, currEntity, { from: subFrom });
const result = new Queryable<D, T | R>(this.db, tableType, this._as, currEntity, { from: subFrom });
if (unknownOrderBys && unknownOrderBys.length > 0) {
result._def.orderBy = [];
let seq = 0;
for (const unknownOrderBy of unknownOrderBys) {
seq++;
result._def.orderBy.push(["__order_" + seq, unknownOrderBy[1]]);
}
}
return result;
}

@@ -808,3 +821,3 @@

const queryable = this.select(() => ({ cnt: new QueryUnit(Number, "COUNT(*)") }));
queryable._def.orderBy?.remove(item1 => item1[0] === "[__searchOrder]");
delete queryable._def.orderBy;
delete queryable._entity["__searchOrder"];

@@ -811,0 +824,0 @@ const item = await queryable.singleAsync();

@@ -60,2 +60,9 @@ import {

public isFalse<T extends TQueryValue>(source: TEntityValue<T>): TQueryBuilderValue[] {
return this.or([
this.isNull(source),
this.equal(source, false as any)
]);
}
public lessThen<T extends number | Number | DateOnly | DateTime | Time>(source: TEntityValue<T | undefined>, target: TEntityValue<T | undefined>): TQueryBuilderValue[] {

@@ -424,3 +431,3 @@ return [this.getQueryValue(source), " < ", this.getQueryValue(target)];

public case(predicate: TEntityValue<boolean | Boolean> | TQueryBuilderValue, then: TEntityValue<T>): CaseQueryHelper<T> {
this._type = SdOrmUtils.getQueryValueType(then);
this._type = SdOrmUtils.getQueryValueType(then) ?? this._type;

@@ -432,3 +439,3 @@ this._cases.push(...[" WHEN ", this._qh.getQueryValue(predicate), " THEN ", this._qh.getQueryValue(then)]);

public else(then: TEntityValue<T>): QueryUnit<T> {
this._type = SdOrmUtils.getQueryValueType(then);
this._type = SdOrmUtils.getQueryValueType(then) ?? this._type;
return new QueryUnit(this._type, ["CASE ", ...this._cases, " ELSE ", this._qh.getQueryValue(then), " END"]);

@@ -435,0 +442,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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