Technology dependencies view

* Added SQL view that lists dependencies of technologies as
comma-separated lists of identifiers
This commit is contained in:
Emmanuel BENOîT 2012-02-29 11:50:04 +01:00
parent f4e38e4943
commit e01eab9c09
3 changed files with 88 additions and 1 deletions
legacyworlds-server-data/db-structure/parts/040-functions

View file

@ -311,4 +311,27 @@ CREATE TRIGGER tg_techdeps_ai
REVOKE EXECUTE
ON FUNCTION defs.tgf_techdeps_ai( )
FROM PUBLIC;
FROM PUBLIC;
/*
* Technology dependencies view
* -----------------------------
*
* This view generates a parseable list of dependencies per technology.
*
* Columns:
* technology_name_id The technology's name
* technology_dependencies A list of comma-separated technology name
* identifiers
*/
DROP VIEW IF EXISTS defs.technology_dependencies_view CASCADE;
CREATE VIEW defs.technology_dependencies_view
AS SELECT technology_name_id ,
array_to_string( array_agg( _name_str.name ) , ',' ) AS technology_dependencies
FROM defs.technologies _tech
LEFT OUTER JOIN defs.technology_dependencies
USING ( technology_name_id )
LEFT OUTER JOIN defs.strings _name_str
ON _name_str.id = technology_name_id_depends
GROUP BY technology_name_id;