incorrect mutation being set on super column #49

Closed
edweip3 opened this Issue Aug 21, 2012 · 4 comments

2 participants

@edweip3

In the FluentSuperColumn class, the function UpdateParent is calling ResetMutationAndAddAllColumns(). This causes mutations to be added to the tracker for all columns in an existing super column. ResetMutation() should probably be called instead.

steps to reproduce:
1. Create a super column family.
2. insert a row with a super column.
3. update the row to add more super columns using code similar to below

var family = db.GetSuperColumnFamily(ColumnFamilyName);
var record = family.Get(id).FirstOrDefault();

dynamic column = record.CreateSuperColumn();
column.columnname = "column value";
record["supercolumn key"] = column;

db.Attach(record);
db.SaveChanges();

@nberardi nberardi was assigned Aug 21, 2012
@nberardi

Is there any way you can add a reproduceable test in the Bugs folder.

https://github.com/managedfusion/fluentcassandra/tree/master/test/FluentCassandra.Tests/Bugs

I tried to get this to happen, but I don't think I am setting it up correctly. Please feel free to send me a pull request with the test case.

@edweip3

Here's a snippet of code that reproduces the problem. Sorry, I don't have any spare time right now to do it properly in the Bugs folder.

//create super column family
string ColumnFamilyName = "testfamily";
string key = "somekey";
keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema
{
FamilyName = ColumnFamilyName,
FamilyType = ColumnType.Super,
KeyValueType = CassandraType.AsciiType,
SuperColumnNameType = CassandraType.AsciiType,
ColumnNameType = CassandraType.UTF8Type,
DefaultColumnValueType = CassandraType.UTF8Type
});

//create 1 row with 1 super column

var family = db.GetSuperColumnFamily(ColumnFamilyName);
var record = family.Get(key).FirstOrDefault();
if (record == null || record.Columns.Count == 0)
{
record = family.CreateRecord(key: id);
}

var column = record.CreateSuperColumn();
column["columnname"] = "some column value";
column.ColumnName = "supercolumn 1";
record.Columns.Add(column);

db.Attach(record);
db.SaveChanges(); //succeddes.

// create another super column
record = family.Get(key).FirstOrDefault();
if (record == null || record.Columns.Count == 0)
{
record = family.CreateRecord(key: id);
}

var column2 = record.CreateSuperColumn();
column2["columnname"] = "some other column value";
column2.ColumnName = "supercolumn 2";
record.Column.Add(column2);

db.Attach(record);
db.SaveChanges(); //fails with exception

@nberardi
@nberardi

This was fixed with issue #52

@nberardi nberardi closed this Aug 26, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment