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
feat(dependency): Support pg version 7 #7888
Conversation
@felixfbecker No idea why the tests fail :/ |
docs/usage.md
Outdated
@@ -201,7 +201,7 @@ const sequelize = new Sequelize('sqlite:relativePath/dbname.db') | |||
|
|||
### PostgreSQL | |||
|
|||
The library for PostgreSQL is`pg@~3.6.0` You'll just need to define the dialect: | |||
The library for PostgreSQL is`pg@~6.1.0` You'll just need to define the dialect: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7
doesnt match ~6.1.0
. The whole range of supported versions should be documented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well it's not released yet. Might confuse some people O.o
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see anything wrong with documenting that both 6 and 7 are supported. Otherwise someone will have to update this documentation once 7 is out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. does pg@>=6.1.0
make more sense or pg@^6.1.0 || ^7.0.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say the latter, there is a high chance we won't support 8.0 when it comes out
@felixfbecker I skipped ci, have a final look and lemme know if everything's alright. |
@alitaheri that doesn't work for PRs, you need the status check for the last commit ;) |
Ops sorry 😅 😅 |
Any idea what release this might make it out on? 4.x or backported? |
@contra as soon as it's merged into master, it will be released as 4.x |
@felixfbecker Cool, thanks for the speedy response. |
Sorry, there are merge conflicts. You probably just need to rebase your version and run |
28773ab
to
c4b0cbf
Compare
@felixfbecker It's done. please rerun the tests. thanks 😁 |
@felixfbecker Any chance we can merge this as is? 😁 😅 |
Don't ask me, I approved - need more than 1 review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we somehow check that the right version of pg is installed? Releasing this as a minor might break for some people on old versions of pg that don't support promises (it's an obvious break, but still a break)
@janmeier The version compatible ( v6.1.0 ) is almost a year old now. If people are upgrading sequelize to v4 I'm sure they've long upgraded pg to v6.1.0 😅 |
Roger that :) |
|
||
type.types.postgres.oids.push(row.oid); | ||
type.types.postgres.array_oids.push(row.typarray); | ||
return connection.query(query).then(result => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is nested .then()
handler and could be moved one level higher
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@felixfbecker Could you elaborate on that? Do you mean I should return query and continue the upper promise chain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah.
bad:
return foo().then(() => {
return bar().then(() => {
return baz()
})
})
good:
return foo()
.then(() => {
return bar()
})
.then(() => {
return baz()
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@felixfbecker I can't do what you asked. Because it's not a nested then
it's tap
and then
. If I chain the promises then the client won't be returned. Since I hate non-standard promise APIs I'll remove the chaining code and solve it differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hate them too, I don't even know what tap
does 😄
Hmm, but it's still a breaking change if we really did still support 3.x with Sequelize 4.0... Is there a way to make this change backwards-compatible, e.g. by not relying on the promise support? |
@felixfbecker |
I usually just use this oneliner: new Promise((resolve, reject) => conn.query(sql, (err, rows) => err ? reject(err) : resolve(rows))) |
@felixfbecker @janmeier Have a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is much better if this prevents the breaking change! Thanks!
} else if (row.typname === 'geography') { | ||
type = dataTypes.postgres.GEOGRAPHY; | ||
} | ||
return new Promise((resolve, reject) => connection.query(query, (error, result) => error ? reject(error) : resolve([connection, result]))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, resolving with a tuple to maintain the connection is a bit weird. I didn't see that connection
is still needed in scope, I would say in that case the nested promise is okay
docs/usage.md
Outdated
@@ -201,7 +201,7 @@ const sequelize = new Sequelize('sqlite:relativePath/dbname.db') | |||
|
|||
### PostgreSQL | |||
|
|||
The library for PostgreSQL is`pg@~3.6.0` You'll just need to define the dialect: | |||
The library for PostgreSQL is`pg@^6.1.0 || ^7.0.0` You'll just need to define the dialect: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we lower the constraint if we don't use the promise support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would 5.0.0
be ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure how outdated this doc is - maybe you could find out the minimal version that passes the tests? Does pg@3.6.0
even work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@felixfbecker Is that really necessary?
@felixfbecker Done what you've asked. |
Hey y'all - sorry I just saw this! The deprecation of https://node-postgres.com/guides/upgrading#client-query-submittable- +1 for using callbacks or promises though. The callback style should work for every old versions of node-postgres too. If y'all ever run into questions or weird bugs you think are related to node-postgres itself please don't hesitate to open an issue or ping me on twitter. Thanks for all you do here!! ❤️ 🤗 |
@felixfbecker Any reason you haven't merged this yet? We need this change for production 😅 😅 |
Pull Request check-list
Please make sure to review and check all of these items:
npm run test
ornpm run test-DIALECT
pass with this change (including linting)?Description of change
Upgrade pg API usage to be forward compatible with version 7. Also gets rid of the deprecation warning.
Closes #7818