Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vospace-file-catalog
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VOSpace INAF
vospace-file-catalog
Commits
e7c16d55
Commit
e7c16d55
authored
4 years ago
by
Sonia Zorba
Browse files
Options
Downloads
Patches
Plain Diff
Added function for merging arrays for task #3892
parent
dabe3ef3
No related branches found
No related tags found
No related merge requests found
Pipeline
#1383
passed
4 years ago
Stage: dockerize
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
08-update_array.sql
+14
-0
14 additions, 0 deletions
08-update_array.sql
with
14 additions
and
0 deletions
08-update_array.sql
0 → 100644
+
14
−
0
View file @
e7c16d55
-- This function returns an array adding some elements and removing others
-- It is used to update recursively groupread and groupwrite properties
CREATE
OR
REPLACE
FUNCTION
update_array
(
input_array
VARCHAR
[],
elements_to_add
VARCHAR
[],
elements_to_remove
VARCHAR
[])
RETURNS
VARCHAR
[]
AS
$
func
$
SELECT
array_agg
(
elements
)
FROM
(
SELECT
DISTINCT
UNNEST
(
input_array
)
UNION
SELECT
DISTINCT
UNNEST
(
elements_to_add
)
EXCEPT
SELECT
DISTINCT
UNNEST
(
elements_to_remove
)
)
AS
output_values
(
elements
)
$
func
$
LANGUAGE
sql
;
SELECT
update_array
(
'{"group1","group2"}'
::
VARCHAR
[],
'{"group2","group3"}'
::
VARCHAR
[],
'{"group1"}'
::
VARCHAR
[])
=
'{"group2","group3"}'
AS
test_passed
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment