GORM Playground Link

https://github.com/go-gorm/playground/pull/532

Description

When using Migrator.DropColumn, the table cannot be provided as a string. Providing it as a model works fine. I expect it to work even when the table is provided as a string.

As far as my shallow analysis can tell, the issue is caused by this: - In Migrator.RunWithValue, the Statement is setup with a nil Schema. The Schema is only set in the else block visited in case the value parameter is not a string. - DropColumn's callback provided to Migrator.RunWithValue uses stmt.Schema.LookUpField(name), which leads to a nil dereference in this case.

What I'm unsure about is how this should be fixed, hence no fixing PR. If you give me some pointers, I can give it a go, though. What I'm equally unsure about is whether this issue happens with other methods, too. If it does, they should all disappear at once if the fix is done within RunWithValue.

Comment From: a631807682

@pascallohrer RunWithValue support table name and model, but Schema is not required, we need to judge it before LookUpField, This problem also exists in other methods. PR Welcome.