1
0
mirror of https://github.com/sasjs/core.git synced 2026-07-23 15:35:29 +00:00

fix: ensure leading blanks are always imported

This commit is contained in:
4gl
2026-07-22 16:29:18 +01:00
parent e104f0722d
commit e24ef4c6fc
7 changed files with 83 additions and 7 deletions
+11
View File
@@ -11,9 +11,20 @@
filename webref temp;
data demo;
length x $100;
do x='"','0A'x,'0D'x,'09'x,'00'x,'0E'x,'0F'x,'01'x,'02'x,'10'x,'11'x,'\';
output;
end;
/* embedded quote variants */
x='say "hi" there'; output;
x='"fully quoted"'; output;
x='back\slash'; output;
x='quote and back\"slash'; output;
/* leading / trailing blank variants */
x=' leading blanks'; output;
x=' "leading blanks and quotes"'; output;
x='trailing blanks '; output;
x=' both '; output;
run;
%mp_jsonout(OPEN,jref=webref)
%mp_jsonout(OBJ,demo,jref=webref)
+51
View File
@@ -32,4 +32,55 @@ run;
%mp_assert(
iftrue=(%str(&checkval)=%str(&sysvlong)),
desc=Check if the sysvlong value was created
)
/*
Test that ms_webout(FETCH) retains leading blanks in character values
(simulates the CSV format generated by the sasjs adapter, ie an input
statement in the first row followed by unquoted data)
*/
%let fref2=%mf_getuniquefileref();
data _null_;
file &fref2 lrecl=32767 termstr=crlf;
put 'col1:$char10. col2:best.';
put ' padded,1';
run;
%global _webin_fileref _webin_name;
%let _webin_fileref=&fref2;
%let _webin_name=leadblank;
%let _webin_file_count=1;
%ms_webout(FETCH)
data _null_;
set leadblank;
if col1=' padded' then call symputx('checkblank','PASS');
else call symputx('checkblank',cats('FAIL:',col1));
run;
%mp_assert(
iftrue=(&checkblank=PASS),
desc=ms_webout FETCH retains leading blanks with $char informat
)
/* same test, but with a plain $ informat (as sent by some clients) */
%let fref3=%mf_getuniquefileref();
data _null_;
file &fref3 lrecl=32767 termstr=crlf;
put 'col1:$10. col2:best.';
put ' padded,1';
run;
%let _webin_fileref=&fref3;
%let _webin_name=leadblank2;
%let _webin_file_count=1;
%ms_webout(FETCH)
data _null_;
set leadblank2;
if col1=' padded' then call symputx('checkblank2','PASS');
else call symputx('checkblank2',cats('FAIL:',col1));
run;
%mp_assert(
iftrue=(&checkblank2=PASS),
desc=ms_webout FETCH retains leading blanks with $ informat
)
+3 -2
View File
@@ -44,6 +44,7 @@ data work.somedata1 work.somedata2;
x=1;
y=' t"w"o';
z=.z;
y2=' two';
label x='x factor';
output;
run;
@@ -58,14 +59,14 @@ run;
%let test1=FAIL;
data _null_;
set testlib1.somedata1;
if x=1 and y=' t"w"o' and z="Z" then call symputx('test1','PASS');
if x=1 and y=' t"w"o' and z="Z" and y2=' two' then call symputx('test1','PASS');
putlog (_all_)(=);
run;
%let test2=FAIL;
data _null_;
set testlib1.somedata2;
if x=1 and y=' t"w"o' and z="Z" then call symputx('test2','PASS');
if x=1 and y=' t"w"o' and z="Z" and y2=' two' then call symputx('test2','PASS');
putlog (_all_)(=);
run;