-
Notifications
You must be signed in to change notification settings - Fork 17
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
how to upgrade pg_query? #9
Comments
I was able to download https://github.com/lfittl/libpg_query and compile a new archive file. I then copy the cp ../libpg_query/libpg_query.a libpg_query/osx/ # I would definitely do linux once I figure out osx
cp ../libpg_query/pg_query.h libpg_query/include/ Then install, build and test yarn install
yarn build
yarn test test fails - any clue what I need to do in this process?
|
update: I got tests to pass! However, this would seemingly be major breaking changes. The update introduces var query = require('../');
var assert = require('assert');
describe('pg-query', function() {
it('should parse a query', function() {
assert.equal(typeof query.parse('select 1').query[0].RawStmt.stmt.SelectStmt, 'object');
});
it('should parse a null', function() {
assert(query.parse("select null").query[0].RawStmt.stmt.SelectStmt.targetList[0].ResTarget.val.A_Const.val.Null);
});
it('should parse an empty string', function() {
assert(query.parse("select ''").query[0].RawStmt.stmt.SelectStmt.targetList[0].ResTarget.val.A_Const.val.String.str === '');
});
it('should not parse a bogus query', function() {
assert.ok(query.parse('NOT A QUERY').error instanceof Error);
});
}); |
@pyramation Yeah, unfortunately the RawStmt change was one in upstream Postgres with 10, so its not really something that can be avoided. For better or worse, Postgres parse trees are not supposed to be consistent across versions, which is why this would happen again in the next release (i.e. 11). |
Thanks @lfittl, I see. I suppose people should just tag versions for this repo... what's a good way to deal with this? fwiw, the tests are passing: https://travis-ci.org/pyramation/node-pg-query-native/builds/414224051 Should I still make a PR? |
here's my PR: #10 |
@pyramation Yeah, in general I would consider upgrading the parser version to be a major version increment on this library, and expect people to upgrade to that version whenever they are ready. Unfortunately no better way to deal with this that I have found :) |
@pyramation Since there's no response from @zhm, will you do the honour to publish a new npm package for this - with different name, since this is breaking change anyway. |
And BTW, this module will break when npm install in node 10.x - need to update the |
I already did!
I have two repos, one is the new name: https://github.com/pyramation/pgsql-parser |
@beeing I upgraded pg_query, overhauled the testing system, and added a TON of new functionality. I think well over 100 commits from master. |
Underneath, I also had to fork pg-query-native, https://github.com/pyramation/node-pg-query-native for now I just called it pg-query-native-latest: https://github.com/pyramation/pg-query-parser/blob/master/package.json#L59 |
Ah... that's nice. Must have missed this out. Thanks! |
I just |
Just out of curiosity, how about removing the RawStmt.stmt after parsing it to maintain the backward compatibility? And BTW, do you able to add Issues in your forked repo as well? We can use your repo to file new issues going forward. |
@beeing Just one thought re: removing RawStmt.stmt for compatibility - I wouldn’t recommend this for two reasons:
Unfortunately its not preventable to have incompatible parse trees across versions - thats the same way that Postgres internally handles these structures. |
Point noted. Thanks for sharing @lfittl |
the version of pg_query is old and cannot parse quite a few statements now that are valid.
I'm happy to help and make a PR, are can somebody provide some insight on where to start?
The text was updated successfully, but these errors were encountered: