Skip to content

Commit 95caf9c

Browse files
committed
fix: set useDefaultIdType while discovering models
Signed-off-by: Muhammad Aaqil <aaqilcs102@gmail.com>
1 parent 1d605f9 commit 95caf9c

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

lib/datasource.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1733,7 +1733,15 @@ DataSource.prototype.discoverSchemas = function(tableName, options, cb) {
17331733
if (uniqueKeys.includes(propName)) {
17341734
schema.properties[propName]['index'] = {unique: true};
17351735
}
1736-
const dbSpecific = {
1736+
// set useDefaultIdType: false in the case of id property with generated: 1 and has string type
1737+
if (
1738+
schema.properties[propName]['id'] &&
1739+
schema.properties[propName]['generated'] &&
1740+
schema.properties[propName]['type'].toLowerCase() === 'string'
1741+
) {
1742+
schema.properties[propName]['useDefaultIdType'] = false;
1743+
}
1744+
const dbSpecific = schema.properties[propName][dbType] = {
17371745
columnName: item.columnName,
17381746
dataType: item.dataType,
17391747
dataLength: item.dataLength,

0 commit comments

Comments
 (0)