Skip to content

Commit

Permalink
fix: descriptions longer than 255 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
josemariaeliasMM committed Dec 19, 2023
1 parent 1297c21 commit 008b7bf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions migrations/20231219181201_change_description_text.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALTER TABLE `type_def_types` MODIFY `description` TEXT;
ALTER TABLE `type_def_fields` MODIFY `description` TEXT;
ALTER TABLE `type_def_operations` MODIFY `description` TEXT;
ALTER TABLE `type_def_operation_parameters` MODIFY `description` TEXT;
1 change: 1 addition & 0 deletions src/controller/breakdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class BreakDownSchemaCaseUse implements BreakDownService {
return;
} catch (err) {
logger.error('Error breaking down the schema', err.message ?? err);
throw err;
}
}
}
16 changes: 13 additions & 3 deletions src/database/schemaBreakdown/breakdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export class BreakDownRepository<T, K> {
if (data.length === 0) {
return;
}

return trx.raw(`INSERT INTO ${this.tableName} (${this.columns.join(
','
)})
Expand Down Expand Up @@ -50,9 +51,18 @@ export class BreakDownRepository<T, K> {
const fields = columns.map((column) => {
const value = i[column];
if (value === undefined) return 'null';
else if (typeof value === 'string')
return `'${value.replace(/'/g, "\\'")}'`;
else return value;
else if (typeof value === 'string') {
let sanitized = value;
if (value.endsWith('\\')) {
sanitized = `${value} `;
}

const trailingSlashesSanitized = sanitized.replace(
/'/g,
"\\'"
);
return `'${trailingSlashesSanitized}'`;
} else return value;
});
return `(${fields.join(',')})`;
});
Expand Down

0 comments on commit 008b7bf

Please sign in to comment.