Skip to content

Commit 693994c

Browse files
Implement FE of Postgis types
1 parent af32710 commit 693994c

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

forward_engineering/ddlProvider.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,8 @@ module.exports = (baseProvider, options, app) => {
470470
schemaName: schemaData.schemaName,
471471
underlyingType: jsonSchema.underlyingType,
472472
checkConstraints: jsonSchema.checkConstraints,
473+
typeModifier: jsonSchema.typeModifier,
474+
srid: jsonSchema.srid,
473475
collationRule,
474476
timePrecision,
475477
timezone,

forward_engineering/helpers/columnDefinitionHelper.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,19 @@ module.exports = ({
3535
return type;
3636
};
3737

38+
const addTypeModifier = ({ type, typeModifier, srid }) => {
39+
const typeSrid = srid ? `, ${srid}` : ``;
40+
if (typeModifier && typeModifier !== "") {
41+
return `${type}(${typeModifier}${typeSrid})`
42+
}
43+
return type;
44+
}
45+
3846
const canHaveLength = type => ['char', 'varchar', 'bit', 'varbit'].includes(type);
3947
const canHavePrecision = type => type === 'numeric';
4048
const canHaveTimePrecision = type => ['time', 'timestamp'].includes(type);
4149
const canHaveScale = type => type === 'numeric';
50+
const canHaveTypeModifier = type => ['geography', 'geometry'].includes(type);
4251

4352
const decorateType = (type, columnDefinition) => {
4453
if (canHaveLength(type) && _.isNumber(columnDefinition.length)) {
@@ -47,6 +56,12 @@ module.exports = ({
4756
return addScalePrecision(type, columnDefinition.precision, columnDefinition.scale);
4857
} else if (canHavePrecision(type) && _.isNumber(columnDefinition.precision)) {
4958
return addPrecision(type, columnDefinition.precision);
59+
} else if (canHaveTypeModifier(type)) {
60+
return addTypeModifier({
61+
type,
62+
typeModifier: columnDefinition.typeModifier,
63+
srid: columnDefinition.srid
64+
});
5065
} else if (
5166
canHaveTimePrecision(type) &&
5267
(_.isNumber(columnDefinition.timePrecision) || columnDefinition.timezone)

properties_pane/field_level/fieldLevelConfig.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2236,6 +2236,42 @@ making sure that you maintain a proper JSON format.
22362236
"data": "options",
22372237
"valueType": "string"
22382238
},
2239+
{
2240+
"propertyName": "Type modifier",
2241+
"propertyKeyword": "typeModifier",
2242+
"propertyType": "text",
2243+
"dependency": {
2244+
"type": "or",
2245+
"values": [
2246+
{
2247+
"key": "mode",
2248+
"value": "geometry"
2249+
},
2250+
{
2251+
"key": "mode",
2252+
"value": "geography"
2253+
}
2254+
]
2255+
}
2256+
},
2257+
{
2258+
"propertyName": "SRID",
2259+
"propertyKeyword": "srid",
2260+
"propertyType": "text",
2261+
"dependency": {
2262+
"type": "or",
2263+
"values": [
2264+
{
2265+
"key": "mode",
2266+
"value": "geometry"
2267+
},
2268+
{
2269+
"key": "mode",
2270+
"value": "geography"
2271+
}
2272+
]
2273+
}
2274+
},
22392275
{
22402276
"propertyName": "Comments",
22412277
"propertyKeyword": "description",

0 commit comments

Comments
 (0)