vaticle / typeql

TypeQL: the polymorphic query language of TypeDB
https://typedb.com
Mozilla Public License 2.0
213 stars 45 forks source link

Using standard form for numeric literals throws an error when parsed #288

Open james-whiteside opened 1 year ago

james-whiteside commented 1 year ago

Description

Numbers expressed in standard form (exponent notation) are not currently accepted as valid syntax.

Environment

  1. OS: MacOS 12.6.1
  2. TypeDB version: TypeDB 2.17.0
  3. TypeDB client: Studio 6d1b4f730df08d1d96bff66a7f48f974f9088f58

Reproducible Steps

Run a query involving a number in standard form, for example:

match
$g isa geo-entity, has alpha-three-code "AFW";
$i isa indicator-entity, has series-code "IT.NET.USER.ZS";
$y isa year; $y = 1994;
insert
(subject: $g, indicator: $i, year: $y) isa indicator-data, has value 4.37347303003985e-06;

Expected Output

Query is accepted.

Actual Output

## Error> [TQL03] TypeQL Error: There is a syntax error at line 1:
match $g isa geo-entity, has alpha-three-code "AFW"; $i isa indicator-entity, has series-code "IT.NET.USER.ZS"; $y isa year; $y = 1994; insert (subject: $g, indicator: $i, year: $y) isa indicator-data, has value 4.37347303003985e-06;
                                                                                                                                                                                                                                    ^
extraneous input 'e-06' expecting ';'
shaad00 commented 1 year ago

match $g isa geo-entity, has alpha-three-code "AFW"; $i isa indicator-entity, has series-code "IT.NET.USER.ZS"; $y isa year; $y = 1994; insert (subject: $g, indicator: $i, year: $y) isa indicator-data, has value 4.37347303003985e-06;

Try this , this will help you . You are getting an error just because of the indentation error. You need to gave some space after match and then write your query , in the same way write insert just below the match and after that rest of your query.

james-whiteside commented 1 year ago

Try this , this will help you . You are getting an error just because of the indentation error. You need to gave some space after match and then write your query , in the same way write insert just below the match and after that rest of your query.

I'm not sure that's correct. TypeQL doesn't take into account indentation of queries when parsed. I've tested the same query but with numbers changed from standard form to place-value form and it's running fine.

shaad00 commented 1 year ago

ohhh , that's cool if it's working fine with another value . I will try to find it out .

shaad00 commented 1 year ago

you can check the data type of the 'value' attribute and ensure that it matches the data type of the value you're trying to insert. If you're still having trouble, please let me know and I'll do my best to assist you further.

flyingsilverfin commented 1 year ago

@james-whiteside the title "Numbers in standard form are not valid syntax" is a pretty unclear description of what you're actually outlining? Please refine