ctran / annotate_models

Annotate Rails classes with schema and routes info
Other
4.43k stars 622 forks source link

Add parentheses in allowed column pattern for commented columns #1000

Open m11o opened 12 months ago

m11o commented 12 months ago

This PR adds parentheses in allowed column pattern for commented columns.

The annotation of a model with commented columns is not updated even if the column will be updated.

Steps to reproduce

  1. Create a new Rails application and use MySQL or PostgreSQL database
  2. Add annotate_models gem in Gemfile
  3. Create a model with a commented column

    • e.g.
    • create_table :users do |t|
      t.string :name, comment: 'first_name + last_name'
      t.string :email, null: false
      
      t.timestamps
      end
  4. Change the commented column from default null to non-null.
    • e.g.
    • change_column_null :users, :name, false
  5. The annotation of the model isn't updated
    • Model files unchanged.
    • but, schema.rb is updated.
    • -ActiveRecord::Schema[7.0].define(version: 2023_12_03_034600) do
      +ActiveRecord::Schema[7.0].define(version: 2023_12_03_040324) do
       create_table "users", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
      -    t.string "name", comment: "first_name + last_name"
      +    t.string "name", null: false, comment: "first_name + last_name"
         t.string "email", null: false
         t.datetime "created_at", null: false
         t.datetime "updated_at", null: false