|
Bradley
TrimRight() is NOT a ECMA standard :-(
But it is not a big problem to write javascript that does the trick, here
is my solution that
also works on sub sections og the main object.
async function datasetTrim(obj, leaveAsIs, forceNum) {
if (leaveAsIs === undefined) leaveAsIs = []
if (typeof leaveAsIs === "string") leaveAsIs = [leaveAsIs]
if (forceNum === undefined) forceNum = []
if (typeof forceNum === "string") forceNum = [forceNum]
for (var property in obj) {
if (obj.hasOwnProperty(property)) {
if(obj[property] instanceof Array) {
await datasetTrim(obj[property], leaveAsIs, forceNum)
} else {
if(obj[property] instanceof Object) {
await datasetTrim(obj[property], leaveAsIs, forceNum)
} else {
if (leaveAsIs.indexOf(property) >= 0) continue
if (typeof obj[property] !== 'string') continue
if (isNaN(obj[property]) === false &&
obj[property].trim() != '') {
obj[property] = parseFloat(obj[property])
} else {
obj[property] = obj[property].replace(/ \s/g, '')
if (forceNum.indexOf(property) >= 0 &&
obj[property] == '')
obj[property] = 0
}
}
}
}
}
}
On Sat, Mar 24, 2018 at 7:46 PM, Bradley Stone <bvstone@xxxxxxxxx> wrote:
I wrote a set of nodejs functions that add this feature.. Not tooCloud
difficult at all.
trimming is trivial in node
for (var key in dataObject) {
keyCount++;
var dataValue = dataObject[key].trimRight();
.....
In fact, I use this to trim an entire row when returning a result set
function trimRow(row) {
for (i in row) {
row[i] = row[i].trimRight();
}
return row;
}
for (row in resultSet) {
trimRow(resultSet[row]);
}
I have a set of DB functions that encapsulate the IBM stuff, and this is
how I do it now... I just had to rewrite it for node6 and async so still
in testing, but this part still works.
www.bvstools.com
Native IBM i e-Mail solutions for Microsoft Office 365, Gmail, or any
Provider!have
On Sat, Mar 24, 2018 at 12:36 PM, Nathan Andelin <nandelin@xxxxxxxxx>
wrote:
Niels,
Could you clarify? Are you suggesting that somebody submit an RFE to
inIBM add new SQL connection settings that implement the desired "trim"
behaviors?
Nathan.
On Sat, Mar 24, 2018 at 9:08 AM, Niels Liisberg <nli@xxxxxxxxxxxxxxxxx
wrote:since
At better solution would be: set the trim option on the connection
wouldthat is already IBM proprietary . Doing it on the select statement
pollute the sql syntax.
Why don't you raise a RFE for both trimming and sql-alike data types
100the
result-set. I think my friend Jesse Gorzinsky would love that.
lør. 24. mar. 2018 kl. 15.52 skrev Henrik Rützou <hr@xxxxxxxxxxxx>:
Nathan
a lazy programmer (and I'm one) is a programmer that dosn't code
nandelin@xxxxxxxxx>;-)similar programs from one end to the other - they have fun making a
program generator that then does the job they do not bother to make
On Sat, Mar 24, 2018 at 3:10 PM, Nathan Andelin <
RESTconnotation,wrote:
Henrik,
The term "lazy programmer" is sometimes used with negative
faultand
other times used with positive connotation. In this case, I don't
includingprogrammers who would rather not code the full SQL statement,
rtrim() function calls required to trim fields.
I was just trying to say that this is a case where invoking a
thatwebAPI
ofttimesservice API would provide a simpler interface for programmers. A
web-service API would relieve programmers of the verbosity and
complexity of coding their own SQL statements.
I'm just suggesting that this is a case where a REST web service
wouldwrote:
have advantages over Node's db2a interface.
On Sat, Mar 24, 2018 at 7:41 AM, Henrik Rützou <hr@xxxxxxxxxxxx>
Nathan
you may call it lazy to want to have a transparent interface
removedhasn't
toresultsets
be
touched every time you add a new or remove a column to a table.
Especially removing a column will cause errors if you specify
by specific field names, imho they sould automatically be
mailingfieldfrom
the rest service and that should automatically result in the
fromare
removed
in the UI regardless of code defining the field may exsist.
We are back to constructing an UI where if you filter the SSN
mailingmailingUserAappears -
it dosn't appear in his UI but dons't filter it from UserB it
mailingboth running--
on the same code.
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400)
list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.
--
Regards,
Henrik Rützou
http://powerEXT.org <http://powerext.org/>
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400)
listBest regards
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.
--
Niels Liisberg
Chief Software Architect
System & Method A/S
Phone +45 70 20 30 10
Mobile + 45 31 15 88 61
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400)
list--
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400)
list--
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.
--
Regards,
Henrik Rützou
http://powerEXT.org <http://powerext.org/>
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.