GithubHelp home page GithubHelp logo

Parse queries into objects about floor HOT 8 OPEN

pinchbv avatar pinchbv commented on July 21, 2024
Parse queries into objects

from floor.

Comments (8)

simolus3 avatar simolus3 commented on July 21, 2024 4

I've written https://pub.dev/packages/sqlparser, which is a pure-Dart sql parser and static analyzer. Originally, it was written for another project, but it might be helpful to this library as well. It can turn any sql query into an AST (so you know whether it is an insert/update/select/etc.), so you could just do

final engine = SqlEngine();
print(engine.parse('SELECT * FROM tbl').rootNode is SelectStatement) // true

If you know the table structure at build-time, you can also register available tables to the sql engine by adding them to SqlEngine.knownTables. Then, SqlEngine.analyze can be used to figure out what's returned by queries and it can resolve the type of variables in the query.

from floor.

vitusortner avatar vitusortner commented on July 21, 2024 2

This looks awesome and seems to be the right fit for the library's needs. Thanks @simolus3!

from floor.

dkaera avatar dkaera commented on July 21, 2024 1

Many thanks to @simolus3 for the SQL parser, it saved a lot of time to solve this issue.
PR #733

from floor.

 avatar commented on July 21, 2024

The Query needs to return simple data. (int, String, double, bool)

from floor.

vitusortner avatar vitusortner commented on July 21, 2024

Parsing SQL queries seems more tricky than expected. Unluckily I didn't find a package that could help with that.

from floor.

cw-dev avatar cw-dev commented on July 21, 2024

You might be interested in https://github.com/AlecStrong/sqlite-psi

It’s the backend for https://github.com/square/sqldelight

from floor.

vitusortner avatar vitusortner commented on July 21, 2024

@cw-dev thanks, I'll take a look at it!

from floor.

vladimirfx avatar vladimirfx commented on July 21, 2024

As now is any way to do partial updates? With UPDATE queries or like Room's 2.2 partial updates.

from floor.

Related Issues (20)

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.