sidorares / sidorares/node-mysql2

Explain the intention of the test-binary-notnull-nulls test

Open
#306 2 comments 0 reactions 1 assignee View on GitHub

@sidorares is already working on this.

Since May 8, 2016.

question
Dominant language
TypeScript
Stars
4.4k
Forks
680
Avg merge
9h 7m
Merged PRs (30d)
59

Description

I am trying to fix the failing test cases, but I cannot wrap my head around some, e.g. test-binary-notnull-nulls.

First,

fields[0].flags & FieldFlags.NOT_NULL

From: https://github.com/sidorares/node-mysql2/blob/e83efa4c561eb28f7de6aa9349764a265c1f1148/test/integration/connection/test-binary-notnull-nulls.js#L46

FieldFlags.NOT_NULL is 1 (a harcoded value), this will always be true. If you want to check that column is no nullable, then why not use IS?, e.g.

conn.execute("SELECT IS_NULLABLE FROM INFORMATION_SCHEMA.COLUMNS WHERE `table_schema`=DATABASE() AND `table_name` = 'tmp_account' AND `column_name`='username'", function (error, informationSchemaRows) {
  var usernameIsNullable = informationSchemaRows[0].IS_NULLABLE === 'YES';

Second rows[0][fields[0].name] === null (https://github.com/sidorares/node-mysql2/blob/e83efa4c561eb28f7de6aa9349764a265c1f1148/test/integration/connection/test-binary-notnull-nulls.js#L47).

Username is not null. Either the setup query is wrong or the assertion query is wrong. This could also have to do with the sql_mode=only_full_group_by introduced in 5.7. Though, if the previous behaviour relied on ANY_VALUE(), this would have been failing for a long time.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.