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

fix: refactored mp_getconstraints due to apparent bug in dictionary.table_constraints. Added test. Closes #83

This commit is contained in:
Allan Bowe
2021-10-01 13:04:26 +01:00
parent cb0ddfb61c
commit 35ddccaa16
4 changed files with 43 additions and 5 deletions

View File

@@ -4466,8 +4466,11 @@ create table &outds as
on upcase(a.TABLE_CATALOG)=upcase(b.TABLE_CATALOG)
and upcase(a.TABLE_NAME)=upcase(b.TABLE_NAME)
and a.constraint_name=b.constraint_name
where upcase(a.TABLE_CATALOG)="&lib"
and upcase(b.TABLE_CATALOG)="&lib"
/**
* We cannot apply this clause to the underlying dictionary table. See:
* https://communities.sas.com/t5/SAS-Programming/Unexpected-Where-Clause-behaviour-in-dictionary-TABLE/m-p/771554#M244867
*/
where calculated libref="&lib"
%if "&ds" ne "" %then %do;
and upcase(a.TABLE_NAME)="&ds"
and upcase(b.TABLE_NAME)="&ds"

View File

@@ -49,8 +49,11 @@ create table &outds as
on upcase(a.TABLE_CATALOG)=upcase(b.TABLE_CATALOG)
and upcase(a.TABLE_NAME)=upcase(b.TABLE_NAME)
and a.constraint_name=b.constraint_name
where upcase(a.TABLE_CATALOG)="&lib"
and upcase(b.TABLE_CATALOG)="&lib"
/**
* We cannot apply this clause to the underlying dictionary table. See:
* https://communities.sas.com/t5/SAS-Programming/Unexpected-Where-Clause-behaviour-in-dictionary-TABLE/m-p/771554#M244867
*/
where calculated libref="&lib"
%if "&ds" ne "" %then %do;
and upcase(a.TABLE_NAME)="&ds"
and upcase(b.TABLE_NAME)="&ds"

View File

@@ -50,7 +50,10 @@
"appLoc": "/Shared Data/temp/macrocore",
"macroFolders": [
"tests/sas9only"
]
],
"deployConfig": {
"deployServicePack": true
}
},
{
"name": "docsonly",

View File

@@ -0,0 +1,29 @@
/**
@file
@brief Testing mp_getconstraints.sas macro
<h4> SAS Macros </h4>
@li mf_nobs.sas
@li mp_getconstraints.sas
@li mp_assert.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
)