@@ -24,8 +24,7 @@ import { DriverUtils } from "../driver/DriverUtils"
2424 */
2525export class UpdateQueryBuilder < Entity extends ObjectLiteral >
2626 extends QueryBuilder < Entity >
27- implements WhereExpressionBuilder
28- {
27+ implements WhereExpressionBuilder {
2928 readonly "@instanceof" = Symbol . for ( "UpdateQueryBuilder" )
3029
3130 // -------------------------------------------------------------------------
@@ -182,7 +181,7 @@ export class UpdateQueryBuilder<Entity extends ObjectLiteral>
182181 if ( transactionStartedByUs ) {
183182 try {
184183 await queryRunner . rollbackTransaction ( )
185- } catch ( rollbackError ) { }
184+ } catch ( rollbackError ) { }
186185 }
187186 throw error
188187 } finally {
@@ -537,18 +536,26 @@ export class UpdateQueryBuilder<Entity extends ObjectLiteral>
537536 // support for SQL expressions in update query
538537 updateColumnAndValues . push (
539538 this . escape ( column . databaseName ) +
540- " = " +
541- value ( ) ,
539+ " = " +
540+ value ( ) ,
542541 )
543542 } else if (
544543 ( this . connection . driver . options . type === "sap" ||
545544 this . connection . driver . options . type ===
546- "spanner" ) &&
545+ "spanner" ) &&
547546 value === null
548547 ) {
549548 updateColumnAndValues . push (
550549 this . escape ( column . databaseName ) + " = NULL" ,
551550 )
551+ } else if ( this . connection . driver . options . type === "spanner" &&
552+ value !== null &&
553+ Array . isArray ( value ) &&
554+ column . type === "json"
555+ ) {
556+ updateColumnAndValues . push (
557+ this . escape ( column . databaseName ) + " = JSON '" + JSON . stringify ( value ) + "'" ,
558+ )
552559 } else {
553560 if (
554561 this . connection . driver . options . type === "mssql"
@@ -566,15 +573,15 @@ export class UpdateQueryBuilder<Entity extends ObjectLiteral>
566573 this . connection . driver ,
567574 ) ||
568575 this . connection . driver . options . type ===
569- "aurora-mysql" ) &&
576+ "aurora-mysql" ) &&
570577 this . connection . driver . spatialTypes . indexOf (
571578 column . type ,
572579 ) !== - 1
573580 ) {
574581 const useLegacy = (
575582 this . connection . driver as
576- | MysqlDriver
577- | AuroraMysqlDriver
583+ | MysqlDriver
584+ | AuroraMysqlDriver
578585 ) . options . legacySpatialSupport
579586 const geomFromText = useLegacy
580587 ? "GeomFromText"
@@ -599,7 +606,7 @@ export class UpdateQueryBuilder<Entity extends ObjectLiteral>
599606 }
600607 } else if (
601608 this . connection . driver . options . type ===
602- "mssql" &&
609+ "mssql" &&
603610 this . connection . driver . spatialTypes . indexOf (
604611 column . type ,
605612 ) !== - 1
@@ -616,8 +623,8 @@ export class UpdateQueryBuilder<Entity extends ObjectLiteral>
616623 }
617624 updateColumnAndValues . push (
618625 this . escape ( column . databaseName ) +
619- " = " +
620- expression ,
626+ " = " +
627+ expression ,
621628 )
622629 }
623630 } )
@@ -635,17 +642,17 @@ export class UpdateQueryBuilder<Entity extends ObjectLiteral>
635642 )
636643 updateColumnAndValues . push (
637644 this . escape ( metadata . versionColumn . databaseName ) +
638- " = " +
639- this . escape ( metadata . versionColumn . databaseName ) +
640- " + 1" ,
645+ " = " +
646+ this . escape ( metadata . versionColumn . databaseName ) +
647+ " + 1" ,
641648 )
642649 if (
643650 metadata . updateDateColumn &&
644651 updatedColumns . indexOf ( metadata . updateDateColumn ) === - 1
645652 )
646653 updateColumnAndValues . push (
647654 this . escape ( metadata . updateDateColumn . databaseName ) +
648- " = CURRENT_TIMESTAMP" ,
655+ " = CURRENT_TIMESTAMP" ,
649656 ) // todo: fix issue with CURRENT_TIMESTAMP(6) being used, can "DEFAULT" be used?!
650657 }
651658 } else {
0 commit comments