-
Notifications
You must be signed in to change notification settings - Fork 25
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
Nested module models and unexpected annotations #106
Comments
@lparry thanks for reporting. I'll try and play around with this locally and see what's going on. I suspect the change in behavior is related to changes made for identifying the model annotations, done here #72 In short, I changed from using a regex to identify annotation comment block to using Ripper (Ruby file parser) to improve it. The additional indexes line seems interesting though. |
@lparry just checking - is the actual annotation formatted like that? I think there should be an empty comment line break after the index and I believe it should look like: # == Schema Information
#
# Table name: my_models
#
# id :bigint(8) not null, primary key
# name :string not null
#
# Indexes
#
# index_my_models_on_name (name) UNIQUE
#
module MyModule
# a long comment
# over a few lines
# more explanation
class MyModel < ApplicationModel
end
end I'm able to reproduce the issue using the annotation you have (with the missing comment line break) but I think that's not expected with this gem. |
For reference, I added a basic index to a dummy model and ran annotaterb and this is the result of the file: # frozen_string_literal: true
# == Schema Information
#
# Table name: test_defaults
#
# id :integer not null, primary key
# boolean :boolean default(FALSE)
# date :date default(Tue, 04 Jul 2023)
# datetime :datetime default(Tue, 04 Jul 2023 12:34:56.000000000 UTC +00:00)
# decimal :decimal(14, 2) default(43.21)
# float :float default(12.34)
# integer :integer default(99)
# string :string default("hello world!")
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_test_defaults_on_string (string)
#
class TestDefault < ApplicationRecord
end |
@lparry just checking in, was this able to be resolved on your side? |
@lparry I'm going to close this but feel free to re-open if the issue wasn't resolved. |
I have same issue. |
Hi, I'm seeing some odd behaviour for a model nested inside a name space with annotations previously generated by
annotate_models
eg, we have (roughly, excuse any errors anonymising stuff)
after running
annotaterb
I end up with a duplicate index + newline like this:removing the annotations and starting from scratch letting annotaterb pick where it thinks they belong, I end up with
with the annotations inserted midway through the comment, and with an outdent as above. Any pointers which config options might help here?
The text was updated successfully, but these errors were encountered: