vesoft-inc/nebula-go

func ExecuteWithParameter can't execute, ErrorCode: -1005

TuoLe opened this issue · 1 comments

TuoLe commented

nebula version: 3.1.0
Installation method: docker-compose
nebula-go version: v3.4.0

The following code uses the nebula-go library, and its function is to store an object of type map[string]interface{} into the nebulagraph database through the ExecuteWithParameter function.

Now a bug is encountered during the execution of this code: ErrorCode: -1005, ErrorMsg: Storage Error: The data type does not meet the requirements. Use the correct type of data.

func AddVertex(ptrPool *nebula.ConnectionPool) error {
	// Create session
	session, err := ptrPool.GetSession(username, password)
	if err != nil {
		log.Fatal(fmt.Sprintf("Fail to create a new session from connection pool, "+
			"username: %s, password: %s, %s", username, password, err.Error()))
		return err
	}
	// Release session and return connection back to connection pool
	defer session.Release()

	personMap := make(map[string]interface{})
	personMap["Height"] = 1.78
	personMap["Name"] = "asd"

	insertNGQL := ` 
		CREATE SPACE IF NOT EXISTS Myspace(vid_type=FIXED_STRING(20));
		USE Myspace;

		CREATE TAG IF NOT EXISTS Person (Height double null, Name string null);

		INSERT VERTEX Person (Height, Name)
		VALUES
		"aaaaaaaaaaaaaaaaaaaa":($Height, $Name);
	`

	_, _ = session.Execute("USE Myspace;")

	// Send
	resultSet, err := session.ExecuteWithParameter(insertNGQL, personMap)
	if err != nil {
		fmt.Print(err.Error())
		return err
	}
	checkResultSet("test", resultSet)

	return nil
}

Is my usage wrong and how to resolve it?

This question is similar to this question: https://discuss.nebula-graph.com.cn/t/topic/12512