Skip to content

Commit

Permalink
fix: conditional logic for mp_getconstraints, test also updated. Closes
Browse files Browse the repository at this point in the history
  • Loading branch information
Allan Bowe committed May 10, 2022
1 parent fe94d37 commit cb4ea71
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 21 deletions.
16 changes: 16 additions & 0 deletions all.sas
Expand Up @@ -6570,6 +6570,22 @@ drop table &dropds;
%let lib=%upcase(&lib);
%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,
* however they DO arrive in the correct order. So, create the col.
Expand Down
16 changes: 16 additions & 0 deletions base/mp_getconstraints.sas
Expand Up @@ -40,6 +40,22 @@
%let lib=%upcase(&lib);
%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,
* however they DO arrive in the correct order. So, create the col.
Expand Down
6 changes: 3 additions & 3 deletions sasjs/sasjsconfig.json
Expand Up @@ -43,7 +43,7 @@
},
{
"name": "sas9",
"serverUrl": "https://sas.analytium.co.uk:8343",
"serverUrl": "",
"serverType": "SAS9",
"httpsAgentOptions": {
"allowInsecureRequests": false
Expand All @@ -65,7 +65,7 @@
},
{
"name": "server",
"serverUrl": "https://sas.analytium.co.uk:5007",
"serverUrl": "",
"serverType": "SASJS",
"httpsAgentOptions": {
"allowInsecureRequests": false
Expand All @@ -78,7 +78,7 @@
},
{
"name": "docsonly",
"serverType": "SAS9",
"serverType": "SASJS",
"appLoc": "dummy",
"macroFolders": [
"meta",
Expand Down
64 changes: 46 additions & 18 deletions tests/crossplatform/mp_getconstraints.test.sas
Expand Up @@ -6,24 +6,52 @@
@li mf_nobs.sas
@li mp_getconstraints.sas
@li mp_assert.sas
@li mp_assertscope.sas
**/

proc sql;
create table work.example(
TX_FROM float format=datetime19.,
DD_TYPE char(16),
DD_SOURCE char(2048),
DD_SHORTDESC char(256),
constraint pk primary key(tx_from, dd_type,dd_source),
constraint unq unique(tx_from, dd_type),
constraint nnn not null(DD_SHORTDESC)
);

%mp_getconstraints(lib=work,ds=example,outds=work.constraints)

%mp_assert(
iftrue=(%mf_nobs(work.constraints)=6),
desc=Output table work.constraints created with correct number of records,
outds=work.test_results
)

%macro conditional();

%if %sysfunc(exist(sashelp.vcncolu,view))=1 %then %do;
proc sql;
create table work.example(
TX_FROM float format=datetime19.,
DD_TYPE char(16),
DD_SOURCE char(2048),
DD_SHORTDESC char(256),
constraint pk primary key(tx_from, dd_type,dd_source),
constraint unq unique(tx_from, dd_type),
constraint nnn not null(DD_SHORTDESC)
);
%mp_assertscope(SNAPSHOT)
%mp_getconstraints(lib=work,ds=example,outds=work.constraints)
%mp_assertscope(COMPARE)

%mp_assert(
iftrue=(%mf_nobs(work.constraints)=6),
desc=Output table work.constraints created with correct number of records,
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()

0 comments on commit cb4ea71

Please sign in to comment.