Skip to content

Conversation

MeanSquaredError
Copy link
Contributor

@MeanSquaredError MeanSquaredError commented Oct 8, 2025

This is the third PR that cleans up the ddl2cpp code. It provides the following changes:

  • Wraps all the global DDL parser variables into a separate class (DdlParser). This pretty much gets rid of all the global variables that were polluting the global namespace.
  • Cleans up the code that handles custom data types. The previous version seemed a bit hacky since it was modifying directly the global lists that contained the variable type names.
  • Replaces a for-loop with a list comprehension.
  • Clarifies the error message that is displayed when an unknown SQL data type is found in a DDL file. The previous error message stated:

Error: unsupported datatypes.
Possible solutions:
A) Implement this datatype (examples: sqlpp23/data_types)
B) Use the '{dataTypeFileArg}' command line argument to map the type to a known > type (example: README)
C) Extend/upgrade sqlpp23-ddl2cpp (edit types map)
D) Raise an issue on github

There we several problems with this:

  • Solution A (implementing the datatype in sqlpp23) or C (adding the data type in sqlpp23-ddl2cpp) would not work alone, because one needs to modify both sqlpp23 and sqlpp23-ddl2cpp for the new type to be recognized. So I've merged A and C into a single solution.
  • Solution B (mapping the unknown data type to a known one) would definitely work, so I made it the first proposed one.
  • Solution D (Raise an issue on github) will work so I left it as the last proposed one.

Also the message did not make a difference between an SQL data type and an sqlpp23 data type and in fact these are different data types, an SQL data type is just a keyword, recognized by the database, e.g. INT, while the sqlpp23 data type is a C++ structure, e.g. sqlpp23::integral. So I tried to differentiate these two terms to make it clear that both should be implemented.

In the end the proposed error message looks like:

Error: unsupported SQL data type(s).
Possible solutions:
A) Use the '--path-to-datatype-file' command line argument to map the SQL data type to a known sqlpp23 data type (example: README)
B) Implement this data type in sqlpp23 (examples: sqlpp23/data_types) and in sqlpp23-ddl2cpp
C) Raise an issue on github

I tested the PR creating a single header, split headers and a module, each of these with table creation helpers (--generate-table-creation-helper) and it seems to work correctly. Also tested DDL definitions with custom types and --path-to-datatype-file and this worked correctly too.

@rbock
Copy link
Owner

rbock commented Oct 10, 2025

Thanks for the continued cleanup!

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