@@ -453,8 +453,8 @@ func (r *AssetRepository) deleteWithPredicate(ctx context.Context, pred sq.Eq) (
453453func (r * AssetRepository ) insert (ctx context.Context , ast * asset.Asset ) (id string , err error ) {
454454 err = r .client .RunWithinTx (ctx , func (tx * sqlx.Tx ) error {
455455 query , args , err := sq .Insert ("assets" ).
456- Columns ("urn" , "type" , "service" , "name" , "description" , "data" , "labels" , "updated_by" , "version" ).
457- Values (ast .URN , ast .Type , ast .Service , ast .Name , ast .Description , ast .Data , ast .Labels , ast .UpdatedBy .ID , asset .BaseVersion ).
456+ Columns ("urn" , "type" , "service" , "name" , "description" , "data" , "url" , " labels" , "updated_by" , "version" ).
457+ Values (ast .URN , ast .Type , ast .Service , ast .Name , ast .Description , ast .Data , ast .URL , ast . Labels , ast .UpdatedBy .ID , asset .BaseVersion ).
458458 Suffix ("RETURNING \" id\" " ).
459459 PlaceholderFormat (sq .Dollar ).
460460 ToSql ()
@@ -490,7 +490,6 @@ func (r *AssetRepository) insert(ctx context.Context, ast *asset.Asset) (id stri
490490}
491491
492492func (r * AssetRepository ) update (ctx context.Context , assetID string , newAsset * asset.Asset , oldAsset * asset.Asset , clog diff.Changelog ) error {
493-
494493 if ! isValidUUID (assetID ) {
495494 return asset.InvalidError {AssetID : assetID }
496495 }
@@ -508,22 +507,24 @@ func (r *AssetRepository) update(ctx context.Context, assetID string, newAsset *
508507 newAsset .Version = newVersion
509508 newAsset .ID = oldAsset .ID
510509
511- err = r .execContext (ctx , tx ,
512- `UPDATE assets
513- SET urn = $1,
514- type = $2,
515- service = $3,
516- name = $4,
517- description = $5,
518- data = $6,
519- labels = $7,
520- updated_at = $8,
521- updated_by = $9,
522- version = $10
523- WHERE id = $11;
524- ` ,
525- newAsset .URN , newAsset .Type , newAsset .Service , newAsset .Name , newAsset .Description , newAsset .Data , newAsset .Labels , time .Now (), newAsset .UpdatedBy .ID , newAsset .Version , assetID )
510+ query , args , err := r .buildSQL (sq .Update ("assets" ).
511+ Set ("urn" , newAsset .URN ).
512+ Set ("type" , newAsset .Type ).
513+ Set ("service" , newAsset .Service ).
514+ Set ("name" , newAsset .Name ).
515+ Set ("description" , newAsset .Description ).
516+ Set ("data" , newAsset .Data ).
517+ Set ("url" , newAsset .URL ).
518+ Set ("labels" , newAsset .Labels ).
519+ Set ("updated_at" , time .Now ()).
520+ Set ("updated_by" , newAsset .UpdatedBy .ID ).
521+ Set ("version" , newAsset .Version ).
522+ Where (sq.Eq {"id" : assetID }))
526523 if err != nil {
524+ return fmt .Errorf ("build query: %w" , err )
525+ }
526+
527+ if err := r .execContext (ctx , tx , query , args ... ); err != nil {
527528 return fmt .Errorf ("error running update asset query: %w" , err )
528529 }
529530
@@ -775,6 +776,7 @@ func (r *AssetRepository) getAssetSQL() sq.SelectBuilder {
775776 a.service as service,
776777 a.description as description,
777778 a.data as data,
779+ COALESCE(a.url, '') as url,
778780 a.labels as labels,
779781 a.version as version,
780782 a.created_at as created_at,
0 commit comments