propelorm / Propel2

Propel2 is an open-source high-performance Object-Relational Mapping (ORM) for modern PHP
http://propelorm.org/
MIT License
1.26k stars 398 forks source link

generated-classes are invalid when table columns contain spaces #1907

Open adjenks opened 2 years ago

adjenks commented 2 years ago

I generated a schema from my existing db and then built the model. In a file ending with "TableMap.php" there was a const defined like so:

    /**
     * the column name for the Street Name field
     */
    const COL_STREET NAME = 'myschema.mylocationtable.Street Name';

The gap between "COL_STREET" and "NAME" is invalid.

This column with a space was defined in many places in the file. Replacing "COL_STREET NAME" with "COL_STREET_NAME" in the file seemed to resolve it.

DarkAxi0m commented 2 years ago

I'm pretty sure what you want to do is, in the generated schmea, set tableMapName value,

http://propelorm.org/documentation/reference/schema.html#column-element

<column name="[Long Name]" tableMapName="Longname" phpName="Longname" type="VARCHAR" size="400"/>

edit: Just re-Read you issue, I agree the generator should do this.