-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug] false-positive success when using named export on seeder file #119
Comments
Hi! Sorry for late response. I think it could be better to detect the seeder by some kind or regexp or maybe by using file name. Feel free to dissent with me, open to more ideas |
To me, using |
I have no problem to use default export, but usually I try to avoid that. This link explain very well why. But what I said, I have no problem with this if we are consistent, but could be a breaking change for someone that is using non-default exports. @RaphaelWoude opinions here, pls π |
@jorgebodega got it. For now, you could add some note on README regarding this limitation. Something like: "Seeder files must not contain any other |
Yes, that could work temporary while we still work on this. I will keep this issue open to use it as a reference. Thanks for your help! |
I think we should just use the modern module syntax. I have had a ton of problems before with export default. The link you provided pretty much sums it up. |
For me, the best way to do this is by using non default export and use Lines 23 to 28 in 4136b0e
|
then this interface becomes abstract class Seeder {
abstract run(factory: any, connection: any): Promise<void>
} and now users should move |
For me mikro-orm seeding is a very good example on how to do this. But is unreleased yet. I'm pretty sure we should create a project and start working on next version, maybe a 2.x version, because there will be breaking changes for sure. |
cool! What if there are multiple seeder class exported? I don't know how Mikro ORM handle this. My suggestion is: to prevent misuages, |
Basically, when the seeder file has some
export const foo = 'bar'
-ish statement, therun
method is not invoked and the output is this:I think that typeorm-seeding CLI should ignore these statements regardless of whether it is right or not to have them in a seeder file.
I've notice that this behavior is due to
seedFileObject[keys[0]]
typeorm-seeding/src/importer.ts
Lines 3 to 7 in 4136b0e
because this will return the
foo
variable instead of the seeder class. I've thought thatreturn seedFileObject.default
was enough but @hirsch88 already use this in the past withrequire
(on 84df811)Maybe this should work but I'm not sure:
The text was updated successfully, but these errors were encountered: