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

djorm

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

djorm - npm Package Compare versions

Comparing version 0.1.13-alpha.7 to 0.1.14-alpha.0

db/QueryArray.js

7

db/Database.js

@@ -151,4 +151,11 @@ const { DatabaseMapper } = require('./DatabaseMapper')

}
parseValue (field, value) {
if (this.parser) {
return this.parser.parseValue(field, value)
}
return value
}
}
module.exports = { Database }

9

fields/CharField.js
const { TrivialField } = require('./TrivialField')
/** Field used for char values */
class CharField extends TrivialField {}
class CharField extends TrivialField {
parse (value, inst) {
if (value === null || value === undefined) {
return null
}
return String(value)
}
}
module.exports = { CharField }

4

fields/ForeignKey.js

@@ -31,3 +31,5 @@ const camelCase = require('camelcase')

}
this.foreignKeyField = new KeyFieldType()
this.foreignKeyField = new KeyFieldType({
null: this.null
})
this.expandedField = {

@@ -34,0 +36,0 @@ [this.keyField]: this.foreignKeyField

const { Field } = require('../models/AttrModel')
module.exports = {
...require('./ArrayField'),
...require('./BooleanField'),

@@ -5,0 +6,0 @@ ...require('./CharField'),

@@ -9,4 +9,3 @@ const { FieldValidationError } = require('../errors')

validateValue (inst, fieldName) {
const value = inst.get(fieldName)
validateValue (value, inst, fieldName) {
if (

@@ -23,3 +22,3 @@ typeof value !== 'undefined' &&

}
return super.validateValue(inst, fieldName)
return super.validateValue(value, inst, fieldName)
}

@@ -26,0 +25,0 @@ }

@@ -8,4 +8,3 @@ const { CharField } = require('./CharField')

class UrlField extends CharField {
validateValue (inst, fieldName) {
const value = inst.get(fieldName)
validateValue (value, inst, fieldName) {
if (value) {

@@ -18,3 +17,3 @@ try {

}
return super.validateValue(inst, fieldName)
return super.validateValue(value, inst, fieldName)
}

@@ -21,0 +20,0 @@ }

@@ -1,3 +0,3 @@

const { FieldError, UnknownField } = require('../errors')
const { concatValidators, filterUnique } = require('../filters')
const { FieldError, FieldValidationError, UnknownField } = require('../errors')
const { getModelName, registerModel } = require('./ModelRegistry')

@@ -148,6 +148,4 @@

const validator = concatValidators(
...this.constructor.fieldObjects.map(
([fieldName, field]) => async inst => {
return await field.validateValue(inst, fieldName)
}
...this.constructor.fieldObjects.map(([fieldName, field]) => async inst =>
await field.validateValue(inst.get(fieldName), inst, fieldName)
)

@@ -172,8 +170,4 @@ )

class Field extends GenericField {
static default = new Field()
static private = new Field({ default: false })
static secret = new Field()
static validator = new Field()
static null = new Field({ default: false })
class FieldBase extends GenericField {
static default = new FieldBase()

@@ -221,3 +215,10 @@ /** Based on Robustness principle, fields will accept various representations

}
}
class Field extends FieldBase {
static null = new FieldBase({ default: false })
static private = new FieldBase({ default: false })
static secret = new FieldBase()
static validator = new FieldBase()
/** Given this field has a validator, try to run it as a callback. Callback

@@ -227,6 +228,13 @@ * will receive field value, the model instance, and field name as

*/
async validateValue (inst, fieldName) {
return this.validator
? await this.validator(inst.get(fieldName), inst, fieldName)
: null
async validateValue (value, inst, fieldName) {
if (!this.null && value === null) {
throw new FieldValidationError(
inst,
fieldName,
`Passed \`null\` to non-null field ${getModelName(
inst.constructor
)}.${fieldName}`
)
}
return this.validator ? await this.validator(value, inst, fieldName) : null
}

@@ -233,0 +241,0 @@ }

@@ -92,3 +92,6 @@ const { DatabaseModelBase } = require('./DatabaseModelBase')

try {
this[fieldName] = field.fromDb(value, this)
this[fieldName] = field.fromDb(
this.constructor.db.parseValue(field, value),
this
)
} catch (e) {

@@ -95,0 +98,0 @@ if (e instanceof FieldError) {

{
"name": "djorm",
"version": "0.1.13-alpha.7",
"version": "0.1.14-alpha.0",
"description": "Django like ORM framework",

@@ -39,3 +39,3 @@ "author": "Pavel Žák <pavel@zak.global>",

},
"gitHead": "9f4ef18813a98429678fa22e14a244e86d664b89"
"gitHead": "882b72cd289b8b4078e09b9e282775f5f62c0e3d"
}
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