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

Dependency sorting not working with string keys #91

Open
yaychris opened this issue Nov 21, 2016 · 0 comments
Open

Dependency sorting not working with string keys #91

yaychris opened this issue Nov 21, 2016 · 0 comments

Comments

@yaychris
Copy link
Member

Given the following two seed files:

# photos.yml
records:
- sprig_id: 1
  name: 'Photo 1'
  site_id: "<%= sprig_record(Site, 'cooldev').id %>"

# sites.yml
records:
- sprig_id: 'cooldev'
  name: Cool Dev
  key: cooldev
  domain: cool.dev

if I run the following command:

sprig [
  Photo,
  Site
]

seeds do not work:

D, [2016-11-21T14:17:32.050772 #41433] DEBUG -- : Planting Photo with sprig_id 1
E, [2016-11-21T14:17:32.353571 #41433] ERROR -- : Record for class Site and sprig_id cooldev could not be found. (Substituted with NullRecord)
E, [2016-11-21T14:17:32.428034 #41433] ERROR -- : There was an error saving Photo with sprig_id 1.
E, [2016-11-21T14:17:32.428135 #41433] ERROR -- : #<Sprig::Seed::Record:0x007fe55888d958>
E, [2016-11-21T14:17:32.428259 #41433] ERROR -- : {:site=>["can't be blank"]}
D, [2016-11-21T14:17:32.428316 #41433] DEBUG -- : Planting Site with sprig_id cooldev
I, [2016-11-21T14:17:32.533419 #41433]  INFO -- : Saved
D, [2016-11-21T14:17:32.533508 #41433] DEBUG -- : Seeding complete.
I, [2016-11-21T14:17:32.533553 #41433]  INFO -- : 1 seed successfully planted.
E, [2016-11-21T14:17:32.533590 #41433] ERROR -- : 1 seed couldn't be planted:
E, [2016-11-21T14:17:32.533624 #41433] ERROR -- : #<Sprig::Seed::Record:0x007fe55888d958>
E, [2016-11-21T14:17:32.533669 #41433] ERROR -- : {:site=>["can't be blank"]}

If I switch the order to this:

sprig [
  Site,
  Photo
]

then the seeds work as expected. Also, if I change the site sprig_id to an integer, it works in either order.

My best guess is that the dependency sorter is not correctly sorting records with string keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant