Skip to content

Fix: change auto-generated model fields prefix to suffix to avoid macros collisions#2540

Open
afanofrafa wants to merge 1 commit into
drogonframework:masterfrom
afanofrafa:fix-model-field
Open

Fix: change auto-generated model fields prefix to suffix to avoid macros collisions#2540
afanofrafa wants to merge 1 commit into
drogonframework:masterfrom
afanofrafa:fix-model-field

Conversation

@afanofrafa

Copy link
Copy Markdown

Description of the problem I faced during the developing

Currently, drogon_ctl generates model field constants in the Cols struct with a leading underscore (e.g., _id, _name). This causes compilation issues on Windows (especially with MSVC) due to collisions with system macros and standard library reserved identifiers.

This PR moves the underscore to the end of the variable name (e.g., id_, name_) in the generated templates to follow standard C++ naming conventions and avoid these collisions.

Changes made

  • Updated drogon_ctl/templates/model_h.csp and drogon_ctl/templates/model_cc.csp templates.
  • Changed the generated field names in the Cols struct from _fieldName to fieldName_.

Note: This is a breaking change for existing user code that directly uses ModelName::Cols::_fieldName in their ORM queries, but it is necessary for cross-platform compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants