Skip to content

Commit

Permalink
fix: not to make typeorm generate alter query on geometry column when…
Browse files Browse the repository at this point in the history
… that column was not changed (#5525)

* [Fix] loadTables function to properly get spatialFeatureType and srid of column

* [Fix] ColumnMetadata to handle options.srid when srid is zero

Co-authored-by: ojy6042 <48714272+ojy6042@users.noreply.github.com>
  • Loading branch information
ohjeyong and jeyong-dev committed Feb 17, 2020
1 parent d19dbc6 commit ee57557
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/driver/postgres/PostgresQueryRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,7 @@ export class PostgresQueryRunner extends BaseQueryRunner implements QueryRunner
"type"
FROM "geometry_columns"
) AS _
WHERE ${tablesCondition} AND "column_name" = '${tableColumn.name}'`;
WHERE (${tablesCondition}) AND "column_name" = '${tableColumn.name}' AND "table_name" = '${table.name}'`;

const results: ObjectLiteral[] = await this.query(geometryColumnSql);
tableColumn.spatialFeatureType = results[0].type;
Expand All @@ -1518,7 +1518,7 @@ export class PostgresQueryRunner extends BaseQueryRunner implements QueryRunner
"type"
FROM "geography_columns"
) AS _
WHERE ${tablesCondition} AND "column_name" = '${tableColumn.name}'`;
WHERE (${tablesCondition}) AND "column_name" = '${tableColumn.name}' AND "table_name" = '${table.name}'`;

const results: ObjectLiteral[] = await this.query(geographyColumnSql);
tableColumn.spatialFeatureType = results[0].type;
Expand Down
2 changes: 1 addition & 1 deletion src/metadata/ColumnMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ export class ColumnMetadata {
this.transformer = options.args.options.transformer;
if (options.args.options.spatialFeatureType)
this.spatialFeatureType = options.args.options.spatialFeatureType;
if (options.args.options.srid)
if (options.args.options.srid !== undefined)
this.srid = options.args.options.srid;
if (this.isTreeLevel)
this.type = options.connection.driver.mappedDataTypes.treeLevel;
Expand Down

0 comments on commit ee57557

Please sign in to comment.