-
Notifications
You must be signed in to change notification settings - Fork 18
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
Fixtures cannot be loaded #68
Comments
👋 @bquorning just seeing if there's any more info I can provide here. |
Thank you for the bug report and the repository with reproduction code @gjtorikian. That made the bug very easy to replicate for me 🙏🏼 Rails’ fixtures seem to depend on the column
The code you linked to is switching on this The only solution I could find was to change the Could you please check if #70 fixes the issue? |
Sadly, it. did not. 😦 Here's the stack trace from that branch:
Let me know how else I can help! I tried the branch out in the test case repo I created earlier, and it didn't work there either. |
Thanks for giving it a try.
That is strange. When I use Could you try again, and perhaps push up your changes to ulid-fixtures-bug if it’s still failing? |
Sure! I pushed my commit up; I'm also running the test using |
I run Can you share which error you get, plus stacktrace? |
Sure, here it is:
FWIW I will also try this branch in my actual (real) app and see if I can pinpoint what isn't working. Thank you for your help with all of this! |
I set up GitHub Actions on that test repo, and the tests failed in the same way I posted above: https://github.com/gjtorikian/ulid-fixtures-bug/actions/runs/8225587319/job/22490802305 I'm not sure why this would work on your machine, but at least I confirmed it's not mine! 😅 |
Ok, this is weird. I got the error once locally, but then I never saw it again. I will try to dig deeper into this over the coming days. |
I think I found it! I am not sure how, but it seems the directive diff --git a/db/schema.rb b/db/schema.rb
index ba62d9b..f090cca 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -14,7 +14,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_03_172229) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
- create_table "products", force: :cascade do |t|
+ create_table "products", id: :binary, force: :cascade do |t|
t.string "name"
t.text "description"
t.datetime "created_at", null: false |
Good news, your suggested change fixed my sample bug! But, I still can't seem to get that branch to work for my project. There must be something I am setting up incorrectly. I am reluctant to do so, but I'll close this issue out since I think the problem is on my end. Will report back if I find out what is going on. |
This is a fork of this earlier comment I made.
I finally found some time to set up a reproducible test case: https://github.com/gjtorikian/ulid-fixtures-bug
Run
bin/rails db:create && bin/rails db:migrate && bin/rails test
to see the issue:It seems that, for fixtures which are backed by ULID, the Rails test runner cannot find them.
In
ulid-rails < 2.0
, I was able to work around this with:To begin with, I think this is a Rails problem, but I am not entirely sure. Rails converts a fixture's YAML key name (
product_one
) into an integer (here). That integer does not exist in the DB, because we're using ULIDs. And, from what I remember, the ULID ID autogeneration inserts some randomness; so I rewrote the methods to allow for Rails to look up fixtures by their keyname turned into a ULID.If this is a Rails problem, their
identify
code should probably supportbytea
, just as they already supportuuid
. But I am not sure they will accept that solution, and so I think this lib should have a solution by default. What I cannot figure out is why no one else seems to have encountered this issue, and what I've done to trigger it.The text was updated successfully, but these errors were encountered: