Skip to content

[cli] add --sqlite param #956

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

Merged
merged 1 commit into from
Aug 25, 2023
Merged

[cli] add --sqlite param #956

merged 1 commit into from
Aug 25, 2023

Conversation

ddol
Copy link
Contributor

@ddol ddol commented Aug 25, 2023

There is a SQLiteDialect but it wasn't available as a cli parameter.

I'm running the following query cargo run --features json_example --example cli /tmp/some.sql --sqlite

on main:

david@hydra sqlparser-rs % cargo run --features json_example --example cli /tmp/some.sql --sqlite
   Compiling sqlparser v0.37.0 (/Users/david/code/sqlparser-rs)
    Finished dev [unoptimized + debuginfo] target(s) in 0.53s
     Running `target/debug/examples/cli /tmp/some.sql --sqlite`
thread 'main' panicked at 'Unexpected parameter: --sqlite', examples/cli.rs:51:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

on ddol--cli-add-sqlite:

david@hydra sqlparser-rs % cargo run --features json_example --example cli /tmp/some.sql --sqlite
    Finished dev [unoptimized + debuginfo] target(s) in 0.06s
     Running `target/debug/examples/cli /tmp/some.sql --sqlite`
Parsing from file '/tmp/some.sql' using SQLiteDialect
2023-08-25T03:58:26.462Z DEBUG [sqlparser::parser] Parsing sql 'select 1;'...
2023-08-25T03:58:26.462Z DEBUG [sqlparser::parser] parsing expr
2023-08-25T03:58:26.462Z DEBUG [sqlparser::parser] prefix: Value(Number("1", false))
2023-08-25T03:58:26.462Z DEBUG [sqlparser::parser] get_next_precedence() TokenWithLocation { token: SemiColon, location: Location { line: 0, column: 0 } }
2023-08-25T03:58:26.462Z DEBUG [sqlparser::parser] 0: ; 1: EOF 2: EOF
2023-08-25T03:58:26.462Z DEBUG [sqlparser::parser] next precedence: 0
Round-trip:
'SELECT 1'
Serialized as JSON:
[
  {
    "Query": {
      "with": null,
      "body": {
        "Select": {
          "distinct": null,
          "top": null,
          "projection": [
            {
              "UnnamedExpr": {
                "Value": {
                  "Number": [
                    "1",
                    false
                  ]
                }
              }
            }
          ],
          "into": null,
          "from": [],
          "lateral_views": [],
          "selection": null,
          "group_by": [],
          "cluster_by": [],
          "distribute_by": [],
          "sort_by": [],
          "having": null,
          "named_window": [],
          "qualify": null
        }
      },
      "order_by": [],
      "limit": null,
      "offset": null,
      "fetch": null,
      "locks": []
    }
  }
]
david@hydra sqlparser-rs %

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

LGMT -- thank you @ddol

@coveralls
Copy link

Pull Request Test Coverage Report for Build 5971698570

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 56 unchanged lines in 5 files lost coverage.
  • Overall coverage decreased (-0.1%) to 87.222%

Files with Coverage Reduction New Missed Lines %
src/ast/mod.rs 1 78.74%
tests/sqlparser_postgres.rs 1 98.0%
tests/sqlparser_mysql.rs 2 99.35%
tests/sqlparser_common.rs 16 96.79%
src/lib.rs 36 12.03%
Totals Coverage Status
Change from base Build 5938809737: -0.1%
Covered Lines: 16198
Relevant Lines: 18571

💛 - Coveralls

@alamb
Copy link
Contributor

alamb commented Aug 25, 2023

I believe the clippy failure is due to a newer version of clippy and not anything related to this PR. I will fix it separately

@alamb alamb merged commit 4a2fa66 into apache:main Aug 25, 2023
@alamb
Copy link
Contributor

alamb commented Aug 25, 2023

Clippy fixes in #957

Thanks again for the contribution @ddol

@ddol ddol deleted the ddol--cli-add-sqlite branch August 25, 2023 22:58
serprex pushed a commit to serprex/sqlparser-rs that referenced this pull request Nov 6, 2023
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.

3 participants