Giter VIP home page Giter VIP logo

gql's People

Contributors

0xflotus avatar amrdeveloper avatar byron avatar daemo00 avatar debbl avatar dubaaron avatar gabrielsroka avatar lilit0x avatar mobley-trent avatar morgante avatar se-omar avatar szaydel avatar tbro 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gql's Issues

Use `cargo clippy` in project

Is your feature request related to a problem? Please describe.
Not a major blocker, but it would be great to include clippy to avoid bugs and standardize code style.

For example, the code below is blocked by clippy::derive_ord_xor_partial_ord lint (details)

impl Ord for Value {

Based on std::cmp::Ord's documentation,

Trait for types that form a total order.

Implementations must be consistent with the PartialOrd implementation, and ensure max, min, and clamp are consistent with cmp:

partial_cmp(a, b) == Some(cmp(a, b)).
...
It’s easy to accidentally make cmp and partial_cmp disagree by deriving some of the traits and manually implementing others.

And the current Ord impl for Value in gitql-ast violates the above requirements with the test case below,

let v1 = Value::Integer(1);
let v2 = Value::Boolean(true);
assert_eq!(Some(v1.cmp(&v2)), v1.partial_cmp(&v2)); // failed, `Some(Equal)` vs `Some(Less)`

Another thing: in gitql-ast crate alone, clippy outputs below (most of them are needless_return), which is quite concerning,

warning: `gitql-ast` (lib) generated 74 warnings
error: could not compile `gitql-ast` (lib) due to previous error; 74 warnings emitted

Describe the solution you'd like

  • Add cargo clippy step in GitHub Actions (fail if it produces warnings and above)
  • Fix clippy issues
  • Reconsider implementation of PartialOrd and Ord for Value in gitql-ast

Describe alternatives you've considered
None

Additional context
None

Incorrect statement for CASE in documentation

Describe the bug

Incorrect statement for CASE in documentation

To Reproduce

// https://github.com/AmrDeveloper/GQL/blob/master/docs/expression/case.md
SELECT name FROM branches WHERE (CASE WHERE isRemote THEN 1 ELSE 0 END) > 0

Expected behavior

SELECT name FROM branches WHERE (CASE WHEN isRemote THEN 1 ELSE 0 END) > 0 // replace WHERE with WHEN

GQL (please complete the following information):

Version 0.13.0

Screenshots

FireShot Capture 136 - Case - Git Query language - amrdeveloper github io

Incorrect expr_type for ArithmeticExpression

Describe the bug

Incorrect expr_type for ArithmeticExpression

To Reproduce

// https://github.com/AmrDeveloper/GQL/blob/master/crates/gitql-ast/src/expression.rs
 let express = ArithmeticExpression {
            left: Box::new(NumberExpression {
                value: Value::Integer(1),
            }),
            operator: ArithmeticOperator::Plus,
            right: Box::new(NumberExpression {
                value: Value::Float(1.0),
            }),
 };

 let scope = Enviroment {
            globals: Default::default(),
            globals_types: Default::default(),
            scopes: Default::default(),
};

let ret = express.expr_type(&scope);
assert_eq!(ret.is_float(), true); // fails

Expected behavior

assert_eq!(ret.is_float(), true);  // ret is true

GQL (please complete the following information):

Version 0.11.0

Screenshots

expression.rs

Implement SQL String functions with documentations

Implement string function in our engine, one per pull request.

Steps:

  • Choose unimplemented function and write I am on <function_name>.
  • Then start implement the function in crates/gitql-ast/function.rs.
  • Add docs for it in docs/function/function.md.
  • Make sure everything is formatted and submit a Pull Request.
  • Don't forget to mention issue number in pull request title.

Text Functions

  • ASCII
  • CHAR
  • CHARINDEX
  • CONCAT
  • DATALENGTH
  • DIFFERENCE
  • FORMAT
  • LEFT
  • LEN
  • LOWER
  • LTRIM
  • NCHAR
  • PATINDEX
  • QUOTENAME
  • REPLACE
  • REPLICATE
  • REVERSE
  • RIGHT
  • RTRIM
  • SOUNDEX
  • SPACE
  • STR
  • STUFF
  • SUBSTRING
  • TRANSLATE
  • TRIM
  • UNICODE
  • UPPER

For more information about implementation and description check https://www.w3schools.com/sql/sql_ref_sqlserver.asp

Note: You can only open max 3 PR at the time

Allow to see the commit id when selecting from the commits table

Is your feature request related to a problem? Please describe.
I would like to see the id of the commits table

Describe the solution you'd like
Adding a "commit_id" column to the commits table would probably do it

Describe alternatives you've considered
I don't see any other alternatives

Additional context
I think this would expand the use cases of this project a lot. You'd be able to checkout to a commit you just queried

Aggregation fails with Date fields

Describe the bug
Unlike SQL, it seems like GQL only allows aggregation on the Integer fields as it throws an error when using aggregation functions on the Date fields. For instance, the following query fails:

Query:
select name, max(datetime) from commits group by name

Error message:
"Compiletime ERROR: [34 - 34] -> Function max argument number 0 with type DateTime don't match expected type Integer"

Expected behavior
The aggregation functions such as min and max used on the Date fields should return the earliest and the latest dates respectively.

GQL (please complete the following information):

  • Version 0.9.0

Incorrect comments in function of check_all_values_are_same_type

Describe the bug

Incorrect comments in function of check_all_values_are_same_type

To Reproduce

// https://github.com/AmrDeveloper/GQL/blob/78ca828f952ae0ab22128eb7af0ced6c3442db93/crates/gitql-parser/src/type_checker.rs#L251

/// If they has the same type, return it or return None

Expected behavior

/// If they have the same type, return it or return None

GQL (please complete the following information):

Version 0.14.0

Screenshots

None

Incorrect statement in function of consume_octal_number

Describe the bug

Incorrect statement in function of consume_octal_number

To Reproduce

// https://github.com/AmrDeveloper/GQL/blob/78ca828f952ae0ab22128eb7af0ced6c3442db93/crates/gitql-parser/src/tokenizer.rs#L811

while *pos < chars.len() && ((chars[*pos] >= '0' || chars[*pos] < '8') || chars[*pos] == '_') {

Expected behavior

while *pos < chars.len() && ((chars[*pos] >= '0' && chars[*pos] < '8') || chars[*pos] == '_') {

GQL (please complete the following information):

Version 0.14.0

Screenshots

None

Releases with binary assets?

Any chance to get releases with binary assets, so one can download the compiled binary instead of needing to setup the toolchain and all that?

The rye release workflow looks nice: https://github.com/mitsuhiko/rye/blob/main/.github/workflows/release.yml

If there is a new tag, the workflow would create a draft release, compile all the assets (different architectures) and upload them to the release. The final step is then for somone to (manually) add the release description (if you have any) and publish the release.

(Creating only a draft and only publish when the description is filled is nice because upon publish, GitHub send out an email with the current content. If the release is created without a description, the email has no info :⁠-⁠()

Crash if right-hand of expression is string without double quotation marks

Describe the bug
A clear and concise description of what the bug is.

I tried this. select name from branches where name starts_with xxx

and the program is crashed. but "xxx" was fine.

To Reproduce
gql > select name from branches where name starts_with x

Expected behavior
I don't know the right spec. but it should guide correct way or display a result.

Screenshots
image

GQL (please complete the following information):

  • Version = 0.3.0

EOF/script input, default repo, and plain-text output

Very cool project. Three features I could see being immediately useful:

  • EOF support for piped input; currently echo SELECT 1 | gitql -r . goes into a loop redisplaying its prompt forever. echo 'SELECT 1\nexit' | gitql -r . works
  • script file support; echo SELECT 1 >foo.sql; gitql -r . foo.sql would be useful.
  • default repo: echo SELECT 1\\nexit | gitql should probably look for the repo in . (and possibly walk up .. until it finds a .git or hits /).
  • plain-text, csv, or json output: gitql -r . foo.sql --csv would be very useful in pipelines to work with the resultant data without the ascii tables.

I may work on some PRs for some of these as time permits (assuming they're not against some philosophy of the project). This is a very cool idea, and these would address a wider range of use cases.

Unable to install 0.10.0 and 0.11.0 from cargo

Currently installing versions 0.10.0 and 0.11.0 using cargo install gives an error due to a dependency build:

error: failed to run custom build command for libz-ng-sys v1.1.12

The build seems to fail due to not having cmake installed:

failed to execute command: program not found
is cmake not installed?

Installing version 0.9.0 works fine.

Implement SQL Date and Time functions with documentations

Implement one function with documentations pre pull request

Steps:

  • Choose unimplemented function and write I am on <function_name>.
  • Then start implement the function in crates/gitql-ast/function.rs.
  • Date functions to use or add are in crates/gitql-ast/date_utils.rs.
  • Add docs for it in docs/function/function.md.
  • Make sure everything is formatted and submit a Pull Request.

Note: Engine function don't care about implicit casting so for example DAY("2017-06-15") the argument you will got is Date type as described on the site not Text.

Date Functions

  • CURRENT_DATE
  • CURRENT_TIME
  • CURRENT_TIMESTAMP
  • DATE
  • DAYNAME
  • DAYOFMONTH
  • DAYOFWEEK
  • DAYOFYEAR
  • HOUR
  • LAST_DAY
  • MAKEDATE
  • MAKETIME
  • MINUTE
  • MONTH
  • MONTHNAME
  • NOW
  • QUARTER
  • TO_DAYS
  • WEEK
  • WEEKDAY
  • WEEKOFYEAR
  • YEAR
  • YEARWEEK

For more information about implementation and description check https://www.w3schools.com/sql/sql_ref_sqlserver.asp

Note: You can only open max 3 PR at the time

git actions support

Is your feature request related to a problem? Please describe.
add support to git actions

Describe the solution you'd like
when I push to remote a set of queries, I defined in a config file, are executed on the branch and the results are exported

Describe alternatives you've considered
none

Additional context
I would use it in a simple markdown page with nice stats of my repo and ideally add a badge on the readme.md powered by gql plus add automatially in in changelog as well

Better editing support

Is your feature request related to a problem? Please describe.
After typing a long query and run it, I realize that there was a typo. The up arrow key does NOT bring back the last query (like what shell terminals would do). Copying and past the last query doesn't help much as the left/right arrow keys doesn't navigate the cursor either. Basically, I have to retype the long query and make sure not to make a typo again, which is painful.

Describe the solution you'd like
Better editing support. Make the up arrow key bring back the last query, and make left/right arrow keys navigate the cursor. It's even better if external editors such as Vim is supported to edit queries.

Describe alternatives you've considered

Additional context

Columns are displayed in random order

Describe the bug
Columns are displayed in random order.

To Reproduce
Steps to reproduce the behavior:

  1. select 1,2,3
  2. select 1,2,3
  3. select 1,2,3
  4. select 1,2,3

Expected behavior
The columns are displayed in the order listed in the select command.

GQL (please complete the following information):

  • Version 0.11.0

Screenshots

image

Incorrect comments in function of consume_identifier

Describe the bug

Incorrect comments in function of consume_identifier

To Reproduce

// https://github.com/AmrDeveloper/GQL/blob/78ca828f952ae0ab22128eb7af0ced6c3442db93/crates/gitql-parser/src/tokenizer.rs#L647

// Identifier is be case-insensitive by default, convert to lowercase to be easy to compare and lookup
// https://github.com/AmrDeveloper/GQL/blob/78ca828f952ae0ab22128eb7af0ced6c3442db93/crates/gitql-parser/src/tokenizer.rs#L670

// Identifier is be case-insensitive by default, convert to lowercase to be easy to compare and lookup

Expected behavior

// Identifier is being case-insensitive by default, convert to lowercase to be easy to compare and lookup
// Identifier is being case-insensitive by default, convert to lowercase to be easy to compare and lookup

GQL (please complete the following information):

Version 0.14.0

Screenshots

None

Incorrect comments in function of un_expected_expression_error

Describe the bug

Incorrect comments in function of un_expected_expression_error

To Reproduce

// https://github.com/AmrDeveloper/GQL/blob/78ca828f952ae0ab22128eb7af0ced6c3442db93/crates/gitql-parser/src/parser.rs#L2158

// `< =` the user may mean to write `<=`
if previous.kind == TokenKind::Greater && current.kind == TokenKind::Equal {
// https://github.com/AmrDeveloper/GQL/blob/78ca828f952ae0ab22128eb7af0ced6c3442db93/crates/gitql-parser/src/parser.rs#L2166

// `> =` the user may mean to write `>=`
if previous.kind == TokenKind::Less && current.kind == TokenKind::Equal {

Expected behavior

// `> =` the user may mean to write `>=`
if previous.kind == TokenKind::Greater && current.kind == TokenKind::Equal {
// `< =` the user may mean to write `<=`
if previous.kind == TokenKind::Less && current.kind == TokenKind::Equal {

GQL (please complete the following information):

Version 0.14.0

Screenshots

None

winget installation failed

Describe the bug
Installation using winget install gitql produces an error:

Installer failed with exit code: 0x80070002 : The system cannot find the file specified.

To Reproduce

  1. Open cmd window with admin permissions
  2. Run winget install gitql

Expected behavior
I expected the package to install. Instead an error was produced.

Full output

> winget install gitql
Found GitQL [amrdeveloper.gitql] Version 0.7.1
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
This package requires the following dependencies:
  - Packages
      Microsoft.VCRedist.2015+.x64
      Microsoft.UI.Xaml.2.8
Installing dependencies:
(1/1) Found Microsoft.UI.Xaml [Microsoft.UI.Xaml.2.8] Version 8.2306.22001.0
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Successfully verified installer hash
Starting package install...
  ████████████████████████████▌   95%
Installer failed with exit code: 0x80070002 : The system cannot find the file specified.
  • Version [e.g. 0.7.1]

Readline shortcuts

Sweet tool! I was playing around a bit and I was really missing the standard readline shortcuts.

Is your feature request related to a problem? Please describe.

I don't really know sql that well so I was messing around with some queries. But it got annoying to need to copy paste and then left arrow / right arrow to edit the statements. I was wishing it was possible to up-arrow to get previous history.

Describe the solution you'd like

Would be nice if GQL could support standard readline shortcuts. If it were up to me (big caveat), I would use rustyline: https://github.com/kkawakam/rustyline. I've used it in the past for https://github.com/danobi/btrd and it worked quite well.

I wouldn't mind sending a PR for this if you think it's ok.

Describe alternatives you've considered
Could do custom readline implementation in the cli crate.

Additional context
N/A

Misspelling in Diagnostic::error

Describe the bug

Misspelling in Diagnostic::error

To Reproduce

// https://github.com/AmrDeveloper/GQL/blob/ca60dfd29be62753ae95921b9096cf250ae55d0a/crates/gitql-parser/src/tokenizer.rs#L619

Diagnostic::error("Un expected character").with_location_span(column_start, position),

Expected behavior

Diagnostic::error("Unexpected character").with_location_span(column_start, position),

GQL (please complete the following information):

Version 0.12.0

Screenshots

None

Add pgwire PostgreSQL wire protocol interface to CLI

Hello @AmrDeveloper this is a fantastic library, thanks for putting it together!

We have a need to query our Git repos using SQL but with a PosgreSQL wire protocol (so we can use it with psql or any other PostgreSQL client application).

If you're willing, we'd love to see you add a server mode in GQL using Rust pgwire crate. pgwire does all the hard work of setting up a PostgreSQL wire compatible server and can accept SQL through the wire and pass it into your GQL crates/code.

Something like this:

gql server --repo=NAME,/path/to/repo --repo=NAME2,/path/to/repo2 --port 5432 
  • NAME, NAME2 would be schema names (case insensitive)
  • /path/to/repo would be the repo names

The above would launch a server listening on port 5432 that would make gql pretend to be a PostgreSQL server. Then, any SQL sent to the GQL server through any PostgreSQL client would be sent to GQL and responses returned using PostgreSQL wire protocol.

We would be able to use NAME and NAME2 schema names to combine multiple repos' output.

First time user: Application crashes on "SELECT * from commits" on a repo with no commits yet

Describe the bug
Running select * from commits on an empty repo with no commits throws exception.

Note: Installed it for the very first time.
Installation: scoop install gitql

To Reproduce
Steps to reproduce the behavior:

  1. Create a folder
  2. Do git init
  3. gitql
  4. select * from commits

Expected behavior
I am not sure what should be the expected behavior since I am using it for the first time. Generally speaking I would expect it to show 0 commits or at least don't crash!

Screenshots
image

GQL (please complete the following information):
GitQL version 0.10.0

Additional context
OS: Windows
image

WinGet installation command name incorrect

Describe the bug
When installing through WinGet, the command name is gql-x86_64-windows.exe, rather than gitql as expected

To Reproduce
Steps to reproduce the behavior:

  1. Install through winget (winget install gitql)
  2. Try to run gitql

Expected behavior
To be able to run gitql from the command line

Screenshots
image

GQL (please complete the following information):

  • Version [e.g. 1.0.0]

Additional context
It seems like you can just add the following to the winget installer manifest:

Commands:
- gitql

(I know very little about winget, I just happened to see a CLI tool I recognized and looked how they did it: https://github.com/microsoft/winget-pkgs/blob/e708f1e2c6fc5724b07f5c8c1ef54f5e939d3917/manifests/a/acaudwell/Gource/0.53/acaudwell.Gource.installer.yaml#L15C1-L16C1)

Implement Implicit casting between Date and Text

Is your feature request related to a problem? Please describe.
Add the ability to compare between Date type and Text type with date format

Describe the solution you'd like
Implicit convert Text type if it match date format to date object in the parse

Related issue:
Issue #41

Incorrect equals for DateTime and Time

Describe the bug

Incorrect equals for DateTime and Time

To Reproduce

// https://github.com/AmrDeveloper/GQL/blob/master/crates/gitql-ast/src/value.rs
let value = Value::DateTime(1704890191);
let other = Value::DateTime(1704890192);
let ret = value.equals(&other);
assert_eq!(ret, false); // fails

Expected behavior

assert_eq!(ret, false);  // ret is false

GQL (please complete the following information):

Version 0.11.0

Screenshots

screenshots

More than two conditions in WHERE results in an error

Describe the bug
More than two conditions in WHERE results in an error.

To Reproduce
Steps to reproduce the behavior:
Execute any statement with more than two conditions in the WHERE section:

SELECT COUNT(commit_id) FROM commits WHERE datetime >= "2023-01-01 00:00:00" AND email = "[email protected]" AND comment like "%merge%"

Expected behavior
The results are returned; all condition are applied.

Actual behavior
An error: Unexpected content after the end of 'SELECT' statement

Screenshots
image

GQL (please complete the following information):

  • Version v0.12.0

DateTime filters don't seem to work

When doing a query on the commits table, filtering on the time column does not work.

Examples:
select * from commits where time < "2023-11-01"
Returns every single record on the table regardless of its time value.

select * from commits where time < "2023-11-01"
Returns nothing.

I´ve tried both using a "date" using quotes, a datetime also using quotes, and even using the result of a function such as MAKEDATE, none of them seem to work.
What seems to happen is that any value that is used to filter the time column is "bigger", so any greater than or equal filters always return nothing and any smaller than filter always work as no filter at all.

Tested on version v0.8.0, installed using cargo install.

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.