Git Product home page Git Product logo

pg_parse's People

Contributors

ankane avatar haileys avatar paupino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pg_parse's Issues

Investigate extrapolating pg source directly

There may be a way to reduce dependencies further as well as reduce layers of complexity, by extrapolating the pg source directly. This could perhaps leverage the ruby script that libpg_query already uses.

Parsing fails to parse Lists in ResTarget nodes

Summary:

For example queries with lists of values like INSERT INTO contacts.person(name, ssn) VALUES ($1, $2), parse() fails with an error of:

unknown variant `List`, expected one of <every variant of Node>

How to fix it:

As far as I can tell, this is a consequence of treating every List as an Option<Vec<Node>>, which works most of the time, but not in this specific case of parsing lists of params in ResTarget nodes.

I've included a hacky fix on my fork of pg_query.rs that special-cases List and creates a List struct with an items field, similar to how List is handled in the go library, and creates a separate List variant of Node. This solves the issue for the test case above.

If this โ˜๏ธ approach is acceptable, let me know and I'll put together a PR. A downside to this approach is the split treatment of List across the codebase: in most cases, it becomes an Option<Vec<Node>> (see the other existing parsing tests), but not in the case of e.g. VALUES lists. This doesn't bother me too much for my particular use-case, but would be surprising from someone used to the go implementation's approach of using List everywhere instead of Node[]. A different implementation might be to use a separate List type like the one I've hacked into the build script, but implement IntoIterator and ExactSizedIterator and friends to make working with List exactly like working with Vec<Node> for backwards-compatibility.

Thanks for creating this crate, and let me know how you'd like to proceed!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.