Comparing version 0.1.10-alpha.0 to 0.1.10-alpha.1
@@ -6,2 +6,3 @@ const { Database } = require('../Database') | ||
connectDb = jest.fn() | ||
disconnectDb = jest.fn() | ||
queryDb = jest.fn() | ||
@@ -8,0 +9,0 @@ execDb = jest.fn() |
@@ -55,10 +55,13 @@ const camelCase = require('camelcase') | ||
parsed = Model.from(parsed) | ||
} else { | ||
throw new ValueError( | ||
`Value must be instance of "${getModelName( | ||
Model | ||
)}" or null, but "${parsed}" was given` | ||
) | ||
} | ||
throw new ValueError( | ||
`Value must be instance of "${getModelName( | ||
Model | ||
)}" or null, but "${parsed}" was given` | ||
) | ||
} | ||
inst[this.keyField] = parsed.pk | ||
if (parsed) { | ||
inst.set(this.keyField, parsed.pk) | ||
} | ||
return parsed | ||
@@ -65,0 +68,0 @@ } |
@@ -210,2 +210,10 @@ const { DatabaseModelBase } = require('./DatabaseModelBase') | ||
} | ||
static toString () { | ||
return getModelName(this) | ||
} | ||
toString () { | ||
return `${this.constructor}#${this.pk || JSON.stringify(this.toJson())}` | ||
} | ||
} | ||
@@ -212,0 +220,0 @@ |
@@ -7,4 +7,15 @@ const { ModelError } = require('../errors') | ||
const getModelName = model => | ||
model.meta && model.meta.modelName ? model.meta.modelName : model.name | ||
const getModelName = model => { | ||
const modelName = | ||
(model.meta && model.meta.modelName) || | ||
(typeof model.name === 'string' && model.name) | ||
if (!modelName) { | ||
throw new ModelError( | ||
`Following model has class name overriden: ${Object.getOwnPropertyNames( | ||
model | ||
)}. Perhaps you will need to define a Meta class with \`modelName\` in it.` | ||
) | ||
} | ||
return modelName | ||
} | ||
@@ -11,0 +22,0 @@ const getModels = () => models |
{ | ||
"name": "djorm", | ||
"version": "0.1.10-alpha.0", | ||
"version": "0.1.10-alpha.1", | ||
"description": "Django like ORM framework", | ||
@@ -39,3 +39,3 @@ "author": "Pavel Žák <pavel@zak.global>", | ||
}, | ||
"gitHead": "e3bc0f06ea74de2c501e5349187ea7787acef321" | ||
"gitHead": "ea20f264c199001c15b02b35f1129b42430f27c5" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71913
68
2526