The table name are empty in the generated SQL script when entities has doc comments
Closed this issue · 2 comments
Description:
$subject.
If there are doc comments for the entities defined in the model file like below,
# Represents a conference
#
# + id - The id of the conference
# + name - The name of the conference
public type Conference record {|
readonly string id;
string name;
|};
Generated SQL scripts are like below,
DROP TABLE IF EXISTS ``;
CREATE TABLE `` (
`id` VARCHAR(191) NOT NULL,
`name` VARCHAR(191) NOT NULL,
PRIMARY KEY(`id`)
);
The table name is empty
The issue identified is due to the doc comment being a valid MetadataNode
, and the program falsely assuming this metadata node must be the @sql:Name
annotation, and failing to extract the value
from the annotation. This will be fixed in the next patch release.
In the meantime there's a workaround as follows. It involves using the @sql:Name
annotation to annotate the entity with a custom name for it's resulting table.
# Represents a conference
#
# + id - The id of the conference
# + name - The name of the conference
@sql:Name {value:"Conference"}
public type Conference record {|
readonly string id;
string name;
|};
Please note that this may give you a compiler warning stating the mapped name and entity name is the same, hence making @sql:Name
annotation redundant. However, the client API will generate without any issues.
This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.
- Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
- Reason/Regression - The issue has introduced a regression.
- Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
- Reason/Complex - Issue occurred due to complex scenario.
- Reason/Invalid - Issue is invalid.
- Reason/Other - None of the above cases.