Skip to content

Commit

Permalink
style: Apply formatting (typeorm#11175)
Browse files Browse the repository at this point in the history
  • Loading branch information
OSA413 authored Dec 11, 2024
1 parent 5c2330a commit b535cbd
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 25 deletions.
20 changes: 16 additions & 4 deletions src/driver/postgres/PostgresQueryRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,10 +601,22 @@ export class PostgresQueryRunner
downQueries.push(this.dropIndexSql(table, index))
})
}

if (table.comment) {
upQueries.push(new Query("COMMENT ON TABLE " + this.escapePath(table) + " IS '" + table.comment + "'"));
downQueries.push(new Query("COMMENT ON TABLE " + this.escapePath(table) + " IS NULL"));
upQueries.push(
new Query(
"COMMENT ON TABLE " +
this.escapePath(table) +
" IS '" +
table.comment +
"'",
),
)
downQueries.push(
new Query(
"COMMENT ON TABLE " + this.escapePath(table) + " IS NULL",
),
)
}

await this.executeQueries(upQueries, downQueries)
Expand Down Expand Up @@ -4744,7 +4756,7 @@ export class PostgresQueryRunner

newComment = this.escapeComment(newComment)
const comment = this.escapeComment(table.comment)

if (newComment === comment) {
return
}
Expand Down
6 changes: 2 additions & 4 deletions src/query-builder/InsertQueryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,8 @@ export class InsertQueryBuilder<
// add VALUES expression
if (valuesExpression) {
if (
(
this.connection.driver.options.type === "oracle" ||
this.connection.driver.options.type === "sap"
) &&
(this.connection.driver.options.type === "oracle" ||
this.connection.driver.options.type === "sap") &&
this.getValueSets().length > 1
) {
query += ` ${valuesExpression}`
Expand Down
5 changes: 4 additions & 1 deletion src/query-builder/QueryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,10 @@ export abstract class QueryBuilder<Entity extends ObjectLiteral> {
* Uses same query runner as current QueryBuilder.
*/
createQueryBuilder(queryRunner?: QueryRunner): this {
return new (this.constructor as any)(this.connection, queryRunner ?? this.queryRunner)
return new (this.constructor as any)(
this.connection,
queryRunner ?? this.queryRunner,
)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/schema-builder/RdbmsSchemaBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ export class RdbmsSchemaBuilder implements SchemaBuilder {

if (
DriverUtils.isMySQLFamily(this.connection.driver) ||
this.connection.driver.options.type === 'postgres'
this.connection.driver.options.type === "postgres"
) {
const newComment = metadata.comment
await this.queryRunner.changeTableComment(table, newComment)
Expand Down
11 changes: 6 additions & 5 deletions test/integration/sample2-one-to-one.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,15 @@ describe("one-to-one", function () {
expectedPost.details!.comment = savedPost.details!.comment
expectedPost.details!.metadata = savedPost.details!.metadata

const findOne = () => postRepository.findOne({
const findOne = () =>
postRepository.findOne({
where: {
id: savedPost.id
id: savedPost.id,
},
relations: {
details: true
details: true,
},
relationLoadStrategy: "query"
relationLoadStrategy: "query",
})

const posts = await Promise.all([
Expand All @@ -234,7 +235,7 @@ describe("one-to-one", function () {
findOne(),
])

posts.forEach(post => {
posts.forEach((post) => {
expect(post).not.to.be.null
post!.should.eql(expectedPost)
})
Expand Down
21 changes: 11 additions & 10 deletions test/integration/sample3-many-to-one.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,16 @@ describe("many-to-one", function () {
expectedPost.details!.comment = savedPost.details!.comment
expectedPost.details!.metadata = savedPost.details!.metadata

const findOne = () => postRepository.findOne({
where: {
id: savedPost.id
},
relations: {
details: true
},
relationLoadStrategy: "query"
})
const findOne = () =>
postRepository.findOne({
where: {
id: savedPost.id,
},
relations: {
details: true,
},
relationLoadStrategy: "query",
})

const posts = await Promise.all([
findOne(),
Expand All @@ -236,7 +237,7 @@ describe("many-to-one", function () {
findOne(),
])

posts.forEach(post => {
posts.forEach((post) => {
expect(post).not.to.be.null
post!.should.eql(expectedPost)
})
Expand Down

0 comments on commit b535cbd

Please sign in to comment.