Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions forward_engineering/configs/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,7 @@ module.exports = {
TABLE: {
mode: 'table',
},
JSON: {
format: 'semi-structured',
},
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"2016",
"2017",
"2019",
"2022"
"2022",
"2025"
]
},
"features": {
Expand Down
37 changes: 13 additions & 24 deletions polyglot/adapter.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@
"from": { "childType": "timestamp_ntz" },
"to": { "mode": "datetime2", "childType": "datetime" }
},
/**
* It is a bit tricky adapter. Here we rely on the type detection priority of application. Keyword "mode" has higher
* priority, so it will be used first and when available (in SQL Server 2025 and higher) it will be used. When not available
* it will try to use "childType" and convert the type to "varchar" which is available in all version of SQL Server.
*/
{
"from": { "type": "json" },
"to": {
"hasMaxLength": true,
"childType": "varchar",
"mode": "json"
}
},
["convertLengthToHasMaxLength", 8001],
[
"renameBlockItemProperties",
Expand All @@ -108,29 +121,5 @@
}
]
]
},
"postConvert": {
"modify": {
"field": [
{
"from": {
"type": "jsonObject"
},
"to": {
"hasMaxLength": true,
"mode": "varchar"
}
},
{
"from": {
"type": "jsonArray"
},
"to": {
"hasMaxLength": true,
"mode": "varchar"
}
}
]
}
}
}
84 changes: 84 additions & 0 deletions properties_pane/field_level/fieldLevelConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5123,6 +5123,90 @@ making sure that you maintain a proper JSON format.
"propertyType": "details",
"template": "textarea"
}
],
"json": [
"name",
"code",
"schemaId",
"type",
{
"propertyName": "JSON Type",
"propertyKeyword": "physicalType",
"propertyType": "select",
"hidden": true
},
{
"propertyName": "JSON Types",
"propertyKeyword": "subtype",
"propertyType": "select",
"options": [
{
"name": "object",
"value": "object"
},
{
"name": "array",
"value": "array"
}
],
"defaultValue": "object"
},
{
"propertyName": "Min Properties",
"propertyKeyword": "minProperties",
"propertyType": "numeric",
"dependency": {
"key": "subtype",
"value": "object"
}
},
{
"propertyName": "Max Properties",
"propertyKeyword": "maxProperties",
"propertyType": "numeric",
"dependency": {
"key": "subtype",
"value": "object"
}
},
{
"propertyName": "Default",
"propertyKeyword": "default",
"propertyType": "text"
},
{
"propertyName": "Default constraint name",
"propertyKeyword": "defaultConstraintName",
"propertyType": "text"
},
{
"propertyName": "Comments",
"propertyKeyword": "description",
"propertyTooltip": "comments",
"addTimestampButton": false,
"propertyType": "details",
"template": "textarea"
},
{
"propertyName": "Not null",
"propertyKeyword": "required",
"enableForReference": true,
"propertyType": "checkbox",
"defaultValue": false
},
"foreignCollection",
"foreignField",
"relationshipType",
"sample",
{
"propertyName": "Remarks",
"propertyKeyword": "comments",
"shouldValidate": false,
"propertyTooltip": "remarks",
"addTimestampButton": true,
"propertyType": "details",
"template": "textarea"
}
]
}
}
2 changes: 1 addition & 1 deletion properties_pane/model_level/modelLevelConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ making sure that you maintain a proper JSON format.
"shouldValidate": false,
"propertyTooltip": "DB version",
"propertyType": "select",
"options": ["2008", "2012", "2014", "2016", "2017", "2019", "2022"],
"options": ["2008", "2012", "2014", "2016", "2017", "2019", "2022", "2025"],
"disabledOption": false
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
const containsJson = ({ tableInfo }) =>
tableInfo.some(item => {
if (item['DATA_TYPE'] === 'json') {
return true;
}

if (item['DATA_TYPE'] !== 'nvarchar') {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const defineType = value => {
};

const handleField = (name, properties, cellValue) => {
if (!cellValue || properties.mode !== 'nvarchar') {
if (!cellValue || (properties.mode !== 'nvarchar' && properties.type !== 'json')) {
return { [name]: properties };
}

Expand Down Expand Up @@ -68,7 +68,7 @@ const defineJSONTypes = row => jsonSchema => {
};

const getColumnValue = (firstRow, fieldName, fieldProperties, rows) => {
if (!['varchar', 'nvarchar'].includes(fieldProperties.mode)) {
if (!['varchar', 'nvarchar', 'json'].includes(fieldProperties.mode)) {
return firstRow[fieldName];
}
const complexValueRow = rows.find(row => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const handleType = type => {
case 'xml':
case 'cursor':
case 'rowversion':
return { type };
case 'json':
default:
return { type };
}
Expand Down
69 changes: 69 additions & 0 deletions types/json.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"name": "json",
"erdAbbreviation": "<json>",
"dtdAbbreviation": "{...}",
"parentType": "jsonObject",
"hiddenOnEntity": "view",
"jsonType": {
"order": 2,
"name": "json",
"jsonRoot": true
},
"defaultValues": {
"primaryKey": false,
"additionalProperties": false,
"mode": "json",
"subtype": "object",
"properties": []
},
"subtypes": {
"object": {
"parentType": "jsonObject",
"childValueType": ["jsonString", "jsonNumber", "jsonObject", "jsonArray", "jsonBoolean", "jsonNull"]
},
"array": {
"parentType": "jsonArray",
"childValueType": ["jsonString", "jsonNumber", "jsonObject", "jsonArray", "jsonBoolean", "jsonNull"]
}
},
"dependency": {
"type": "not",
"values": [
{
"level": "model",
"key": "dbVersion",
"value": "2008"
},
{
"level": "model",
"key": "dbVersion",
"value": "2012"
},
{
"level": "model",
"key": "dbVersion",
"value": "2014"
},
{
"level": "model",
"key": "dbVersion",
"value": "2016"
},
{
"level": "model",
"key": "dbVersion",
"value": "2017"
},
{
"level": "model",
"key": "dbVersion",
"value": "2019"
},
{
"level": "model",
"key": "dbVersion",
"value": "2022"
}
]
}
}
3 changes: 2 additions & 1 deletion types/object.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"table",
"reference",
"multiple",
"object"
"object",
"json"
]
}
}
Expand Down