@@ -59,9 +59,12 @@ export interface BulkOperationsHost {
5959 injectTenantOnInsert : SqlDriver [ 'injectTenantOnInsert' ] ;
6060 readonly insertReturnsStoredRows : SqlDriver [ 'insertReturnsStoredRows' ] ;
6161 readonly isMssql : SqlDriver [ 'isMssql' ] ;
62+ readonly isOracle : SqlDriver [ 'isOracle' ] ;
6263 keepSuppliedUpdatedAt : SqlDriver [ 'keepSuppliedUpdatedAt' ] ;
6364 readonly knex : SqlDriver [ 'knex' ] ;
65+ oracleUuidBinding : SqlDriver [ 'oracleUuidBinding' ] ;
6466 primeMssqlGuidColumns : SqlDriver [ 'primeMssqlGuidColumns' ] ;
67+ primeOracleRawUuidColumns : SqlDriver [ 'primeOracleRawUuidColumns' ] ;
6568 readBackInsertedRows : SqlDriver [ 'readBackInsertedRows' ] ;
6669 resyncSequenceToDataMax : SqlDriver [ 'resyncSequenceToDataMax' ] ;
6770 remoteColumn : SqlDriver [ 'remoteColumn' ] ;
@@ -79,7 +82,10 @@ export interface BulkOperationsHost {
7982/** The bodies of the "Bulk & Batch Operations" section of `SqlDriver`: a stateless facet, called by the class's stubs. */
8083export class BulkOperationsFacet {
8184 /** The body of `SqlDriver#bulkCreate`; the method's docblock there is its contract. */
82- static async bulkCreate ( this : Pick < BulkOperationsHost , 'applyWriteColumnMap' | 'auditMissingTenant' | 'autoNumberCounterKey' | 'collidingAutoNumberReservations' | 'fillAutoNumberFields' | 'formatInput' | 'formatOutput' | 'getBuilder' | 'injectTenantOnInsert' | 'insertReturnsStoredRows' | 'isMssql' | 'readBackInsertedRows' | 'resyncSequenceToDataMax' | 'rotationWriteTarget' | 'stampInsertTimestamps' > , object : string , data : any [ ] , options ?: DriverOptions ) : Promise < Record < string , unknown > [ ] > {
85+ static async bulkCreate ( this : Pick < BulkOperationsHost , 'applyWriteColumnMap' | 'auditMissingTenant' | 'autoNumberCounterKey' | 'collidingAutoNumberReservations' | 'fillAutoNumberFields' | 'formatInput' | 'formatOutput' | 'getBuilder' | 'injectTenantOnInsert' | 'insertReturnsStoredRows' | 'isMssql' | 'isOracle' | 'primeOracleRawUuidColumns' | 'readBackInsertedRows' | 'resyncSequenceToDataMax' | 'rotationWriteTarget' | 'stampInsertTimestamps' > , object : string , data : any [ ] , options ?: DriverOptions ) : Promise < Record < string , unknown > [ ] > {
86+ // [#31390] On Oracle a federated object's RAW(16) uuid columns are read from
87+ // the remote catalog before a comparand or a written value is bound.
88+ if ( this . isOracle ) await this . primeOracleRawUuidColumns ( object ) ;
8389 // Same client-side id assignment as create() (id/_id normalization,
8490 // nanoid fallback when neither is supplied) — a row missing an id must
8591 // not be silently inserted with a NULL primary key just because the
@@ -262,21 +268,29 @@ export class BulkOperationsFacet {
262268 }
263269
264270 /** The body of `SqlDriver#bulkDelete`; the method's docblock there is its contract. */
265- static async bulkDelete ( this : Pick < BulkOperationsHost , 'applyTenantScope' | 'auditMissingTenant' | 'getBuilder' | 'remoteColumn' | 'rotationShardsOf' > , object : string , ids : Array < string | number > , options ?: DriverOptions ) : Promise < void > {
271+ static async bulkDelete ( this : Pick < BulkOperationsHost , 'applyTenantScope' | 'auditMissingTenant' | 'getBuilder' | 'isOracle' | 'oracleUuidBinding' | 'primeOracleRawUuidColumns' | 'remoteColumn' | 'rotationShardsOf' > , object : string , ids : Array < string | number > , options ?: DriverOptions ) : Promise < void > {
272+ // [#31390] On Oracle a federated object's RAW(16) uuid columns are read from
273+ // the remote catalog before a comparand or a written value is bound.
274+ if ( this . isOracle ) await this . primeOracleRawUuidColumns ( object ) ;
266275 this . auditMissingTenant ( object , 'bulkDelete' , options ) ;
267276 for ( const target of this . rotationShardsOf ( object ) ?? [ object ] ) {
268277 // The primary key's column: the `external.columnMap` remote column on a
269278 // federated object, `id` otherwise (a rotation shard is never federated).
270- const builder = this . getBuilder ( target , options ) . whereIn ( this . remoteColumn ( object , 'id' , 'id' ) , ids ) ;
279+ // [#31390] On Oracle a RAW(16) uuid key binds each id as `HEXTORAW(?)`.
280+ const keys = ids . map ( ( id ) => this . oracleUuidBinding ( object , 'id' , id , 'comparand' ) ) ;
281+ const builder = this . getBuilder ( target , options ) . whereIn ( this . remoteColumn ( object , 'id' , 'id' ) , keys as any [ ] ) ;
271282 this . applyTenantScope ( builder , object , options ) ;
272283 await builder . delete ( ) ;
273284 }
274285 }
275286
276287 /** The body of `SqlDriver#updateMany`; the method's docblock there is its contract. */
277- static async updateMany ( this : Pick < BulkOperationsHost , 'applyFilters' | 'applyTenantScope' | 'applyWriteColumnMap' | 'auditMissingTenant' | 'formatInput' | 'getBuilder' | 'isMssql' | 'keepSuppliedUpdatedAt' | 'primeMssqlGuidColumns' | 'rotationShardsOf' | 'stampsUpdatedAt' | 'updateWithPresumedTimestamp' | 'updatedAtStamp' | 'updatedAtStampIsPresumed' > , object : string , query : DriverQuery , data : any , options ?: DriverOptions ) : Promise < number > {
288+ static async updateMany ( this : Pick < BulkOperationsHost , 'applyFilters' | 'applyTenantScope' | 'applyWriteColumnMap' | 'auditMissingTenant' | 'formatInput' | 'getBuilder' | 'isMssql' | 'isOracle' | ' keepSuppliedUpdatedAt' | 'primeMssqlGuidColumns' | 'primeOracleRawUuidColumns ' | 'rotationShardsOf' | 'stampsUpdatedAt' | 'updateWithPresumedTimestamp' | 'updatedAtStamp' | 'updatedAtStampIsPresumed' > , object : string , query : DriverQuery , data : any , options ?: DriverOptions ) : Promise < number > {
278289 // [#31395] SQL Server: which columns are GUIDs, before a text operator compiles.
279290 if ( this . isMssql ) await this . primeMssqlGuidColumns ( object , query . where ) ;
291+ // [#31390] On Oracle a federated object's RAW(16) uuid columns are read from
292+ // the remote catalog before a comparand or a written value is bound.
293+ if ( this . isOracle ) await this . primeOracleRawUuidColumns ( object ) ;
280294 this . auditMissingTenant ( object , 'updateMany' , options ) ;
281295
282296 // `data ?? {}` keeps the nullish tolerance this door already had on the
@@ -318,9 +332,12 @@ export class BulkOperationsFacet {
318332 }
319333
320334 /** The body of `SqlDriver#deleteMany`; the method's docblock there is its contract. */
321- static async deleteMany ( this : Pick < BulkOperationsHost , 'applyFilters' | 'applyTenantScope' | 'auditMissingTenant' | 'getBuilder' | 'isMssql' | 'primeMssqlGuidColumns' | 'rotationShardsOf' > , object : string , query : DriverQuery , options ?: DriverOptions ) : Promise < number > {
335+ static async deleteMany ( this : Pick < BulkOperationsHost , 'applyFilters' | 'applyTenantScope' | 'auditMissingTenant' | 'getBuilder' | 'isMssql' | 'isOracle' | ' primeMssqlGuidColumns' | 'primeOracleRawUuidColumns ' | 'rotationShardsOf' > , object : string , query : DriverQuery , options ?: DriverOptions ) : Promise < number > {
322336 // [#31395] SQL Server: which columns are GUIDs, before a text operator compiles.
323337 if ( this . isMssql ) await this . primeMssqlGuidColumns ( object , query . where ) ;
338+ // [#31390] On Oracle a federated object's RAW(16) uuid columns are read from
339+ // the remote catalog before a comparand or a written value is bound.
340+ if ( this . isOracle ) await this . primeOracleRawUuidColumns ( object ) ;
324341 this . auditMissingTenant ( object , 'deleteMany' , options ) ;
325342 let total = 0 ;
326343 for ( const target of this . rotationShardsOf ( object ) ?? [ object ] ) {
@@ -363,9 +380,12 @@ export class BulkOperationsFacet {
363380 }
364381
365382 /** The body of `SqlDriver#count`; the method's docblock there is its contract. */
366- static async count ( this : Pick < BulkOperationsHost , 'applyFilters' | 'applyTenantScope' | 'backendStatementFault' | 'getBuilder' | 'isMssql' | 'primeMssqlGuidColumns' | 'unresolvableFilterColumnRefusal' > , object : string , query ?: DriverQuery , options ?: DriverOptions ) : Promise < number > {
383+ static async count ( this : Pick < BulkOperationsHost , 'applyFilters' | 'applyTenantScope' | 'backendStatementFault' | 'getBuilder' | 'isMssql' | 'isOracle' | ' primeMssqlGuidColumns' | 'primeOracleRawUuidColumns ' | 'unresolvableFilterColumnRefusal' > , object : string , query ?: DriverQuery , options ?: DriverOptions ) : Promise < number > {
367384 // [#31395] SQL Server: which columns are GUIDs, before a text operator compiles.
368385 if ( this . isMssql ) await this . primeMssqlGuidColumns ( object , query ?. where ) ;
386+ // [#31390] On Oracle a federated object's RAW(16) uuid columns are read from
387+ // the remote catalog before a comparand or a written value is bound.
388+ if ( this . isOracle ) await this . primeOracleRawUuidColumns ( object ) ;
369389 const builder = this . getBuilder ( object , options ) ;
370390 this . applyTenantScope ( builder , object , options ) ;
371391
0 commit comments