Comments (6)
thanks. added to Roadmap
from typeorm-fixtures.
fixed in 1.9.0 version
from typeorm-fixtures.
This fix breaks the behavior that I use in my code.
I've got user.entity
with the Exclude
decorator for passwords:
@Entity()
export class User {
@Column({
type: 'varchar',
length: 150,
update: false,
unique: true,
})
username: string;
@Exclude()
@Column()
password: string;
@BeforeInsert()
async hashPassword() {
this.password = await bcrypt.hash(this.password, 10);
}
}
And my fixture looks like this:
entity: User
parameters: {}
items:
user1:
username: '{{internet.userName}}'
password: 'test'
__call:
hashPassword:
user2:
username: '{{internet.userName}}'
password: 'test'
__call:
hashPassword:
Before the fix everything worked just fine. But now this.password
is undefinded
inside the hashPassword
, and it causes an error during the creation of fixtures.
Considering the fact that decorators are not ignored anymore, I removed the __call
params from my fixtures, but it doesn't work either.
@RobinCK Isn't it going to be a better solution to allow users to ignore decorators by some command-line option?
from typeorm-fixtures.
@aleksandryackovlev
Yes, you are right, I need to move this into the entity configuration
from typeorm-fixtures.
Hi, first of all, thank you for this lib.
Is it possible to do something like this, so everyone (inculded me) will be happy
in he yaml file
entity: User
ignoreDecorators: true
items:
user1:
username: foo
password: test
then add the key in jFixturesSchema.js
ignoreDecorators: Joi.boolean(),
add it to in Resolver.js
l15 for (const { entity, items, parameters, processor, resolvedFields, ignoreDecorators } of fixtureConfigs) {
l29 for (const name of referenceNames) {
const data = Object.assign({}, propertyList);
this.stack.push({
parameters: parameters || {},
processor,
entity: entity,
name: name,
resolvedFields,
data,
dependencies: this.resolveDependencies(name, data),
ignoreDecorators
});
and finaly in Builder.js
add method
function isIgnoreDecorators(fixture) {
return !!fixture.ignoreDecorators
}
then use it to configure the ignoreDecorators parameter
entity = class_transformer_1.plainToClassFromExist(entity, data, { ignoreDecorators: isIgnoreDecorators(fixture) });
This way it doesn't break anything and you can disable decorator for specific entities
@RobinCK I find this way more convenient than a cli option.
from typeorm-fixtures.
we are having the problem that they are not ignored - even though setting ignoreDecorators to true. It will not add any field to an object that has the @Exclude()
annotation on the class
from typeorm-fixtures.
Related Issues (20)
- [Bug] Lodash dependency pin
- [Bug] Postgres 'timestamptz' column failing at parsing long date HOT 4
- [Feature request] Add support for typeorm ^0.3.0 HOT 18
- [Bug] Update dependencies HOT 2
- [Bug] $current not working on array fields
- [Bug] class-validator entities may be incorrectly "unserialized/initialized" HOT 1
- [Bug] HOT 2
- [Bug] fix faker deprecation warning
- [Bug] Null ID when referencing another fixture HOT 1
- [Bug] glob is broken in Windows and cannot iterate by folder HOT 2
- [Feature request] Add support for regular expressions/glob patterns when setting fixtures location HOT 1
- [Bug]
- [Feature request] Add TsLoader for fixture
- Problem with @Exclude HOT 2
- [Feature request] Add faker examples with parameters in README
- [Feature request] Reference one field to generate another
- [Feature request] access to entity name in processor HOT 2
- [Feature request] Replace class-transformer usage with TypeORM Repository#merge
- [Bug] Limit faker version HOT 1
- [Feature request] Update `reflect-metadata` dependency to 0.2.2+
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typeorm-fixtures.