Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add WITH (lock) clause for MSSQL select with join queries (#8507)
* fix: add lock clause for MSSQL select with join clause typeorm didn't supported LOCK clause in SELECT + JOIN query. For example, we cannot buld SQL such as "SELECT * FROM USER U WITH(NOLOCK) INNER JOIN ORDER WITH(NOLOCK) O ON U.ID=O.UserID". This pull request enables LOCK with SELECT + JOIN sql query. Closes: #4764 * chore: add test cases * chore: refactor method name, miscellaneous changes on createTableLockExpression
- Loading branch information
1 parent
c490319
commit 3284808
Showing
5 changed files
with
333 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { | ||
Column, | ||
Entity, | ||
JoinColumn, | ||
OneToMany, | ||
OneToOne, | ||
PrimaryGeneratedColumn, | ||
} from "../../../../src"; | ||
import { CartItems } from "./CartItems"; | ||
import { User } from "./User"; | ||
|
||
@Entity() | ||
export class Cart { | ||
@PrimaryGeneratedColumn() | ||
ID!: number; | ||
|
||
@Column() | ||
UNID!: number; | ||
|
||
@Column() | ||
Type!: string; | ||
|
||
@Column() | ||
Cycle?: number; | ||
|
||
@Column() | ||
Term?: string; | ||
|
||
@Column() | ||
RegDate!: Date; | ||
|
||
@Column() | ||
ModifiedDate!: Date; | ||
|
||
@OneToMany((type) => CartItems, (t) => t.Cart) | ||
CartItems?: CartItems[]; | ||
|
||
@OneToOne((type) => User, (t) => t.Cart) | ||
@JoinColumn({ name: "UNID" }) | ||
User?: User; | ||
} |
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 { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from "../../../../src"; | ||
import { Cart } from "./Cart"; | ||
|
||
@Entity() | ||
export class CartItems { | ||
@PrimaryGeneratedColumn() | ||
ID!: number; | ||
|
||
@Column() | ||
CartID!: number; | ||
|
||
@Column() | ||
ItemID!: number; | ||
|
||
@Column() | ||
OptionID!: number; | ||
|
||
@Column() | ||
Quantity!: number; | ||
|
||
@Column() | ||
RegDate!: Date; | ||
|
||
@Column() | ||
ModifiedDate!: Date; | ||
|
||
@ManyToOne((type) => Cart, (t) => t.CartItems) | ||
@JoinColumn({ name: "CartID" }) | ||
Cart?: Cart; | ||
} |
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,25 @@ | ||
import { | ||
Column, | ||
Entity, | ||
OneToOne, | ||
PrimaryGeneratedColumn, | ||
} from "../../../../src"; | ||
import { Cart } from "./Cart"; | ||
|
||
@Entity() | ||
export class User { | ||
@PrimaryGeneratedColumn() | ||
ID!: number; | ||
|
||
@Column() | ||
name!: string; | ||
|
||
@Column() | ||
RegDate!: Date; | ||
|
||
@Column() | ||
ModifiedDate!: Date; | ||
|
||
@OneToOne((type) => Cart, (t) => t.User) | ||
Cart?: Cart; | ||
} |
Oops, something went wrong.