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

a double value can be set to a int32/int64 property successfully #3473

Closed
Nicole00 opened this issue Dec 15, 2021 · 5 comments · Fixed by #3572
Closed

a double value can be set to a int32/int64 property successfully #3473

Nicole00 opened this issue Dec 15, 2021 · 5 comments · Fixed by #3572
Assignees
Labels
type/bug Type: something is unexpected
Milestone

Comments

@Nicole00
Copy link
Contributor

image

My tag has a property with data type int32, when I insert a double value, the expect result is failure, but the result is succeed.

And the query value is forced changed to int32, which is wrong.

@Nicole00 Nicole00 added the type/bug Type: something is unexpected label Dec 15, 2021
@Sophie-Xie Sophie-Xie added this to the v3.0.0 milestone Dec 15, 2021
@Sophie-Xie Sophie-Xie assigned jievince and unassigned CPWstatic Dec 17, 2021
@jievince
Copy link
Contributor

jievince commented Dec 27, 2021

  • Mysql, oracle, tidb, sql server, postgresql allow implicitly convert float to int;

tidb:

my:[email protected]:4000=> create table test.test (a int);
CREATE TABLE
my:[email protected]:4000=> insert into test.test values (18.34);
INSERT 1
my:[email protected]:4000=> select * from test.test;
 a
----
 18
(1 row)

SQL server:
image

@jievince
Copy link
Contributor

  • CockroachDB will report an error:
root@:26257/defaultdb> create table test(a int);
CREATE TABLE

Time: 6ms total (execution 6ms / network 0ms)

root@:26257/defaultdb> insert into test values (18.34);
ERROR: value type decimal doesn't match type int of column "a"
SQLSTATE: 42804
HINT: you will need to rewrite or cast the expression

@jievince
Copy link
Contributor

  • GQL says nothing about it.
    image

@Nicole00
Copy link
Contributor Author

When insert value 1.6 into nebula int32 property, the query result is 1.
image

When insert value 1.6 into mysql int32 property, the query result is 2, which is rounding.
image

Should we keep the same behavior with other dbs ?

@jievince
Copy link
Contributor

When insert value 1.6 into nebula int32 property, the query result is 1. image

When insert value 1.6 into mysql int32 property, the query result is 2, which is rounding. image

Should we keep the same behavior with other dbs ?

Good catch. They will round the float.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Type: something is unexpected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants