@@ -174,24 +174,26 @@ export class TableRepository implements ITableRepository {
174174 }
175175
176176 async find ( spec : Option < TableComositeSpecification > , ignoreSpace ?: boolean ) : Promise < TableDo [ ] > {
177- const query = this . qb
177+ const tx = this . txContext . getCurrentTransaction ( )
178+ const query = tx
178179 . selectFrom ( "undb_table" )
179180 . selectAll ( "undb_table" )
180181 . $if ( spec . isSome ( ) , ( qb ) => new TableReferenceVisitor ( qb ) . call ( spec . unwrap ( ) ) )
181182 . where ( ( eb ) =>
182- new TableDbQuerySpecHandler ( this . qb , eb , this . context . mustGetCurrentSpaceId ( ) , ignoreSpace ) . handle ( spec ) ,
183+ new TableDbQuerySpecHandler ( tx , eb , this . context . mustGetCurrentSpaceId ( ) , ignoreSpace ) . handle ( spec ) ,
183184 )
184185 const tbs = await query . execute ( )
185186
186187 return tbs . map ( ( t ) => this . mapper . toDo ( t ) )
187188 }
188189
189190 async findOne ( spec : Option < TableComositeSpecification > ) : Promise < Option < TableDo > > {
190- const tb = await this . qb
191+ const tx = this . txContext . getCurrentTransaction ( )
192+ const tb = await tx
191193 . selectFrom ( "undb_table" )
192194 . selectAll ( "undb_table" )
193195 . $if ( spec . isSome ( ) , ( qb ) => new TableReferenceVisitor ( qb ) . call ( spec . unwrap ( ) ) )
194- . where ( ( eb ) => new TableDbQuerySpecHandler ( this . qb , eb , this . context . mustGetCurrentSpaceId ( ) ) . handle ( spec ) )
196+ . where ( ( eb ) => new TableDbQuerySpecHandler ( tx , eb , this . context . mustGetCurrentSpaceId ( ) ) . handle ( spec ) )
195197 . executeTakeFirst ( )
196198
197199 if ( ! tb ) {
@@ -203,24 +205,25 @@ export class TableRepository implements ITableRepository {
203205
204206 async findOneById ( id : TableId ) : Promise < Option < TableDo > > {
205207 const spec = Some ( new TableIdSpecification ( id ) )
206- const tb = await this . qb
208+ const tx = this . txContext . getCurrentTransaction ( )
209+ const tb = await tx
207210 . selectFrom ( "undb_table" )
208211 . selectAll ( "undb_table" )
209212 . $call ( ( qb ) => new TableReferenceVisitor ( qb ) . call ( spec . unwrap ( ) ) )
210- . where ( ( eb ) => new TableDbQuerySpecHandler ( this . qb , eb , this . context . mustGetCurrentSpaceId ( ) ) . handle ( spec ) )
213+ . where ( ( eb ) => new TableDbQuerySpecHandler ( tx , eb , this . context . mustGetCurrentSpaceId ( ) ) . handle ( spec ) )
211214 . executeTakeFirst ( )
212215
213216 return tb ? Some ( this . mapper . toDo ( tb ) ) : None
214217 }
215218
216219 async findManyByIds ( ids : TableId [ ] ) : Promise < TableDo [ ] > {
217220 const spec = Some ( new TableIdsSpecification ( ids ) )
218- const tbs = await this . txContext
219- . getCurrentTransaction ( )
221+ const tx = this . txContext . getCurrentTransaction ( )
222+ const tbs = await tx
220223 . selectFrom ( "undb_table" )
221224 . selectAll ( "undb_table" )
222225 . $call ( ( qb ) => new TableReferenceVisitor ( qb ) . call ( spec . unwrap ( ) ) )
223- . where ( ( eb ) => new TableDbQuerySpecHandler ( this . qb , eb , this . context . mustGetCurrentSpaceId ( ) ) . handle ( spec ) )
226+ . where ( ( eb ) => new TableDbQuerySpecHandler ( tx , eb , this . context . mustGetCurrentSpaceId ( ) ) . handle ( spec ) )
224227 . execute ( )
225228
226229 return tbs . map ( ( t ) => this . mapper . toDo ( t ) )
0 commit comments