Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We should add this change to fix the bug where null byte makes postgr… #10815

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions src/driver/postgres/PostgresDriver.ts
Expand Up @@ -1235,22 +1235,22 @@ export class PostgresDriver implements Driver {
if (!tableColumn) return false // we don't need new columns, we only need exist and changed

const isColumnChanged =
tableColumn.name !== columnMetadata.databaseName ||
tableColumn.name !== this.escapeNullBytes(columnMetadata.databaseName) ||
tableColumn.type !== this.normalizeType(columnMetadata) ||
tableColumn.length !== columnMetadata.length ||
tableColumn.isArray !== columnMetadata.isArray ||
tableColumn.precision !== columnMetadata.precision ||
(columnMetadata.scale !== undefined &&
tableColumn.scale !== columnMetadata.scale) ||
tableColumn.comment !==
this.escapeComment(columnMetadata.comment) ||
this.escapeNullBytes(columnMetadata.comment) ||
(!tableColumn.isGenerated &&
!this.defaultEqual(columnMetadata, tableColumn)) || // we included check for generated here, because generated columns already can have default values
tableColumn.isPrimary !== columnMetadata.isPrimary ||
tableColumn.isNullable !== columnMetadata.isNullable ||
tableColumn.isUnique !==
this.normalizeIsUnique(columnMetadata) ||
tableColumn.enumName !== columnMetadata.enumName ||
this.normalizeIsUnique(columnMetadata) ||
tableColumn.enumName !== this.escapeNullBytes(columnMetadata.enumName) ||
(tableColumn.enum &&
columnMetadata.enum &&
!OrmUtils.isArraysEqual(
Expand All @@ -1259,11 +1259,11 @@ export class PostgresDriver implements Driver {
)) || // enums in postgres are always strings
tableColumn.isGenerated !== columnMetadata.isGenerated ||
(tableColumn.spatialFeatureType || "").toLowerCase() !==
(columnMetadata.spatialFeatureType || "").toLowerCase() ||
(columnMetadata.spatialFeatureType || "").toLowerCase() ||
tableColumn.srid !== columnMetadata.srid ||
tableColumn.generatedType !== columnMetadata.generatedType ||
(tableColumn.asExpression || "").trim() !==
(columnMetadata.asExpression || "").trim()
(columnMetadata.asExpression || "").trim()

// DEBUG SECTION
// if (isColumnChanged) {
Expand Down Expand Up @@ -1608,13 +1608,13 @@ export class PostgresDriver implements Driver {
}

/**
* Escapes a given comment.
* Escapes a given string.
*/
protected escapeComment(comment?: string) {
if (!comment) return comment
protected escapeNullBytes(string?: string) {
if (!string) return string

comment = comment.replace(/\u0000/g, "") // Null bytes aren't allowed in comments
string = string.replace(/\u0000/g, "") // Null bytes aren't allowed in strings

return comment
return string
}
}