Page MenuHomeSoftware Heritage

Update db swh.revision.metadata data with tarball length
Closed, MigratedEdits Locked

Event Timeline

Query sample to update jsonb field:


softwareheritage-dev=# begin;
BEGIN
softwareheritage-dev=# select metadata#>'{original_artifact,0,name}' as name, metadata#>'{original_artifact,0,length}' as length
softwareheritage-dev-# from revision
softwareheritage-dev-# where id ='\xcd065c4537de129de7b4cc6a5bebfeb09247fc14';
           name           | length
--------------------------+--------
 "talkfilters-1.0.tar.gz" |
(1 row)

softwareheritage-dev=# update revision
softwareheritage-dev-# set metadata = jsonb_set(metadata, '{original_artifact,0,length}', '10')
softwareheritage-dev-# where id = '\xcd065c4537de129de7b4cc6a5bebfeb09247fc14';
UPDATE 1
softwareheritage-dev=# select metadata#>'{original_artifact,0,name}' as name, metadata#>'{original_artifact,0,length}' as length
from revision
where id ='\xcd065c4537de129de7b4cc6a5bebfeb09247fc14';
           name           | length
--------------------------+--------
 "talkfilters-1.0.tar.gz" | 10
(1 row)

softwareheritage-dev=# rollback;
ROLLBACK

source: http://www.postgresql.org/docs/9.5/static/functions-json.html#FUNCTIONS-JSON-PROCESSING-TABLE + tinkering in psql

olasd changed the visibility from "All Users" to "Public (No Login Required)".May 13 2016, 5:09 PM