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

leoric

Package Overview
Dependencies
Maintainers
1
Versions
143
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 2.0.3 to 2.0.4

14

History.md

@@ -1,5 +0,15 @@

2.0.3 / 2021-02-11
2.0.4 / 2022-02-16
==================
## What's Changed
* fix: fix unit test error by @LB4027221 in https://github.com/cyjake/leoric/pull/269
* fix: attribute.defaultValue should be set when init attributes by @cyjake in https://github.com/cyjake/leoric/pull/271
**Full Changelog**: https://github.com/cyjake/leoric/compare/v2.0.3...v2.0.4
2.0.3 / 2022-02-11
==================
## What's Changed
* fix: default updatedAt to new date if model has no createdAt by @LB4027221 in https://github.com/cyjake/leoric/pull/268

@@ -12,3 +22,3 @@

2.0.2 / 2021-02-10
2.0.2 / 2022-02-10
==================

@@ -15,0 +25,0 @@

2

package.json
{
"name": "leoric",
"version": "2.0.3",
"version": "2.0.4",
"description": "JavaScript Object-relational mapping alchemy",

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

@@ -155,3 +155,2 @@ 'use strict';

/**

@@ -158,0 +157,0 @@ * Get or set attribute value by name. This method is quite similiar to `jQuery.attr()`. If the attribute isn't selected when queried from database, an error will be thrown when accessing it.

@@ -60,2 +60,7 @@ 'use strict';

if (dataType === 'timestamp without time zone') dataType = 'timestamp';
let columnDefault = row.column_default;
if (/^NULL::/i.test(columnDefault)) columnDefault = null;
if (dataType === 'boolean') columnDefault = columnDefault === 'true';
const primaryKey = row.constraint_type === 'PRIMARY KEY';

@@ -67,3 +72,3 @@ const precision = row.datetime_precision;

columnType: length > 0 ? `${dataType}(${length})` : dataType,
defaultValue: primaryKey ? null : row.column_default,
defaultValue: primaryKey ? null : columnDefault,
dataType,

@@ -70,0 +75,0 @@ allowNull: row.is_nullable !== 'NO',

@@ -78,4 +78,5 @@ 'use strict';

// eslint-disable-next-line no-unused-vars
function parseDefaultValue(text) {
function parseDefaultValue(text, type) {
if (typeof text !== 'string') return text;
if (type === 'boolean') return text === 'true';

@@ -88,3 +89,3 @@ try {

} catch (err) {
debug('[parseDefaultValue] [%s] %s', text, err.stack);
debug('[parseDefaultValue] [%s] %s', text, err);
}

@@ -116,6 +117,7 @@

const primaryKey = pk === 1;
const result = {
columnName: name,
columnType,
defaultValue: parseDefaultValue(dflt_value),
defaultValue: parseDefaultValue(dflt_value, type),
dataType: dataType,

@@ -122,0 +124,0 @@ allowNull: primaryKey ? false : notnull == 0,

@@ -52,5 +52,4 @@ 'use strict';

for (const columnInfo of columns) {
const { columnName, columnType, defaultValue, ...restInfo } = columnInfo;
const { columnName, columnType, ...restInfo } = columnInfo;
const name = columnName === '_id' ? columnName : camelCase(columnName);
// leave out defaultValue to let database take over the default
attributes[name] = {

@@ -57,0 +56,0 @@ ...restInfo,

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