From 522a525b96874209c3042cc7e4a543b5bec36d9e Mon Sep 17 00:00:00 2001 From: Pedro Mateo <39684602+pedromateoa@users.noreply.github.com> Date: Mon, 30 May 2022 13:15:24 -0400 Subject: [PATCH 1/3] complete size for date and logical types --- src/structure.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/structure.js b/src/structure.js index 4b02783..19dcf2d 100644 --- a/src/structure.js +++ b/src/structure.js @@ -8,7 +8,13 @@ var fieldSize = require('./fieldsize'), * @returns {Object} view */ module.exports = function structure(data, meta) { - + if(meta){ + // + meta.forEach(x => { + if (x.type == 'D') x.size = 8 + if (x.type == 'L') x.size = 1 + }); + } var field_meta = meta || fields.multi(data), fieldDescLength = (32 * field_meta.length) + 1, bytesPerRecord = fields.bytesPer(field_meta), // deleted flag @@ -52,7 +58,7 @@ module.exports = function structure(data, meta) { view.setInt8(32 + i * 32 + 11, f.type.charCodeAt(0)); // field length view.setInt8(32 + i * 32 + 16, f.size); - if (f.type == 'N') view.setInt8(32 + i * 32 + 17, 3); + if (f.type == 'N') view.setInt8(32 + i * 32 + 17, f.decs || 0); }); offset = fieldDescLength + 32; From 5f8e0bb3868424072d02d0085eb78c1f452fc4a4 Mon Sep 17 00:00:00 2001 From: Pedro Mateo <39684602+pedromateoa@users.noreply.github.com> Date: Mon, 30 May 2022 13:16:47 -0400 Subject: [PATCH 2/3] Update structure.js --- src/structure.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structure.js b/src/structure.js index 19dcf2d..53645bf 100644 --- a/src/structure.js +++ b/src/structure.js @@ -58,7 +58,7 @@ module.exports = function structure(data, meta) { view.setInt8(32 + i * 32 + 11, f.type.charCodeAt(0)); // field length view.setInt8(32 + i * 32 + 16, f.size); - if (f.type == 'N') view.setInt8(32 + i * 32 + 17, f.decs || 0); + if (f.type == 'N') view.setInt8(32 + i * 32 + 17, f.decs || 0); // include decimals }); offset = fieldDescLength + 32; From d0005f4216ea39651830c57817e0ddc9bce371ca Mon Sep 17 00:00:00 2001 From: Pedro Mateo <39684602+pedromateoa@users.noreply.github.com> Date: Mon, 13 Jun 2022 08:34:13 -0400 Subject: [PATCH 3/3] trying logical values it only evaluates that val is not empty, it could be if it is true if val=='t', otherwise all false --- src/structure.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structure.js b/src/structure.js index 53645bf..dcf7ab1 100644 --- a/src/structure.js +++ b/src/structure.js @@ -74,7 +74,7 @@ module.exports = function structure(data, meta) { switch (f.type) { // boolean case 'L': - view.setUint8(offset, val ? 84 : 70); + view.setUint8(offset, val == 't' ? 84 : 70); offset++; // it only evaluates that val is not empty, it could be if it is true if val=='t', otherwise all false offset++; break;