Skip to content
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

String escaping behaviour creates invalid queries and limits possible strings #106

Open
adammitchelldev opened this issue Feb 24, 2020 · 1 comment

Comments

@adammitchelldev
Copy link

adammitchelldev commented Feb 24, 2020

Description

Strings are not escaped when converting Java TypeQL to a query string, despite requiring escape characters in order for the query string to be valid.

It also appears that the required escape characters are inserted, rather than being removed during parsing of the query, and that this was an oversight during a bugfix for asymmetrical escaping behaviour in an older version of TypeQLpre 1.0).

The behaviour is not standard, can cause users to accidentally break their queries (when programmatically generating them) and prevents users from inserting any string.

Environment

  1. OS (where TypeQL server runs): any
  2. TypeQL version (and platform): any
  3. TypeQL client: any (most notable in client-java)
  4. Other environment details:

Reproducible Steps

Steps to create the smallest reproducible scenario:
1.

// Gives us an invalid TypeQL query
System.out.println(TypeQL.insert(TypeQL.var("x").isa("person").has("name", "b\"o\"b")).toString());

Expected Output

insert $x isa person, has name "b\"o\"b";

Actual Output

insert $x isa person, has name "b"o"b";
@flyingsilverfin
Copy link
Member

Stashed PR here: #224
Further considerations are in the comment there

@flyingsilverfin flyingsilverfin self-assigned this Jan 10, 2023
dmitrii-ubskii added a commit that referenced this issue Jul 8, 2024
## Usage and product changes

User-defined functions and structs:
```typeql
fun mean_salary($c: company) -> double? :
    match 
        (company: $c, employee: $_) isa employment, has salary $s;
    return mean($s); 
```
```typeql
struct dated_coordinate:
    longitude value double,
    latitude value double,
    date value datetime;
```

Query pipelines:
```
with fun costliest_printer($employee: employee) -> printer? :
  match 
    ($printer, $employee) isa print_permission;
    $printer has cost_per_page $cost;
  sort $cost desc;
  return first($printer);
match
  $printer isa printer, has office_number $n, has newly_installed true;
  $employee isa employee, has office_number $n;
put ($employee, $printer) isa print_permission;
match 
  $high_cost_printer = costliest_printer($employee), has printer_name $name;
  not { $printer is $high_cost_printer; };
  $employee has contact $address;
insert 
  $notice isa queued_email, has recipient $address, 
  has content "Do you still need the printer " + $name + "?";
```

New undefine syntax allows user to be more precise as to what is being
undefined:
```typeql
undefine
owns age from person;
@regex from first-name;
as name from person owns first-name;
```
New, more concise delete syntax:
```typeql
match $p isa person, has name $n;
delete $n of $p;
```

Implement JSON-like string unescaping (closes #106).

See [The TypeDB 3.0 Roadmap](<https://typedb.com/blog/typedb-3-roadmap>)
for more details!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants