Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meta: unify attributesToSQL test and type attributesToSQL and attributeToSQL #15533

Closed
wants to merge 20 commits into from

Conversation

WikiRik
Copy link
Member

@WikiRik WikiRik commented Jan 6, 2023

Pull Request Checklist

  • Have you added new tests to prevent regressions?
  • If a documentation update is necessary, have you opened a PR to the documentation repository?
  • Did you update the typescript typings accordingly (if applicable)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Does the name of your PR follow our conventions?

Description Of Change

Just like #15526 this PR is smaller than the others. I just want to get rid of the dialect specific QueryGenerator unit tests and doing it properly just gets me in a too big of a rabbit hole. Future PRs should migrate attributesToSQL and attributeToSQL and overhaul the test suite.

@WikiRik WikiRik marked this pull request as ready for review January 9, 2023 08:41
@WikiRik WikiRik marked this pull request as draft March 12, 2023 10:24
@WikiRik WikiRik marked this pull request as ready for review March 12, 2023 11:01
@WikiRik WikiRik requested review from ephys and removed request for ephys March 12, 2023 11:03
packages/core/src/dialects/abstract/query-generator.d.ts Outdated Show resolved Hide resolved
packages/core/src/dialects/ibmi/query-generator.js Outdated Show resolved Hide resolved
packages/core/src/dialects/ibmi/query-generator.js Outdated Show resolved Hide resolved
packages/core/src/dialects/mssql/query-generator.js Outdated Show resolved Hide resolved
packages/core/src/dialects/abstract/query-generator.d.ts Outdated Show resolved Hide resolved
});
});

// TODO: check what this test is supposed to do and update the possible defaultValue accordingly
Copy link
Member

Choose a reason for hiding this comment

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

This test is broken and should be split into multiple tests:

  • One that uses DataTypes.ARRAY (on dialects that support this type) with an empty array: should work
  • One that uses DataTypes.BLOB: should never work, [] is not a valid value on a blob
  • One that uses DataTypes.JSON (on dialects that support this type) : should always work
  • One that uses any string type (like 'JSON' instead DataTypes.JSON): should never work because can't guess the type of an empty array and string types don't give any information

Note that the data type is an actual data type and not a string in the above two tests

});

// TODO: this test is broken for at least DB2. It adds the default value because the data type is a string, which can't have special behaviors.
// change type to an actual Sequelize DataType & re-enable
Copy link
Member

Choose a reason for hiding this comment

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

In this instance it's honestly default that's broken. String types don't give any information so the default value should always be added.

If DataTypes.BLOB were used, then the dialect could enforce specific behaviors

});
});

// TODO: check what this test is supposed to do and update the possible defaultValue accordingly
Copy link
Member

Choose a reason for hiding this comment

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

Same remarks as the above three review notes:

Because the type is a string instead of an instanceof DataType, no special behavior can occur. We use string data types as-is, it's the equivalent of using a literal()
This test should use DataTypes.TEXT instead

An array is also not a good type to use to test that the default value is not added: A string would be a better value

});
});

// TODO: check what this test is supposed to do and update the possible defaultValue accordingly
Copy link
Member

Choose a reason for hiding this comment

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

same

});

// TODO: check what this test is supposed to do and update the possible defaultValue accordingly
it(`No Default value for JSON allowed for some dialects`, () => {
Copy link
Member

Choose a reason for hiding this comment

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

same

@WikiRik WikiRik marked this pull request as draft March 12, 2023 13:42
@WikiRik
Copy link
Member Author

WikiRik commented Apr 12, 2024

Superseded by and linked in #17121

@WikiRik WikiRik closed this Apr 12, 2024
@WikiRik WikiRik deleted the WikiRik/attributes-to-sql-unit-tests branch April 12, 2024 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants