Skip to content

Comments

chore: using mysql2 as library for serverless-mysql#374

Open
andreabadesso wants to merge 1 commit intomasterfrom
chore/use-mysql2
Open

chore: using mysql2 as library for serverless-mysql#374
andreabadesso wants to merge 1 commit intomasterfrom
chore/use-mysql2

Conversation

@andreabadesso
Copy link
Collaborator

Motivation

The last update of the mysql library we were using was in Jan 23, 2020

Acceptance Criteria

  • We should use mysql2 as the library for serverless-mysql (mysql is the default)
  • We should remove the mysql dependency

Security Checklist

  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.

`SELECT \`tx_id\`,
\`token_id\`,
SUM(\`balance\`) AS balance,
CAST(SUM(\`balance\`) AS INTEGER) AS balance,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

mysql2 is returning SUM, MIN and MAX as strings, so we can either cast it on mysql itself or on javascript, with parseInt, I prefer doing it directly in mysql

Copy link
Member

Choose a reason for hiding this comment

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

Casting to integer is fine but the SUM returns a DECIMAL (which the client converts to a string) because of a posible overflow and precision issues. Maybe we should check no cast has this problem, like a sum of output values that can go over the mysql native integer highest number.

"": {
"name": "hathor-wallet-service",
"version": "1.23.0-beta",
"version": "1.23.1-beta",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The last bump didn't update this, totally unrelated to the PR

Copy link
Member

@r4mmer r4mmer left a comment

Choose a reason for hiding this comment

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

There are some warnings like "Argument 'mysql' should be typed" which can be fixed if we use the mysql2 types

`SELECT \`tx_id\`,
\`token_id\`,
SUM(\`balance\`) AS balance,
CAST(SUM(\`balance\`) AS INTEGER) AS balance,
Copy link
Member

Choose a reason for hiding this comment

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

Casting to integer is fine but the SUM returns a DECIMAL (which the client converts to a string) because of a posible overflow and precision issues. Maybe we should check no cast has this problem, like a sum of output values that can go over the mysql native integer highest number.

@luislhl luislhl changed the base branch from dev to master April 21, 2023 12:41
@tuliomir tuliomir removed their request for review July 7, 2023 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants