CompositeType wont serialize properly for col name #120

Closed
gillotte opened this Issue Mar 18, 2013 · 1 comment

2 participants

@gillotte

Hi Nick, consider the following

CompositeType colname = new CompositeType(new CassandraType[] { CassandraType.AsciiType, CassandraType.AsciiType });            
        AsciiType k1 = new AsciiType();
        k1.SetValue("key2");
        AsciiType k2 = new AsciiType();
        k2.SetValue("key3");
        colname.SetValue(new CassandraObject[] { k1, k2 });

        var record = cf.CreateRecord(key);
        record[colname] = colValue;

this fails essentially because this line fails

        var val1 = colname.GetValue(CassandraType.GetCassandraType(typeof(byte[])));

A proposed fix:

Edit CassandraObject's Get Value to include bytetype clause.

public CassandraObject GetValue(CassandraType type)
    {
        if (type.FluentType == GetType())
            return this;

        if (GetType() == typeof(BytesType))
            return GetCassandraObjectFromDatabaseByteArray((byte[])GetValue(), type);

        //NEW CODE
        if (type == CassandraType.BytesType)
            return ToBigEndian();

        return GetCassandraObjectFromObject(GetValue(), type);
    }

thoughts?

@nberardi
@nberardi nberardi closed this Apr 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment