We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
serialize
The rbs generated for an ActiveRecord model that uses serialize :some_field, Array does not generate the correct RBS for it. ex
serialize :some_field, Array
My situation is as follows:
schema.rb:
... create_table "foos", id: :serial, force: :cascade do |t| ... t.text "photos" ... end ...
foo.rb:
class Foo < ApplicationRecord serialize :photos, Array ...
it generates the following RBS in foo.rbs:
... def photos: () -> String? def photos=: (String?) -> String? def photos?: () -> bool def photos_changed?: () -> bool def photos_change: () -> [ String?, String? ] def photos_will_change!: () -> void def photos_was: () -> String? def photos_previously_changed?: () -> bool def photos_previous_change: () -> Array[String?]? def photos_previously_was: () -> String? def photos_before_last_save: () -> String? def photos_change_to_be_saved: () -> Array[String?]? def photos_in_database: () -> String? def saved_change_to_photos: () -> Array[String?]? def saved_change_to_photos?: () -> bool def will_save_change_to_photos?: () -> bool def restore_photos!: () -> void def clear_photos_change: () -> void ...
in this case, these should really be typed as Array[String]?, Array[Object]?, Array[untyped] or something similar...
Array[String]?
Array[Object]?
Array[untyped]
e.g.
def photos: () -> Array[String]? def photos=: (Array[String]?) -> Array[String]? def photos?: () -> bool def photos_changed?: () -> bool def photos_change: () -> [ Array[String]?, Array[String]? ] def photos_will_change!: () -> void def photos_was: () -> Array[String]? def photos_previously_changed?: () -> bool def photos_previous_change: () -> Array[Array[String]?]? def photos_previously_was: () -> Array[String]? def photos_before_last_save: () -> Array[String]? def photos_change_to_be_saved: () -> Array[Array[String]?]? def photos_in_database: () -> Array[String]? def saved_change_to_photos: () -> Array[Array[String]?]? def saved_change_to_photos?: () -> bool def will_save_change_to_photos?: () -> bool def restore_photos!: () -> void def clear_photos_change: () -> void
The text was updated successfully, but these errors were encountered:
Another similar case is when using Postgres array column, like this:
add_column :user, :photos, :string, array: true, default: []
generator produces String type signature, instead of Array[String].
Is there any way to manually override such cases, so that they would not be overwritten after running generators?
Sorry, something went wrong.
No branches or pull requests
The rbs generated for an ActiveRecord model that uses
serialize :some_field, Array
does not generate the correct RBS for it. exMy situation is as follows:
schema.rb:
foo.rb:
it generates the following RBS in foo.rbs:
in this case, these should really be typed as
Array[String]?
,Array[Object]?
,Array[untyped]
or something similar...e.g.
The text was updated successfully, but these errors were encountered: