-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Only first single quote in comments is escaped (#7514)
- Loading branch information
1 parent
eff43c1
commit e1e9423
Showing
6 changed files
with
76 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src"; | ||
|
||
@Entity() | ||
export class Post { | ||
|
||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column("text", { | ||
nullable: false, | ||
comment: `E.g. 'foo', 'bar', or 'baz' etc.` | ||
}) | ||
text: string; | ||
|
||
@Column("text", { | ||
nullable: false, | ||
comment: `E.g. '''foo, 'bar''', or baz' etc.` | ||
}) | ||
text2: string; | ||
|
||
@Column("text", { | ||
nullable: false, | ||
comment: `E.g. "foo", "bar", or "baz" etc.` | ||
}) | ||
text3: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import "reflect-metadata"; | ||
import {Connection} from "../../../src"; | ||
import {createTestingConnections, closeTestingConnections} from "../../utils/test-utils"; | ||
import {Post} from "./entity/Post"; | ||
|
||
describe("github issues > #7479 Only first single quote in comments is escaped", () => { | ||
let connections: Connection[]; | ||
before(async () => connections = await createTestingConnections({ | ||
enabledDrivers: ["postgres", "cockroachdb", "mysql"], | ||
schemaCreate: true, | ||
dropSchema: true, | ||
entities: [Post], | ||
})); | ||
after(() => closeTestingConnections(connections)); | ||
|
||
it("should properly escape quotes in comments", () => Promise.all(connections.map(async connection => { | ||
const queryRunner = connection.createQueryRunner(); | ||
|
||
let table = await queryRunner.getTable("post"); | ||
const column1 = table!.findColumnByName("text")!; | ||
const column2 = table!.findColumnByName("text2")!; | ||
const column3 = table!.findColumnByName("text3")!; | ||
|
||
column1.comment!.should.be.equal(`E.g. 'foo', 'bar', or 'baz' etc.`) | ||
column2.comment!.should.be.equal(`E.g. '''foo, 'bar''', or baz' etc.`) | ||
column3.comment!.should.be.equal(`E.g. "foo", "bar", or "baz" etc.`) | ||
|
||
await queryRunner.release() | ||
}))); | ||
}); |