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

mysql/json:support json_type #1937

Merged
merged 3 commits into from
Jun 19, 2017
Merged

mysql/json:support json_type #1937

merged 3 commits into from
Jun 19, 2017

Conversation

AndreMouche
Copy link
Member

Hi,
This PR implement json_type for json. Since tidb haven't implement json_type in evaluator, so we would implement this part later. The related source file in tidb is (https://github.com/pingcap/tidb/blob/master/util/types/json/functions.go#L25)

@andelf @hhkbp2 @hicqu @lishihai9017 PTAL


use super::Json;

const JSON_TYPE_BOOLEAN: &[u8] = b"BOOLEAN";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&'static [u8]

@hhkbp2
Copy link
Contributor

hhkbp2 commented Jun 17, 2017

LGTM

#[cfg(test)]
mod test {
use super::*;
#[test]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a blank line before attribute.

use super::Json;

const JSON_TYPE_BOOLEAN: &[u8] = b"BOOLEAN";
const JSON_TYPE_NONE: &[u8] = b"NULL";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use str here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we only need binary in tikv. And if we use str here, it would still be converted to binary after json_type @siddontang

const JSON_TYPE_ARRAY: &[u8] = b"ARRAY";

impl Json {
pub fn json_type(&self) -> &[u8] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, the type should be an enum or integer, but here it is a &[u8], do we use this for comparison?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@siddontang siddontang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AndreMouche AndreMouche merged commit 1dd5cbd into master Jun 19, 2017
@AndreMouche AndreMouche deleted the shirly/json_type branch June 19, 2017 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants