Skip to content

Commit

Permalink
* fixed missing version in get_schema.sql
Browse files Browse the repository at this point in the history
* added disabled flag in return of list_schemas.sql
  • Loading branch information
benedeki committed Jan 12, 2022
1 parent fefd5f3 commit 29c5e32
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
14 changes: 7 additions & 7 deletions database/src/main/dataset_schema/get_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* limitations under the License.
*/

DROP FUNCTION dataset_schema.get_schema(TEXT, INTEGER);
DROP FUNCTION dataset_schema.get_schema(BIGINT);
DROP FUNCTION IF EXISTS dataset_schema.get_schema(TEXT, INTEGER);
DROP FUNCTION IF EXISTS dataset_schema.get_schema(BIGINT);

CREATE OR REPLACE FUNCTION dataset_schema.get_schema(
IN i_schema_name TEXT,
Expand Down Expand Up @@ -91,14 +91,14 @@ BEGIN
RETURN;
END IF;

SELECT 200, 'OK', dss.id_schema, dss.schema_name,
SELECT 200, 'OK', dss.id_schema, dss.schema_name, dss.schema_version,
dss.schema_description, dss.fields, _created_by, _created_when,
dss.updated_by, dss.updated_when, _locked_by, _locked_when,
_disabled_by, _disabled_when
FROM dataset_schema.schemas dss
WHERE dss.schema_name = i_schema_name AND
dss.schema_version = _schema_version
INTO status, status_text, id_schema, schema_name,
INTO status, status_text, id_schema, schema_name, schema_version,
schema_description, fields, created_by, created_when,
updated_by, updated_when, locked_by, locked_when,
disabled_by, disabled_when;
Expand Down Expand Up @@ -168,11 +168,11 @@ DECLARE
_schema_name TEXT;
BEGIN

SELECT 200, 'OK', dss.id_schema, dss.schema_name,
SELECT 200, 'OK', dss.id_schema, dss.schema_name, dss.schema_version,
dss.schema_description, dss.fields, dss.updated_by, dss.updated_when
FROM dataset_schema.schemas dss
WHERE dss.id_schema = i_key_schema
INTO status, status_text, id_schema, _schema_name,
INTO status, status_text, id_schema, _schema_name, schema_version,
schema_description, fields, updated_by, updated_when;

IF NOT found THEN
Expand All @@ -189,7 +189,7 @@ BEGIN
INTO created_by, created_when, locked_by, locked_when,
disabled_by, disabled_when;

schema_name := _schema_name; -- used a local variable to avoid name disambiguaty
schema_name := _schema_name; -- used a local variable to avoid name disambiguity

RETURN;
END;
Expand Down
5 changes: 3 additions & 2 deletions database/src/main/dataset_schema/list_schemas.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ DROP FUNCTION IF EXISTS dataset_schema.list_schemas(BOOLEAN);
CREATE OR REPLACE FUNCTION dataset_schema.list_schemas(
IN i_include_disabled BOOLEAN DEFAULT FALSE,
OUT schema_name TEXT,
OUT schema_latest_version INTEGER
OUT schema_latest_version INTEGER,
OUT disabled BOOLEAN
) RETURNS SETOF record AS
$$
-------------------------------------------------------------------------------
Expand All @@ -37,7 +38,7 @@ $$
DECLARE
BEGIN
RETURN QUERY
SELECT dsh.schema_name, dsh.schema_latest_version
SELECT dsh.schema_name, dsh.schema_latest_version, dsh.disabled_when IS NOT NULL
FROM dataset_schema.heads dsh
WHERE i_include_disabled OR dsh.disabled_when IS NULL
ORDER BY schema_name; --TODO Include order by?
Expand Down

0 comments on commit 29c5e32

Please sign in to comment.