barryvdh / laravel-ide-helper

IDE Helper for Laravel
MIT License
14.17k stars 1.16k forks source link

Capitalized column name 'NAME' leads to whereNAME($value) annotation, leads to n_a_m_e in SQL query #1356

Closed HenkPoley closed 7 months ago

HenkPoley commented 2 years ago

Versions:

Description:

Example schema

CREATE TABLE prefix_configuration
(
    ID         int UNSIGNED AUTO_INCREMENT
        PRIMARY KEY,
    SCOPE      varchar(255) NOT NULL,
    NAME       varchar(255) NOT NULL,
    VALUE      longtext     NOT NULL,
    created_at timestamp    NULL,
    updated_at timestamp    NULL
)
    COLLATE = utf8_unicode_ci;

CREATE INDEX scope
    ON prefix_configuration (SCOPE);

Then lead to the capitalized annotations:

/**
 * @method static Builder|Configuration whereNAME($value)
 * @method static Builder|Configuration whereSCOPE($value)
 */
class Configuration extends Model {}

When you use those in en Eloquent where() funtion:

Configuration::whereSCOPE('some scope')->whereNAME('some name')

Leads to SQL with s_c_o_p_e and n_a_m_e as supposed column names.

Proposed fix

Make lower case snake_case first, then to CapitalCase.

mfn commented 7 months ago

Leads to SQL with

But the SQL is generated by Laravel, not ide-helper.