OrientDB-NET.binary icon indicating copy to clipboard operation
OrientDB-NET.binary copied to clipboard

Colons and quotes lost when saved in a inner document

Open cha67 opened this issue 10 years ago • 0 comments

Hello !

This small test is failing. The string 'e=mc2' become 'e:mc2' if stored in a member of an inner document

    public void InsertColonAndEqualSymbolInInnerDocument()
    {
        Utils.InitPool();

        using (ODatabase database = new ODatabase("alias"))
        {
            DataSourceOrientDbDTO entity = new DataSourceOrientDbDTO();
            entity.Parameters = new List<DataSourceOrientDbDTO.DataSourceParameter>();
            entity.Parameters.Add(new DataSourceOrientDbDTO.DataSourceParameter() { Name = "'e=mc2'" }); //Name property type is string

            ODocument d = database.Insert<DataSourceOrientDbDTO>(entity).Run();

            List<DataSourceOrientDbDTO> result = database
            .Select()
            .From(typeof(DataSourceOrientDbDTO).Name)
            .Where("@rid").Equals(d.ORID)
            .ToList<DataSourceOrientDbDTO>();

            Assert.AreEqual("'e=mc2'", result.First().Parameters.First().Name); //returns \'e:mc2\'

        }
    }

A working solution for the column problem (but I don't know if there are side effects).

In SQLQuery.cs add an assignmentKeyword parameter to BuildFieldValue

    private string BuildFieldValue<T>(string fieldName, T fieldValue, string assignmentKeyword)
    {
        string field = "";

        if (_compiler.HasKey(Q.Set))
        {
            field += ", ";
        }

        field += string.Join(" ", fieldName, assignmentKeyword, ""); //was Q.Equals

From SQLQuery.ToString(), near "else if (value is ODocument)"

Original : var strValue = BuildFieldValue("'" + field.Key + "'", field.Value).Replace('=', ':');

New version : var strValue = BuildFieldValue("'" + field.Key + "'", field.Value, ":"); //assignmentKeyword should be ":" from THIS CALL ONLY

Other calls to BuildFieldValue should pass Q.Equals as assignmentKeyword (as currently in the code)

But I have no solution for the quotes problem

cha67 avatar May 14 '15 12:05 cha67