Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Side effects with pg_search gem #7

Open
alexanderadam opened this issue Aug 5, 2014 · 4 comments
Open

Side effects with pg_search gem #7

alexanderadam opened this issue Aug 5, 2014 · 4 comments

Comments

@alexanderadam
Copy link

When using the gem pg_search spring-reap will fail with

ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "pg_search_documents" does not exist
LINE 1: SELECT "pg_search_documents".* FROM "pg_search_documents"
                                            ^
: SELECT "pg_search_documents".* FROM "pg_search_documents"
-e:1:in `<main>'
Tasks: TOP => db:seed:reap

So, in general it would be nice if standard errors would be skipped and in summary will be shown what couldn't be serialized.

Spring creates the pg_search_documents.yml although the exception was thrown so it would be also useful if the empty file wouldn't be created or at least removed if it is empty.

Thank you for your work! 👍

@h0tl33t
Copy link
Contributor

h0tl33t commented Aug 5, 2014

Looks like the pg_search gem creates a PgSearch::Document model and an underlying migration for the pg_search_documents table, so it seems as if sprig-reap picked up on the correct table name.

If I'm understanding correctly, this particular error isn't due to sprig-reap but perhaps a missing table (migration needed to be run). However, the main takeaway is that sprig-reap shouldn't completely bail out on an error, but rather output some meaningful logging and attempt to continue. I think that's a good thing to do!

@h0tl33t h0tl33t mentioned this issue Aug 6, 2014
@alexanderadam
Copy link
Author

We tried it and it worked but with the current implementation there is no way to see what the error was.
Additionally reap will skip the dump for all the following records.
So if the first record fails, the following records won't be dumped neither.

@h0tl33t
Copy link
Contributor

h0tl33t commented Aug 21, 2014

I'll look into outputting the errors and just skipping single records when there are errors rather than all subsequent records for a given model.

@h0tl33t
Copy link
Contributor

h0tl33t commented Sep 12, 2014

I made a change to output the rescued errors, so that addresses at least part of your feedback.

To your other comment, I don't see a way for record-level operations to fail at this point. Sprig-reap will only do two things at the model-level:

  1. Either pull all the records from the database, or..
  2. Throw an error (most likely due to an inability to infer the correct database table name)

Once they're fetched from the database, it's not obvious to me what might throw an error. If you've experienced what you believe is an error due to a specific record, could you leave a comment with the error so I can investigate?

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

No branches or pull requests

2 participants