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

Seedfu filtering of fixtures is not working correctly #118

Open
johnpaulh opened this issue Jan 2, 2017 · 2 comments
Open

Seedfu filtering of fixtures is not working correctly #118

johnpaulh opened this issue Jan 2, 2017 · 2 comments

Comments

@johnpaulh
Copy link

johnpaulh commented Jan 2, 2017

I am trying to filter out a fixture file using the filter option passed to the

SeedFu.seed(fixtures, filter)

passing regex eg: filter = /(?!001_file.rb)/

The regexp used inside seedfu runner is as given below(https://github.com/mbleigh/seed-fu/blob/master/lib/seed-fu/runner.rb)

filenames.find_all { |filename| filename =~ @filter }

So for my above condition the condition returns
"001_file.rb" =~ filter # returns 1

and for the rest of the files it return
"002_anotherfile.rb" =~ filter # 0

Ideally I would expect the find_all in the runner to return the filtered out filenames ie., leaving out "001_file.rb". But the find_all considers 1, 0 or any other value except nil as true and adds that file to the filenames list. Did anybody else faced this issue or am I missing something ??

@rubesMN
Copy link

rubesMN commented Jun 30, 2017

+1 for this. Spent half a day trying to get filters working and they pretty much dont work without a fix for this.

@mauro-ni
Copy link

mauro-ni commented Dec 22, 2017

An example:

Let's suppose to store seeds under APP_DIR/db/seeds/, then

Using the rake task:

bin/rails db:seed_fu FIXTURE_PATH=db/seeds FILTER=categories,tags

In the code:

SeedFu.seed(Rails.root.join('db', 'seeds'), /categories|tags/)

As you can see the way you pass arguments differs, it would be helpful to update the readme.

Many thanks for the great gem!

Mauro

discoursereviewbot referenced this issue in discourse/discourse Jun 17, 2020
This allows plugins to specify if they would like to filter out any seed
data files from running during migrations.
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

3 participants