-
Notifications
You must be signed in to change notification settings - Fork 59
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
Refactor Talk indexing into a Talk::Index record. #540
base: main
Are you sure you want to change the base?
Conversation
This does take some extra work since Active Record can't detect `rowid` is the primary key. But with some awareness around that, it's pretty smooth sailing and we can entirely remove a lot of the custom SQL with standard Active Record.
end | ||
|
||
after_create_commit :create_in_index | ||
after_update_commit :update_in_index | ||
after_destroy_commit :remove_from_index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We get this for free now via dependent: :destroy
!
I don't get what's going on in the tests. In development the query looks correct and finds the talk:
But in tests the query looks different and doesn't find the talk:
The Swapping to |
Ok, if I put
But it still doesn't find the book. |
Ah, something seems to be up when we try to insert the record, hm. It's missing the rowid here.
|
Ok, wow, maybe this is more trouble than it's worth. We have to drop back into raw SQL to get Active Record to put in the |
I like how it all feels really ActiveRecord. |
I'm hoping to get back to this, because I'd like to wrap it up. |
This does take some extra work since Active Record can't detect
rowid
is the primary key.But with some awareness around that, it's pretty smooth sailing and we can entirely remove a lot of the custom SQL with standard Active Record.