mariadb-corporation / mariadb-connector-nodejs

MariaDB Connector/Node.js is used to connect applications developed on Node.js to MariaDB and MySQL databases. MariaDB Connector/Node.js is LGPL licensed.
GNU Lesser General Public License v2.1
366 stars 91 forks source link

FieldInfo type is missing `length` property #226

Closed GingerAdonis closed 1 year ago

GingerAdonis commented 1 year ago

The documentation has a type-casting example like below. But the column argument doesn't have the length property typed, which is probably a mistake.

const typeCastFunction = (column, next) => {
  if (column.type == "TINY" && column.length === 1) {
    const val = column.int();
    return val === null ? null : val === 1;
  }
  return next();
};

And a more generic question: Wouldn't it make sense to refactor the whole project to Typescript to prevent this and other typing mistakes from occurring?

rusher commented 1 year ago

Thanks for pointing that out, documentation has been corrected with this commit, see result.

Column have no length property, but columnLength

Additionally, decoding functions have been added to documentation.

TypeScript would have been a solution at the beginning. This would be a big refactor that is not on a schedule for now.