cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ble...@apache.org
Subject [1/4] cassandra git commit: Fix SimpleDateType type compatibility
Date Thu, 12 Nov 2015 20:18:17 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 7fcf14faa -> 0781bccc9


Fix SimpleDateType type compatibility

patch by Benjamin Lerer; reviewed by Joshua McKenzie for CASSANDRA-10027


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b05fe4ff
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b05fe4ff
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b05fe4ff

Branch: refs/heads/trunk
Commit: b05fe4ffee8f1c457a79013c2ddc88abcdadc6bb
Parents: 84d4488
Author: blerer <benjamin.lerer@datastax.com>
Authored: Thu Nov 12 20:53:42 2015 +0100
Committer: blerer <benjamin.lerer@datastax.com>
Committed: Thu Nov 12 20:53:42 2015 +0100

----------------------------------------------------------------------
 CHANGES.txt                                        |  1 +
 .../cassandra/db/marshal/SimpleDateType.java       |  2 +-
 .../cql3/validation/operations/AlterTest.java      | 17 +++++++++++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b05fe4ff/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9c834f3..5705453 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.2.4
+ * Fix SimpleDateType type compatibility (CASSANDRA-10027)
  * (Hadoop) fix splits calculation (CASSANDRA-10640)
  * (Hadoop) ensure that Cluster instances are always closed (CASSANDRA-10058)
  * (cqlsh) show partial trace if incomplete after max_trace_wait (CASSANDRA-7645)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b05fe4ff/src/java/org/apache/cassandra/db/marshal/SimpleDateType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/SimpleDateType.java b/src/java/org/apache/cassandra/db/marshal/SimpleDateType.java
index 747709e..6e435ee 100644
--- a/src/java/org/apache/cassandra/db/marshal/SimpleDateType.java
+++ b/src/java/org/apache/cassandra/db/marshal/SimpleDateType.java
@@ -69,7 +69,7 @@ public class SimpleDateType extends AbstractType<Integer>
     @Override
     public boolean isValueCompatibleWithInternal(AbstractType<?> otherType)
     {
-        return this == otherType || otherType == IntegerType.instance;
+        return this == otherType || otherType == Int32Type.instance;
     }
 
     public Term fromJSONObject(Object parsed) throws MarshalException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b05fe4ff/test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
index 95380f4..566c0ea 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
@@ -200,4 +200,21 @@ public class AlterTest extends CQLTester
             assertInvalidSyntaxMessage("no viable alternative at input 'WITH'", stmt);
         }
     }
+
+    /**
+     * tests CASSANDRA-10027
+     */
+    @Test
+    public void testAlterColumnTypeToDate() throws Throwable
+    {
+        createTable("CREATE TABLE %s (key int PRIMARY KEY, c1 int);");
+        execute("INSERT INTO %s (key, c1) VALUES (1,1);");
+        execute("ALTER TABLE %s ALTER c1 TYPE date;");
+        assertRows(execute("SELECT * FROM %s"), row(1, 1));
+
+        createTable("CREATE TABLE %s (key int PRIMARY KEY, c1 varint);");
+        execute("INSERT INTO %s (key, c1) VALUES (1,1);");
+        assertInvalidMessage("Cannot change c1 from type varint to type date: types are incompatible.",
+                             "ALTER TABLE %s ALTER c1 TYPE date;");
+    }
 }


Mime
View raw message