Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of https://github.com/gillotte/fluentcassandra

…into gillotte-master
  • Loading branch information...
commit fc335e7ea1142a69bdbe24fc1bcd22ffd6991503 2 parents e8ccbe9 + 88bd95b
@nberardi nberardi authored
View
33 src/FluentColumnFamily.cs
@@ -145,8 +145,37 @@ public override IList<FluentColumn> Columns
{
get { return _columns; }
}
-
- /// <summary>
+
+ public override void RemoveColumn(object name)
+ {
+ FluentColumn col = Columns.FirstOrDefault(c => c.ColumnName == name);
+
+ if (col != null)
+ {
+ Columns.Remove(col);
+ }
+ else
+ {
+ var cfSchema = GetSchema();
+ var schema = cfSchema.Columns.FirstOrDefault(c => c.Name == name);
+
+ if (schema != null)
+ {
+ col = new FluentColumn(schema);
+ col.ColumnName = CassandraObject.GetCassandraObjectFromObject(name, schema.NameType);
+ }
+ else
+ {
+ col = new FluentColumn();
+ col.ColumnName = CassandraObject.GetCassandraObjectFromObject(name);
+ }
+
+ col.SetParent(GetSelf());
+ MutationTracker.ColumnMutated(MutationType.Removed, col);
+ }
+ }
+
+ /// <summary>
/// Gets the path.
/// </summary>
/// <returns></returns>
View
7 src/FluentCqlRow.cs
@@ -112,7 +112,12 @@ public override IList<FluentColumn> Columns
get { return _columns; }
}
- public CassandraObject this[CassandraObject columnName]
+ public override void RemoveColumn(object name)
+ {
+ throw new NotSupportedException();
+ }
+
+ public CassandraObject this[CassandraObject columnName]
{
get
{
View
11 src/FluentRecord.cs
@@ -170,12 +170,19 @@ public IFluentMutationTracker MutationTracker
private set;
}
- public void RemoveColumn(object name)
+ public abstract void RemoveColumn(object name);
+
+ public bool TryRemoveColumn(object name)
{
var col = Columns.FirstOrDefault(c => c.ColumnName == name);
if (col != null)
- Columns.Remove(col);
+ {
+ Columns.Remove(col);
+ return true;
+ }
+
+ return false;
}
#endregion
View
30 src/FluentSuperColumn.cs
@@ -87,7 +87,35 @@ public override IList<FluentColumn> Columns
get { return _columns; }
}
- /// <summary>
+ public override void RemoveColumn(object name)
+ {
+ FluentColumn col = Columns.FirstOrDefault(c => c.ColumnName == name);
+
+ if (col != null)
+ {
+ Columns.Remove(col);
+ }
+ else
+ {
+ var schema = GetColumnSchema(name);
+
+ if (schema != null)
+ {
+ col = new FluentColumn(schema);
+ col.ColumnName = CassandraObject.GetCassandraObjectFromObject(name, schema.NameType);
+ }
+ else
+ {
+ col = new FluentColumn();
+ col.ColumnName = CassandraObject.GetCassandraObjectFromObject(name);
+ }
+
+ col.SetParent(GetPath());
+ MutationTracker.ColumnMutated(MutationType.Removed, col);
+ }
+ }
+
+ /// <summary>
///
/// </summary>
public FluentSuperColumnFamily Family
View
31 src/FluentSuperColumnFamily.cs
@@ -130,7 +130,36 @@ public override IList<FluentSuperColumn> Columns
get { return _columns; }
}
- /// <summary>
+ public override void RemoveColumn(object name)
+ {
+ var col = Columns.FirstOrDefault(c => c.ColumnName == name);
+
+ if (col != null)
+ {
+ Columns.Remove(col);
+ }
+ else
+ {
+ var cfSchema = GetSchema();
+ var schema = cfSchema.Columns.FirstOrDefault(c => c.Name == name);
+
+ if (schema != null)
+ {
+ col = new FluentSuperColumn(schema);
+ col.ColumnName = CassandraObject.GetCassandraObjectFromObject(name, schema.NameType);
+ }
+ else
+ {
+ col = new FluentSuperColumn();
+ col.ColumnName = CassandraObject.GetCassandraObjectFromObject(name);
+ }
+
+ col.SetParent(GetSelf());
+ MutationTracker.ColumnMutated(MutationType.Removed, col);
+ }
+ }
+
+ /// <summary>
///
/// </summary>
public CassandraColumnFamilySchema GetSchema()
Please sign in to comment.
Something went wrong with that request. Please try again.