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

GeneratedAttributeMethods is inconsistently included in the RBI files #1954

Open
adamk9k opened this issue Jul 11, 2024 · 2 comments
Open

GeneratedAttributeMethods is inconsistently included in the RBI files #1954

adamk9k opened this issue Jul 11, 2024 · 2 comments

Comments

@adamk9k
Copy link

adamk9k commented Jul 11, 2024

I’m running into a weird issue. We run tapioca dsl --verify on CI and recently it started to detect uncommitted changes and indeed when running tapioca dsl on the CI it does generate differently than it does on local. To give you an example, the model

class MyModel < ApplicationRecord
  self.primary_key = :id

  self.table_name = "my_table"
end

will generate the following rbi file on local (M1 machine)

class MyModel
  extend CommonRelationMethods
  extend GeneratedRelationMethods

and on CI, which runs on x86 linux I get

 class MyModel
+  include GeneratedAttributeMethods
   extend CommonRelationMethods
   extend GeneratedRelationMethods

Happens for multiple models that were not even modified recently. Tested both on tapioca (0.13.3) and the newest tapioca (0.15.1). We don’t have any compiler options.

CI is Github actions with ubuntu-latest is Ubuntu 24.04 TLS x86 architecture and on local I'm running on an M1 Macbook Air.

Besides the architecture, there is no difference between the two setups, environment variables and Tapioca config file is the same. Any ideas would be appreciated. Thanks!

@KaanOzkan
Copy link
Contributor

KaanOzkan commented Jul 12, 2024

Make sure that locally database is setup properly and my_table exists. We return early in the compiler if we can't get the table:

return unless constant.table_exists?

If the setup is correct I'd also make sure the table_name assignment is running upon application boot before we trigger the DSL compiler. If not the code would be looking at a my_model table instead of my_table.

@adamk9k
Copy link
Author

adamk9k commented Jul 15, 2024

Thanks, I have the verify step running after

  RAILS_ENV=test bundle exec rails db:drop
  RAILS_ENV=test bundle exec rails db:create
  RAILS_ENV=test bundle exec rails db:schema:load
  RAILS_ENV=test ./bin/tapioca dsl --verify

So the table should definitely be created.

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

2 participants