Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added types implementation #77

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion lib/itoolkit.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,29 @@ class iSql {
}
}


exports.types = {
char(length) {
return length.toString() + "A";
},
packed(digits, delimiter) {
return digits.toString() + "P" + delimiter.toString();
},
zoned(digits, delimiter) {
return digits.toString() + "S" + delimiter.toString();
},
Comment on lines +576 to +581
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest changing digits and delimiter to something more descriptive. SQL uses the terms precision and scale, though some may find that confusing. Perhaps total_digits and decimal_digits would be more appropriate?

signed(digits, delimiter) {
return digits.toString() + "I" + delimiter.toString();
},
unsigned(digits, delimiter) {
return digits.toString() + "U" + delimiter.toString();
},
Comment on lines +582 to +587
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, XMLSERVICE doesn't support integer types with scale, so the delimiter must always be 0 and is thus unnecessary.

Also, I'd also like to have separate functions for each type/length that would need no parameters, eg. signed_byte, signed_short, signed_int, signed_bigint, etc..

float(digits, delimiter) {
return digits.toString() + "F" + delimiter.toString();
Comment on lines +588 to +589
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather see separate float and double functions which take no parameters and return "4F2" and "8F4", respectively.

Aside: I'm not sure why XMLSERVICE wants 4F2 and 8F4, when RPG says the decimal digits field must be blank (and would be 4F and 8F, respectively).

},
binary(length) {
return length.toString() + "B";
}
};

exports.iConn = iConn;
exports.iCmd = iCmd;
Expand Down