Giter Site home page Giter Site logo

rsql's People

Contributors

dependabot[bot] avatar kirillgordinerhenag avatar piotr-oles avatar timhambourger 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

Watchers

 avatar  avatar  avatar

rsql's Issues

`=contains=` operator for searching substrings

Is your feature request related to a problem? Please describe.
I'm not able to search all rows from a column substring. I'm trying to look for a title that contains the word "test", but it's not possible. Only equal strings.

Describe the solution you'd like
It would be awesome to have some sort of operator like this claims RSQL supports those operators. I you have a guide or example for adding them I'd do it. Thanks.

Use of mutation testing in rsql - Help needed

Hello there!

My name is Ana. I noted that you use the mutation testing tool StrykerJS in the project.
I am a postdoctoral researcher at the University of Seville (Spain), and my colleagues and I are studying how mutation testing tools are used in practice. With this aim in mind, we have analysed over 3,500 public GitHub repositories using mutation testing tools, including yours! This work has recently been published in a journal paper available at https://link.springer.com/content/pdf/10.1007/s10664-022-10177-8.pdf.

To complete this study, we are asking for your help to understand better how mutation testing is used in practice, please! We would be extremely grateful if you could contribute to this study by answering a brief survey of 21 simple questions (no more than 6 minutes). This is the link to the questionnaire https://forms.gle/FvXNrimWAsJYC1zB9.

We apologize if you have already received message multiple times or if you have already had the opportunity to complete the survey. If you have already shared your feedback, we want to convey our appreciation, kindly disregard this message, and please accept our apologies for any inconvenience.

Drop me an e-mail if you have any questions or comments ([email protected]). Thank you very much in advance!!

emit and parse fail to respect some escaping rules for quotes and backslashes

emit and parse both fail to respect some of the escaping rules for quotes and backslashes from rsql-parser (relevant excerpts quoted below). The result is that ValueNodes whose value contains double quotes get corrupted when round-tripping through emit then parse.

@rsql version 1.3.2
Node version 16.15.1

Repro steps
Run the following snippet in an ES6 JS environment:

import builder from "@rsql/builder";
import { emit } from "@rsql/emitter";
import { parse } from "@rsql/parser";

const node = builder.comparison("selector", "==", "foo\"bar\\baz");
console.log(node.right.value);

const rsql = emit(node);
console.log(rsql);

const roundTrippedNode = parse(rsql);
// In TS we'd need to assert that roundTrippedNode is a ComparisonNode for this to compile.
console.log(roundTrippedNode.right.value);

Expected outcome
Console contains the following logged values (per rsql-parser escaping rules):

foo"bar\baz
selector=="foo\"bar\\baz"
foo"bar\baz

Actual outcome
Console contains the following logged values:

foo"bar\baz
selector=="fo\"bar\baz"
fo\"bar\baz

Relevant rsql-parser escaping rules
From https://github.com/jirutka/rsql-parser#grammar-and-semantic (emphasis added):

If you need to use both single and double quotes inside a quoted argument, then you must escape one of them using \ (backslash). If you want to use \ literally, then double it as \\. Backslash has a special meaning only inside a quoted argument, not in unquoted argument.

Analysis
emit escapes " (double quote) as \", but in the process it consumes the preceding character. Furthermore, emit fails to escape \ (backslash) as \\, as is required if (and only if) the value is being wrapped in quotes.

Meanwhile, parse correctly continues parsing the ValueNode's value past the \" sequence, i.e. it doesn't mistake the " in \" as ending the ValueNode's value. But parse fails to consume the \ in \" in the process, as it fails to consume the later \ in bar\baz.

Get selectors and values from a logic expression

Is your feature request related to a problem? Please describe.
Just an improvement to the README of the project if needed.
We can get the value and selector from a comparison node, but if we have a logic node, for example:
const expression = parse("year>=2003;year<=2004");

How can we get the selector and value from each comparison?

Describe the solution you'd like
Improvement in the README, explaining how to get values from a Logic

option to run this package with "skipLibCheck=false" not possible

Hey :)

When trying to build my application with your package I ended up with this error:

node_modules/@rsql/ast/dist/index.d.ts:3:1 - error TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier.

3 const EQ: "==";
  ~~~~~


node_modules/@rsql/parser/dist/index.d.ts:7:1 - error TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier.

7 function parse(source: string): ExpressionNode;
  ~~~~~~~~

It surely works when flagging skipLibCheck=true, but is this really wanted?

I now ended up with creating 2 custom typings in my application:

rsql_ast.d.ts:

declare module '@rsql/ast' {...}

rsql_parser.d.ts:

import { ExpressionNode } from '@rsql/ast';
declare module '@rsql/parser' {
    function parse(source: string): ExpressionNode;
}

i then was able to remove the skipLibCheck flag from my tsconfig and added the following option to it:

"paths": {
      "*": ["node_modules/*"],
      "@rsql/ast": ["custom_typings/rsql_ast.d.ts"],
      "@rsql/parser": ["custom_typings/rsql_parser.d.ts"]
    }

Looking forward to hear from you :)

[Security] Workflow ci.yml is using vulnerable action actions/checkout

The workflow ci.yml is referencing action actions/checkout using references v1. However this reference is missing the commit a6747255bd19d7a757dbdda8c654a9f84db19839 which may contain fix to the some vulnerability.
The vulnerability fix that is missing by actions version could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider to update the reference to the action.

Allow customizing the quoting behavior of emit.

Is your feature request related to a problem? Please describe.
This is definitely a nice-to-have, not an urgent need. Something I noticed while working on #32 is that the emitter has good internal support for using either quote character (double or single) to escape comparison values, but that emit itself currently only supports using the double quote character. Among other things, this means the emitted RSQL can end up being longer than it it needs to be if the AST being emitted contains a lot of comparison values with double quotes in them.

Describe the solution you'd like
I'd propose adding an optional second parameter to emit giving it the following signature:

type Quote = '"' | "'";

interface EmitOptions {
  /**
   * The preferred quote character to use when `emit` encounters a comparison value that needs to be escaped by wrapping
   * in quotes. Either `"` (the ASCII double quote character) or `'` (the ASCII single quote character). Defaults to `"`
   * (the ASCII double quote character).
   */
  preferredQuote?: Quote;
  /**
   * If `true`, `emit` will override the `preferredQuote` setting on a comparison value-by-comparison value basis if
   * doing so would shorten the emitted RSQL. If `false`, `emit` will use the `preferredQuote` as the quote character
   * for all comparison values encountered. Defaults to `true`.
   */
  optimizeQuotes?: boolean;
}

function emit(expression: ExpressionNode, opts?: EmitOptions): string;

I'll submit a PR for this in just a min.

Why aren't types and interfaces exported?

I'm trying to use the parser with an Angular/Typescript project and I'd like to convert the ExpressionNode returned by the parse method to my custom representation. However ExpressionNode is not exported in the module, nor do the other types.
I think it'd be great (and easy) if they did.

Parser converts array of numbers to array of strings

Given a string like
tags:user:my_field1=isoneof=(81)

I would expect the value in the parsed expression to be
[81]
However, it currently coverts to
['81']

As you can imagine this is impacting the results of the filter.

support for function calls in ast/parser

Hi,

I am using the parser to get an AST to build SQL from it. I want to support some function such as today() or aggregate function such as max(column1)

For example

max(year)>=today(-90)

I am looking for a way to get this kind of syntax working. Could you please tell me how hard it would be to make this work. I am currently reading the source code of the AST and parser package.

I think a dirty way would be to allow the parenthesis at those places. However, I think it would be more clean to parse this into a function call node. With function name and arguments.

Anyways, this is a cool library. Thanks for building it.

convert parse expression to Sequelize where condition

// parsing
import { parse } from "@rsql/parser";
const expression = parse("year>=2003");

// return
{
type: 'COMPARISON',
left: { type: 'SELECTOR', selector: 'year' },
operator: '>=',
right: { type: 'VALUE', value: '2003' }
}

how to convert the expression to Sequelize where condition ?

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.