1
0
mirror of https://github.com/sasjs/core.git synced 2025-12-10 22:14:35 +00:00

Merge pull request #236 from sasjs/allanbowe/error-data-set-sashelp-235

fix: conditional logic for mp_getconstraints, test also updated.  Closes #235
This commit is contained in:
Allan Bowe
2022-05-10 18:00:20 +03:00
committed by GitHub
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 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.

View File

@@ -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.

View File

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

View File

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