annotate_models icon indicating copy to clipboard operation
annotate_models copied to clipboard

Add parentheses in allowed column pattern for commented columns

Open m11o opened this issue 2 years ago • 0 comments

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
      

m11o avatar Dec 03 '23 03:12 m11o