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

@spinajs/orm-sql

Package Overview
Dependencies
Maintainers
1
Versions
359
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spinajs/orm-sql - npm Package Compare versions

Comparing version 2.0.197 to 2.0.198

14

lib/cjs/converters.js

@@ -6,2 +6,3 @@ "use strict";

const luxon_1 = require("luxon");
const DATE_NUMERICAL_TYPES = ['int', 'integer', 'float', 'double', 'decimal', 'bigint', 'smallint', 'tinyint', 'mediumint'];
class SqlSetConverter {

@@ -33,8 +34,13 @@ toDB(value) {

toDB(value, _model, column) {
const numericalTypes = ['int', 'tinyint', 'smallint', 'mediumint', 'bigint', 'float', 'double', 'decimal'];
if (value === null) {
return null;
}
if (value === undefined) {
return '1970-01-01 00:00:00';
}
let dt = value instanceof luxon_1.DateTime ? value : luxon_1.DateTime.fromJSDate(value);
if (numericalTypes.includes(column.Type)) {
return dt?.toUnixInteger() ?? 0;
if (DATE_NUMERICAL_TYPES.includes(column.Type)) {
return dt.toUnixInteger() ?? 0;
}
return dt?.toSQL({ includeOffset: false }) ?? "1970-01-01 00:00:00";
return dt.toSQL({ includeOffset: false });
}

@@ -41,0 +47,0 @@ fromDB(value) {

@@ -28,9 +28,15 @@ "use strict";

execute(builder) {
const compiled = builder.toDB();
if (Array.isArray(compiled)) {
// TODO: rethink this cast
return Promise.all(compiled.map((c) => this.executeOnDb(c.expression, c.bindings, builder.QueryContext)));
try {
const compiled = builder.toDB();
if (Array.isArray(compiled)) {
// TODO: rethink this cast
return Promise.all(compiled.map((c) => this.executeOnDb(c.expression, c.bindings, builder.QueryContext)));
}
else {
return this.executeOnDb(compiled.expression, compiled.bindings, builder.QueryContext);
}
}
else {
return this.executeOnDb(compiled.expression, compiled.bindings, builder.QueryContext);
catch (err) {
this.Log.error(`Error during query execution: ${err.message}, ${err.stack}, model: ${builder.Model.name}, context: ${builder.QueryContext}`);
throw err;
}

@@ -37,0 +43,0 @@ }

import { DatetimeValueConverter } from '@spinajs/orm';
import { DateTime } from 'luxon';
const DATE_NUMERICAL_TYPES = ['int', 'integer', 'float', 'double', 'decimal', 'bigint', 'smallint', 'tinyint', 'mediumint'];
export class SqlSetConverter {

@@ -27,8 +28,13 @@ toDB(value) {

toDB(value, _model, column) {
const numericalTypes = ['int', 'tinyint', 'smallint', 'mediumint', 'bigint', 'float', 'double', 'decimal'];
if (value === null) {
return null;
}
if (value === undefined) {
return '1970-01-01 00:00:00';
}
let dt = value instanceof DateTime ? value : DateTime.fromJSDate(value);
if (numericalTypes.includes(column.Type)) {
return dt?.toUnixInteger() ?? 0;
if (DATE_NUMERICAL_TYPES.includes(column.Type)) {
return dt.toUnixInteger() ?? 0;
}
return dt?.toSQL({ includeOffset: false }) ?? "1970-01-01 00:00:00";
return dt.toSQL({ includeOffset: false });
}

@@ -35,0 +41,0 @@ fromDB(value) {

@@ -11,9 +11,15 @@ import { SqlDefaultValueBuilder } from './builders.js';

execute(builder) {
const compiled = builder.toDB();
if (Array.isArray(compiled)) {
// TODO: rethink this cast
return Promise.all(compiled.map((c) => this.executeOnDb(c.expression, c.bindings, builder.QueryContext)));
try {
const compiled = builder.toDB();
if (Array.isArray(compiled)) {
// TODO: rethink this cast
return Promise.all(compiled.map((c) => this.executeOnDb(c.expression, c.bindings, builder.QueryContext)));
}
else {
return this.executeOnDb(compiled.expression, compiled.bindings, builder.QueryContext);
}
}
else {
return this.executeOnDb(compiled.expression, compiled.bindings, builder.QueryContext);
catch (err) {
this.Log.error(`Error during query execution: ${err.message}, ${err.stack}, model: ${builder.Model.name}, context: ${builder.QueryContext}`);
throw err;
}

@@ -20,0 +26,0 @@ }

{
"name": "@spinajs/orm-sql",
"version": "2.0.197",
"version": "2.0.198",
"description": "framework orm sql language module",

@@ -55,5 +55,5 @@

"dependencies": {
"@spinajs/di": "^2.0.197",
"@spinajs/orm": "^2.0.197",
"@spinajs/exceptions": "^2.0.197",
"@spinajs/di": "^2.0.198",
"@spinajs/orm": "^2.0.198",
"@spinajs/exceptions": "^2.0.198",
"luxon": "^3.2.1",

@@ -60,0 +60,0 @@ "typescript-mix": "^3.1.3"

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

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