Star

How to insert a vertex with default value

At first,create a new Tag:

CREATE TAG t2 (name string, age int)  

and then,insert value to it but not set age

INSERT VERTEX t2 (name) VALUES 11:("n1")

But there was an error:[ERROR (-8)]: `age’ not exist default value
So,Is there a way to specify a default value when creating a tag or to insert without inserting certain columns when inserting data.Because I don’t want to insert it right now.

Try this:

CREATE TAG t2 (name string, age int default 18);

INSERT VERTEX t2 (name) VALUES 11:(“n1”)

FETCH PROP ON t2 11;

Thanks,It’s working!
But when I using alter tag with [default],it’s still not working.
Like this:

create tag t2 (name string default "N/A", age int default -1);
INSERT VERTEX t2() VALUES 11:();
fetch prop on t2 11;

I got:
image
and then,I execute:

ALTER tag t2 add (description string default "none");
fetch prop on t2 11

I got:
image
exectue:

INSERT VERTEX t2() VALUES 11:()

give me a error message:

[ERROR (-8)]: `description' not exist default value

Is [alter] not support [default]? Or it’s bug?

That looks like a bug. Can you raise an issue in github, so we can track it. THX a lot.

OK,I will

@Qubutol Thanks for your contribution to Nebula Graph! Could you please contact nebulagraphbot via WeChat once you finish raising the issue? We have a gift for those who find bugs for us.

OK,I will add nebulagraphbot