Skip to content

Fix foreign key issue with Rails 6 and Sqlite3 #695

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

Merged
merged 1 commit into from
Dec 2, 2019

Conversation

shime
Copy link
Contributor

@shime shime commented Nov 23, 2019

Rails 6 has dropped name from options for ActiveRecord::ConnectionAdapters::ForeignKeyDefinition
for Sqlite3 adapter:

https://github.com/rails/rails/blob/f2df77709f7e536aaf4d6f984ff21a49d44d34c1/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb#L305-L311

This has caused issues with getting foreign key info and blowing up
when trying to annotate models with foreign keys. This commit
adds one additional check for name presence and uses column
attribute from options instead.

Closes #620.

Rails 6 has dropped name from ActiveRecord::ConnectionAdapters::ForeignKeyDefinition
for Sqlite3 adapter:

https://github.com/rails/rails/blob/f2df77709f7e536aaf4d6f984ff21a49d44d34c1/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb\#L305-L311

This has caused issues with getting foreign key info and blowing up
when trying to annotate models with foreign keys. This commit
adds one additional check for name presence and uses column
attribute from options instead.

Closes ctran#620.
@drwl
Copy link
Collaborator

drwl commented Dec 2, 2019

@shime thanks for the patch. It looks good to me. Just for my understanding, can you elaborate more on the code you linked to?

v5.2 looks to have the same code
https://github.com/rails/rails/blob/5-2-stable/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb#L356

@drwl drwl merged commit d84c526 into ctran:develop Dec 2, 2019
peterfication pushed a commit to store2be/annotate_models that referenced this pull request Jan 20, 2020
Rails 6 has dropped name from ActiveRecord::ConnectionAdapters::ForeignKeyDefinition
for Sqlite3 adapter:

https://github.com/rails/rails/blob/f2df77709f7e536aaf4d6f984ff21a49d44d34c1/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb\#L305-L311

This has caused issues with getting foreign key info and blowing up
when trying to annotate models with foreign keys. This commit
adds one additional check for name presence and uses column
attribute from options instead.

Closes ctran#620.
vfonic pushed a commit to vfonic/annotate_models that referenced this pull request May 8, 2020
Rails 6 has dropped name from ActiveRecord::ConnectionAdapters::ForeignKeyDefinition
for Sqlite3 adapter:

https://github.com/rails/rails/blob/f2df77709f7e536aaf4d6f984ff21a49d44d34c1/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb\#L305-L311

This has caused issues with getting foreign key info and blowing up
when trying to annotate models with foreign keys. This commit
adds one additional check for name presence and uses column
attribute from options instead.

Closes ctran#620.
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

Successfully merging this pull request may close these issues.

undefined method `gsub' for nil:NilClass
2 participants