1
0
mirror of https://github.com/sasjs/core.git synced 2026-01-07 17:40:05 +00:00

fix: conditional logic for mp_getconstraints, test also updated. Closes #235

This commit is contained in:
Allan Bowe
2022-05-10 14:59:31 +00:00
parent fe94d3781a
commit cb4ea71e81
4 changed files with 79 additions and 19 deletions

16
all.sas
View File

@@ -6570,6 +6570,22 @@ drop table &dropds;
%let lib=%upcase(&lib); %let lib=%upcase(&lib);
%let ds=%upcase(&ds); %let ds=%upcase(&ds);
/**
* Cater for environments where sashelp.vcncolu is not available
*/
%if %sysfunc(exist(sashelp.vcncolu,view))=0 %then %do;
proc sql;
create table &outds(
libref char(8)
,TABLE_NAME char(32)
,constraint_type char(8) label='Constraint Type'
,constraint_name char(32) label='Constraint Name'
,column_name char(32) label='Column'
,constraint_order num
);
%return;
%end;
/** /**
* Neither dictionary tables nor sashelp provides a constraint order column, * Neither dictionary tables nor sashelp provides a constraint order column,
* however they DO arrive in the correct order. So, create the col. * however they DO arrive in the correct order. So, create the col.

View File

@@ -40,6 +40,22 @@
%let lib=%upcase(&lib); %let lib=%upcase(&lib);
%let ds=%upcase(&ds); %let ds=%upcase(&ds);
/**
* Cater for environments where sashelp.vcncolu is not available
*/
%if %sysfunc(exist(sashelp.vcncolu,view))=0 %then %do;
proc sql;
create table &outds(
libref char(8)
,TABLE_NAME char(32)
,constraint_type char(8) label='Constraint Type'
,constraint_name char(32) label='Constraint Name'
,column_name char(32) label='Column'
,constraint_order num
);
%return;
%end;
/** /**
* Neither dictionary tables nor sashelp provides a constraint order column, * Neither dictionary tables nor sashelp provides a constraint order column,
* however they DO arrive in the correct order. So, create the col. * however they DO arrive in the correct order. So, create the col.

View File

@@ -43,7 +43,7 @@
}, },
{ {
"name": "sas9", "name": "sas9",
"serverUrl": "https://sas.analytium.co.uk:8343", "serverUrl": "",
"serverType": "SAS9", "serverType": "SAS9",
"httpsAgentOptions": { "httpsAgentOptions": {
"allowInsecureRequests": false "allowInsecureRequests": false
@@ -65,7 +65,7 @@
}, },
{ {
"name": "server", "name": "server",
"serverUrl": "https://sas.analytium.co.uk:5007", "serverUrl": "",
"serverType": "SASJS", "serverType": "SASJS",
"httpsAgentOptions": { "httpsAgentOptions": {
"allowInsecureRequests": false "allowInsecureRequests": false
@@ -78,7 +78,7 @@
}, },
{ {
"name": "docsonly", "name": "docsonly",
"serverType": "SAS9", "serverType": "SASJS",
"appLoc": "dummy", "appLoc": "dummy",
"macroFolders": [ "macroFolders": [
"meta", "meta",

View File

@@ -6,11 +6,16 @@
@li mf_nobs.sas @li mf_nobs.sas
@li mp_getconstraints.sas @li mp_getconstraints.sas
@li mp_assert.sas @li mp_assert.sas
@li mp_assertscope.sas
**/ **/
proc sql;
create table work.example( %macro conditional();
%if %sysfunc(exist(sashelp.vcncolu,view))=1 %then %do;
proc sql;
create table work.example(
TX_FROM float format=datetime19., TX_FROM float format=datetime19.,
DD_TYPE char(16), DD_TYPE char(16),
DD_SOURCE char(2048), DD_SOURCE char(2048),
@@ -18,12 +23,35 @@ create table work.example(
constraint pk primary key(tx_from, dd_type,dd_source), constraint pk primary key(tx_from, dd_type,dd_source),
constraint unq unique(tx_from, dd_type), constraint unq unique(tx_from, dd_type),
constraint nnn not null(DD_SHORTDESC) constraint nnn not null(DD_SHORTDESC)
); );
%mp_assertscope(SNAPSHOT)
%mp_getconstraints(lib=work,ds=example,outds=work.constraints)
%mp_assertscope(COMPARE)
%mp_getconstraints(lib=work,ds=example,outds=work.constraints) %mp_assert(
%mp_assert(
iftrue=(%mf_nobs(work.constraints)=6), iftrue=(%mf_nobs(work.constraints)=6),
desc=Output table work.constraints created with correct number of records, desc=Output table work.constraints created with correct number of records,
outds=work.test_results outds=work.test_results
) )
%end;
%else %do;
proc sql;
create table work.example(
TX_FROM float format=datetime19.,
DD_TYPE char(16),
DD_SOURCE char(2048),
DD_SHORTDESC char(256)
);
%mp_assertscope(SNAPSHOT)
%mp_getconstraints(lib=work,ds=example,outds=work.constraints)
%mp_assertscope(COMPARE)
%mp_assert(
iftrue=(%mf_nobs(work.constraints)=0),
desc=Empty table created as constraints not supported,
outds=work.test_results
)
%end;
%mend conditional;
%conditional()