I have identified what I believe to be a bug in the above package. I was using it in a call to a straightforward backend function which inserts a record into a Member collection. Originally, the code looked like this:
export async function memberInsert(emailstring, forenamestring, surnamestring) {
try {
const results = await sql(‘INSERT INTO Member(notifiedEmail, surname, forename) VALUES ("’ + emailstring + ‘“,”’ + forenamestring + ‘“,”’ + surnamestring + ‘")’);
} catch (error) {
console.log(error);
}
}
I tried building the sql command as a string and logging it and to my eye it looked fine as shown below
INSERT INTO Member( notifiedEmail, surname, forename) VALUES(“value1”,“value2”,“value3” )
When called, the function inserted a row into the collection but all three values were concatenated as shown below and written to the notifiedEmail column:
value1",“value2”,"value3
I managed to achieve the desired result but adding a trailing space after the commas in the sql command …
const results = await sql(‘INSERT INTO Member(notifiedEmail, surname, forename) VALUES ("’ + emailstring + ‘", "’ + forenamestring + ‘", "’ + surnamestring + ‘")’);
which in mean the sql command becomes:
INSERT INTO Member( notifiedEmail, surname, forename) VALUES(“value1”, “value2”, “value3” )
It doesn’t make sense to me that the trailing spaces have to be included to ensure that the sql string is interpreted correctly.