mirror of
https://github.com/sasjs/core.git
synced 2026-01-06 17:10:05 +00:00
fix: conditional logic for mp_getconstraints, test also updated. Closes #235
This commit is contained in:
16
all.sas
16
all.sas
@@ -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.
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
@@ -6,24 +6,52 @@
|
|||||||
@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(
|
|
||||||
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(
|
%if %sysfunc(exist(sashelp.vcncolu,view))=1 %then %do;
|
||||||
iftrue=(%mf_nobs(work.constraints)=6),
|
proc sql;
|
||||||
desc=Output table work.constraints created with correct number of records,
|
create table work.example(
|
||||||
outds=work.test_results
|
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()
|
||||||
|
|||||||
Reference in New Issue
Block a user