@sasjs/core 7.0.0 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -149,9 +149,15 @@ data _null_;
149
149
  %end;
150
150
  %if &vtype=N %then %do;
151
151
  %if &flavour=SAS %then %do;
152
- put &var;
152
+ /* the value becomes a SQL literal, and PUT writes a special missing
153
+ (.A-.Z, ._) as its letter only - which PROC SQL reads as a column
154
+ name, so the leading period is written first */
155
+ if missing(&var) and &var ne . then put "." &var;
156
+ else put &var;
153
157
  %end;
154
158
  %else %if &flavour=PGSQL %then %do;
159
+ /* Postgres has no special missing values, so any missing numeric
160
+ (including ._ and .A-.Z) is written as NULL */
155
161
  if missing(&var) then put 'NULL';
156
162
  %if &applydttm=YES and "%substr(&vfmt.xxxxxxxx,1,8)"="DATETIME"
157
163
  %then %do;
@@ -575,7 +575,14 @@ select distinct tgtvar_nm into: missvars separated by ' '
575
575
  qstr=quote(trim(NEWVAL_CHAR));
576
576
  put tgtvar_nm '=' qstr;
577
577
  end;
578
- else put tgtvar_nm '=' newval_num;
578
+ else do;
579
+ /* the value becomes a SQL literal, so a special missing (.A-.Z, ._)
580
+ needs its leading period - PUT writes only the letter, which PROC SQL
581
+ reads as a column name */
582
+ put tgtvar_nm '=' @@;
583
+ if missing(newval_num) and newval_num ne . then put "." newval_num;
584
+ else put newval_num;
585
+ end;
579
586
  if comma=' ' then comma=' ,';
580
587
  end;
581
588
  if last.key_hash then put ' where key_hash=trim("' key_hash '");';
@@ -173,6 +173,9 @@ create table &outds as select "No " as _____DELETE__THIS__RECORD_____
173
173
  ;
174
174
 
175
175
  /* create SAS code to apply to stage_ds */
176
+ /* numeric values become SQL literals, so a special missing (.A-.Z, ._) must
177
+ carry its leading period - PUT writes only the letter, which PROC SQL reads
178
+ as a column name */
176
179
  data _null_;
177
180
  set &ds1;
178
181
  file &fref1 lrecl=33000;
@@ -188,6 +191,8 @@ data _null_;
188
191
  cnt=count(oldval_char,'"');
189
192
  charval=quote(trim(substr(oldval_char,1,32765-cnt)));
190
193
  if tgtvar_type='C' then put charval @@;
194
+ else if missing(oldval_num) and oldval_num ne .
195
+ then put "." oldval_num @@;
191
196
  else put oldval_num @@;
192
197
  if not last.is_pk then put ',';
193
198
  end;
@@ -197,6 +202,8 @@ data _null_;
197
202
  cnt=count(oldval_char,'"');
198
203
  charval=quote(trim(substr(oldval_char,1,32765-cnt)));
199
204
  if tgtvar_type='C' then put charval @@;
205
+ else if missing(oldval_num) and oldval_num ne .
206
+ then put "." oldval_num @@;
200
207
  else put oldval_num @@;
201
208
  end;
202
209
  end;
@@ -210,6 +217,8 @@ data _null_;
210
217
  cnt=count(newval_char,'"');
211
218
  charval=quote(trim(substr(newval_char,1,32765-cnt)));
212
219
  if tgtvar_type='C' then put charval @@;
220
+ else if missing(newval_num) and newval_num ne .
221
+ then put "." newval_num @@;
213
222
  else put newval_num @@;
214
223
  end;
215
224
  else if move_type='D' then do;
@@ -221,6 +230,8 @@ data _null_;
221
230
  cnt=count(oldval_char,'"');
222
231
  charval=quote(trim(substr(oldval_char,1,32765-cnt)));
223
232
  if tgtvar_type='C' then put charval @@;
233
+ else if missing(oldval_num) and oldval_num ne .
234
+ then put "." oldval_num @@;
224
235
  else put oldval_num @@;
225
236
  end;
226
237
  else do;
@@ -229,6 +240,8 @@ data _null_;
229
240
  cnt=count(oldval_char,'"');
230
241
  charval=quote(trim(substr(oldval_char,1,32765-cnt)));
231
242
  if tgtvar_type='C' then put charval @@;
243
+ else if missing(oldval_num) and oldval_num ne .
244
+ then put "." oldval_num @@;
232
245
  else put oldval_num @@;
233
246
  end;
234
247
  end;
package/package.json CHANGED
@@ -43,5 +43,5 @@
43
43
  "devDependencies": {
44
44
  "@nogoo9/gitleaks": "8.30.1-post.2"
45
45
  },
46
- "version": "7.0.0"
46
+ "version": "7.0.2"
47
47
  }
@@ -350,7 +350,8 @@ filename &webref "&webrefpath";
350
350
  )
351
351
  %if "&outstatus" ne "0" %then %do;
352
352
  data &outstatus;
353
- length state $20 uri $256 errmsg $256 platform $10;
353
+ length state $20 uri $256 errmsg $32767 platform $10;
354
+ length line $32767;
354
355
  retain state 'completed' uri '' errmsg '' platform 'SASJS' abortseen 0;
355
356
  infile &respref end=eof lrecl=32767;
356
357
  /* scan the whole response - the abort block is not always on the first
@@ -363,10 +364,15 @@ filename &webref "&webrefpath";
363
364
  abortseen=1;
364
365
  end;
365
366
  if abortseen=1 and errmsg='' and index(_infile_,'"MSG"')>0 then do;
366
- /* prxchange returns its input untouched when nothing matches, which
367
- * would put the whole line in errmsg */
368
- if prxmatch('/"MSG" *: *"([^"]*)"/',_infile_) then
369
- errmsg=prxchange('s/.*"MSG" *: *"([^"]*)".*/$1/',-1,_infile_);
367
+ /* a quote inside the message arrives escaped, and the capture below
368
+ * used to stop at it, returning the part before the first \" and
369
+ * dropping the rest. The escaped pairs are unescaped first, so the
370
+ * value is captured whole: the match is greedy and runs to the
371
+ * closing quote of the value rather than to the first quote after
372
+ * the field name. */
373
+ line=tranwrd(_infile_,'\"','"');
374
+ if prxmatch('/"MSG" *: *"(.*)"/',line) then
375
+ errmsg=prxchange('s/.*"MSG" *: *"(.*)".*/$1/',-1,line);
370
376
  end;
371
377
  end;
372
378
  /* one row, whatever the response contained */