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

expression, json: fix cast json to other types. #4265

Merged
merged 10 commits into from Aug 23, 2017

Conversation

Projects
None yet
3 participants
@hicqu
Contributor

hicqu commented Aug 21, 2017

Fix cast from JSON to other types. And make something in util/types/json from private to public so that we can use them in other modules.

hicqu added some commits Aug 21, 2017

expression, json: fix cast json to int and real.
And I make many things in util/types/json from
private to public in order to we can use them
in parent modules.

@hicqu hicqu requested review from XuHuaiyu and zz-jason Aug 21, 2017

hicqu added some commits Aug 21, 2017

bound := UnsignedUpperBound[mysql.TypeLonglong]
u, err := ConvertFloatToUint(sc, f, bound, mysql.TypeDouble)
return int64(u), errors.Trace(err)
case json.TypeCodeString:

This comment has been minimized.

@XuHuaiyu

XuHuaiyu Aug 21, 2017

Contributor

what will Tidb get for:

create table t(a json);
insert into t value('"123abc"');
select cast(a as signed);

mysql gets

mysql> select cast(a as signed) from t;
Field   1:  `cast(a as signed)`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       LONGLONG
Collation:  binary (63)
Length:     21
Max_length: 2
Decimals:   0
Flags:      BINARY NUM


+-------------------+
| cast(a as signed) |
+-------------------+
|                12 |
+-------------------+
1 row in set, 1 warning (0.00 sec)

should we use StrToInt() here?

@XuHuaiyu

XuHuaiyu Aug 21, 2017

Contributor

what will Tidb get for:

create table t(a json);
insert into t value('"123abc"');
select cast(a as signed);

mysql gets

mysql> select cast(a as signed) from t;
Field   1:  `cast(a as signed)`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       LONGLONG
Collation:  binary (63)
Length:     21
Max_length: 2
Decimals:   0
Flags:      BINARY NUM


+-------------------+
| cast(a as signed) |
+-------------------+
|                12 |
+-------------------+
1 row in set, 1 warning (0.00 sec)

should we use StrToInt() here?

@hicqu

This comment has been minimized.

Show comment
Hide comment
@hicqu

hicqu Aug 22, 2017

Contributor

@XuHuaiyu , PTAL, thanks.

Contributor

hicqu commented Aug 22, 2017

@XuHuaiyu , PTAL, thanks.

@XuHuaiyu

LGTM

@XuHuaiyu XuHuaiyu merged commit 8c69983 into master Aug 23, 2017

3 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla Contributor License Agreement is signed.
Details

@XuHuaiyu XuHuaiyu deleted the qupeng/json-fix branch Aug 23, 2017

dbjoa added a commit to cloud-pi/tidb that referenced this pull request Aug 30, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment