From 9d3590e5a4f378ace81d2675e8c644f6814cf975 Mon Sep 17 00:00:00 2001 From: jar3b Date: Thu, 24 Mar 2016 12:17:57 +0300 Subject: [PATCH] Add regioncode to FIAS result set --- aore/dbutils/dbschemas.py | 2 +- aore/templates/postgre/create_structure.sql | 1 + aore/templates/postgre/expand_query.sql | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/aore/dbutils/dbschemas.py b/aore/dbutils/dbschemas.py index 23407cb..1441ed9 100644 --- a/aore/dbutils/dbschemas.py +++ b/aore/dbutils/dbschemas.py @@ -13,7 +13,7 @@ db_shemas = dict() db_shemas['ADDROBJ'] = \ DbSchema("ADDROBJ", ["AOID", "AOGUID", "SHORTNAME", "FORMALNAME", "AOLEVEL", "PARENTGUID", "ACTSTATUS", "LIVESTATUS", - "NEXTID"], + "NEXTID", "REGIONCODE"], "aoid", "Object") diff --git a/aore/templates/postgre/create_structure.sql b/aore/templates/postgre/create_structure.sql index e7f8188..44b8a53 100644 --- a/aore/templates/postgre/create_structure.sql +++ b/aore/templates/postgre/create_structure.sql @@ -10,6 +10,7 @@ CREATE TABLE "ADDROBJ" ( "actstatus" BOOL, "livestatus" BOOL, "nextid" UUID, + "regioncode" int2, CONSTRAINT "aoid" UNIQUE ("aoid"), CONSTRAINT "id_addrobj" PRIMARY KEY ("id") ) diff --git a/aore/templates/postgre/expand_query.sql b/aore/templates/postgre/expand_query.sql index 3a63279..17fa4db 100644 --- a/aore/templates/postgre/expand_query.sql +++ b/aore/templates/postgre/expand_query.sql @@ -6,4 +6,4 @@ WITH RECURSIVE child_to_parents AS ( WHERE "ADDROBJ".aoguid = child_to_parents.parentguid AND "ADDROBJ".actstatus = True AND "ADDROBJ".livestatus = True AND "ADDROBJ".nextid IS NULL ) -SELECT DISTINCT ON (scname) cs.aoid, cs.aoguid, cs.shortname, cs.formalname, cs.aolevel, s.socrname FROM child_to_parents cs LEFT JOIN "SOCRBASE" s ON s.scname=cs.shortname ORDER BY scname, aolevel; +SELECT DISTINCT ON (scname) cs.aoid, cs.aoguid, cs.shortname, cs.formalname, cs.aolevel, cs.regioncode, s.socrname FROM child_to_parents cs LEFT JOIN "SOCRBASE" s ON s.scname=cs.shortname ORDER BY scname, aolevel;