Add support for custom types to ddl2cpp#110
Merged
rbock merged 10 commits intorbock:custom_typefrom Mar 29, 2026
Merged
Conversation
…ments of a type (cpp_type:<type>)
… add support for comments as dumped by pg_dump.
Owner
|
Thanks, this looks pretty cool already! Can you add some tests, too? MySQL dump with comment: DROP TABLE IF EXISTS `tab_foo`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tab_foo` (
`id` bigint NOT NULL AUTO_INCREMENT,
`text_nn_d` varchar(255) NOT NULL DEFAULT '',
`int_n` int DEFAULT NULL COMMENT 'cpp_type:test::my_int',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;sqlite3 does not seem to support column comments officially, see docs. But it seems to happily accept comments in the same way as MySQL above. |
…r .. is not supported.
Contributor
Author
|
I've updated the MR based on your comments. Also added a note about the sqlite backend. According to what I found on internet only inline comments are supported (and preserved when dumped). |
Owner
|
Nice! Thanks for the super swift implementation, the support for multiple options, and the clean documentation! |
rbock
pushed a commit
that referenced
this pull request
Mar 29, 2026
* Add support for special (custom) cpp types (using a csv file) * Add parsing support for custom types as annotation in the leading comments of a type (cpp_type:<type>) * When a cpp_type annotation exists dont emit an error SQL data type for .. is not supported. * Improve ddl2cpp documentation by adding c++ user-defined type support. * Add unit tests for the user-defined types.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See issue #106
Add three possible ways for mapping columns to user-defined types.
--path-to-cpp-types <csv>pg_dumpoutputI haven't checked where mysqldump or sqlite3 puts the comments. If you have an example of how that looks I can try to fix that too.
A somewhat unrelated change but it caused me a headache, add the possibility to strip the schema from the table (
pg_dumpincludes the schema in theCREATE TABLEstatement).And of course, updated the documentation.