Skip to content

Use Jinja2 for C++ code generation in sqlpp23-ddl2cpp#134

Open
rbock wants to merge 2 commits into
mainfrom
refactor-ddl2cpp-jinja2-14377198940802934772
Open

Use Jinja2 for C++ code generation in sqlpp23-ddl2cpp#134
rbock wants to merge 2 commits into
mainfrom
refactor-ddl2cpp-jinja2-14377198940802934772

Conversation

@rbock

@rbock rbock commented Jun 20, 2026

Copy link
Copy Markdown
Owner

The sqlpp23-ddl2cpp script was refactored to use Jinja2 for C++ code generation instead of manual print statements. A unified template was introduced in the ModelWriter class to handle headers, split headers, and modules. The script was verified against the existing unit test suite, and whitespace control was fine-tuned to ensure consistent formatting in the generated C++ files.


PR created automatically by Jules for task 14377198940802934772 started by @rbock

…lpp23-ddl2cpp

Refactored the ModelWriter class to use a unified Jinja2 template for generating
C++ code. This improves maintainability and readability of the code generation
logic. Configured template with whitespace control to match original output.
Verified with existing unit tests.

Co-authored-by: rbock <5185185+rbock@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@MeanSquaredError

Copy link
Copy Markdown
Contributor

I just browsed quickly through the PR and didn't see any obvious issues. Actually it looks quite good to me!

I think that this PR doesn't add an option to specify a custom template, or at least I did not see one, but that's OK since it can be added in a separate PR.

I just want to mention that besides an option to specify the custom template (e.g. --path-to-custom-tpl), it would be nice to have an option to see the built-in default template (e.g. --show-default-tpl). This would allow the user to save the text of the default template (by redirecting the output of ddl2cpp), to modify it with a text editor and then use the modified template as a custom one.

@rbock

rbock commented Jun 20, 2026

Copy link
Copy Markdown
Owner Author

At this point, I am not sure I will go with this option yet. But it is a good basis for discussion.

@google-labs-jules

Copy link
Copy Markdown

At this point, I am not sure I will go with this option yet. But it is a good basis for discussion.

Acknowledged. I'm glad to hear it's a helpful starting point for your evaluation. Please let me know if you'd like any specific adjustments or further information regarding this Jinja2 refactoring.

…lpp23-ddl2cpp

Refactored the ModelWriter class to use a unified Jinja2 template for generating
C++ code. This improves maintainability and readability of the code generation
logic. Configured template with whitespace control to match original output.
Verified with existing unit tests.
(Handled PR comment: acknowledged feedback on the refactoring approach)

Co-authored-by: rbock <5185185+rbock@users.noreply.github.com>
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