Skip to content

Conversation

@tmont
Copy link
Contributor

@tmont tmont commented Jul 10, 2018

Pull Request check-list

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

Raw queries to the sqlite_master table were being special-cased and as such would return inconsistent values. For example, SELECT * FROM sqlite_master would simply return an array populated with just the value in the name column. This change allows you to query the sqlite_master just like any other table, and removes hardcoded SQL string checks in favor of using the QueryTypes enum.

This is related to #1612 and #8769. Previous workarounds were to shove the sqlite_master table into a view so that its table name wouldn't be caught by the indexOf check and query the view instead.

This changeset also fixes a DataTypes test that was failing due to timezone issues.

@codecov
Copy link

codecov bot commented Jul 10, 2018

Codecov Report

Merging #9645 into master will increase coverage by <.01%.
The diff coverage is 100%.

let createTableSql;

return this.sequelize.query(describeCreateTableSql, options)
return this.sequelize.query(describeCreateTableSql, { type: QueryTypes.SELECT, raw: true })
Copy link
Contributor

Choose a reason for hiding this comment

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

We should pass other options, probably { type: QueryTypes.SELECT, raw: true, ...options }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That seemed to make things fail (although I never did try to figure out why). options was always something like

{ type: 'unique', fields: [ 'email' ] }

I believe options is meant to be the options to create the constraint, not just general query options. Are there some specific properties I could pick out? I wasn't really sure of what the possibilities were.

@sushantdhiman sushantdhiman merged commit 31113ce into sequelize:master Jul 14, 2018
@tmont
Copy link
Contributor Author

tmont commented Jul 15, 2018

@sushantdhiman You probably already realized this, but it just occurred to me that this will be a breaking change for any query that involves the string sqlite_master for the sqlite dialect. So it probably can't be backported to v4.x (if that was even under consideration).

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.

2 participants