Skip to content
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

Cannot seed Astro DB when seed file is under srcDir #10712

Closed
1 task
kidonng opened this issue Apr 7, 2024 · 0 comments · Fixed by #10720
Closed
1 task

Cannot seed Astro DB when seed file is under srcDir #10712

kidonng opened this issue Apr 7, 2024 · 0 comments · Fixed by #10720
Assignees
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) pkg: db

Comments

@kidonng
Copy link
Contributor

kidonng commented Apr 7, 2024

Astro Info

Astro                    v4.5.16
Node                     v18.18.0
System                   Linux (x64)
Package Manager          unknown
Output                   static
Adapter                  none
Integrations             astro:db
                         @astrojs/db/file-url

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

I prefer to set srcDir: '.' to avoid an extra directory level. However, when using Astro DB, seeding will fail with the following error:

00:13:11 [ERROR] [astro:db] Cannot read properties of undefined (reading 'Symbol(drizzle:Columns)')

As mentioned in #10458 (comment), if I unset srcDir and move the seed file (seed.ts, along with the entire db folder) outside of src, seeding will succeed.

I digged in the code and found if I change it to return resolved.virtual even if the seed file is inside srcDir, the seeding will succeed as well, without "recursive seed calls" as mentioned in the comments. This may have unexpected consequences though since I'm not familiar with the internals.

if (importer.id.startsWith(srcDirPath)) {
// Seed only if the importer is in the src directory.
// Otherwise, we may get recursive seed calls (ex. import from db/seed.ts).
return resolved.seedVirtual;
}
return resolved.virtual;

What's the expected result?

Seeding should success whether the seed file is under srcDir or not.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-tx22uf

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Apr 7, 2024
@matthewp matthewp self-assigned this Apr 8, 2024
@matthewp matthewp added - P3: minor bug An edge case that only affects very specific usage (priority) and removed needs triage Issue needs to be triaged labels Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) pkg: db
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants