mirror of https://github.com/apache/cassandra
Correctly typecheck in CQL3 even in presence of ReversedType
patch by slebresne; reviewed by jbellis for CASSANDRA-5386
This commit is contained in:
parent
61e329f7ae
commit
b72af485f6
|
|
@ -12,6 +12,7 @@
|
|||
* Invalid streamId in cql binary protocol when using invalid CL (CASSANDRA-5164)
|
||||
* Fix validation for IN where clauses with collections (CASSANDRA-5376)
|
||||
* Copy resultSet on count query to avoid ConcurrentModificationException (CASSANDRA-5382)
|
||||
* Correctly typecheck in CQL3 even with ReversedType (CASSANDRA-5386)
|
||||
Merged from 1.1:
|
||||
* cli: Quote ks and cf names in schema output when needed (CASSANDRA-5052)
|
||||
* Fix bad default for min/max timestamp in SSTableMetadata (CASSANDRA-5372)
|
||||
|
|
|
|||
|
|
@ -105,6 +105,22 @@ public interface CQL3Type
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object o)
|
||||
{
|
||||
if(!(o instanceof Custom))
|
||||
return false;
|
||||
|
||||
Custom that = (Custom)o;
|
||||
return type.equals(that.type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode()
|
||||
{
|
||||
return type.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
@ -166,6 +182,22 @@ public interface CQL3Type
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object o)
|
||||
{
|
||||
if(!(o instanceof Collection))
|
||||
return false;
|
||||
|
||||
Collection that = (Collection)o;
|
||||
return type.equals(that.type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode()
|
||||
{
|
||||
return type.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class TypeCast implements Term.Raw
|
|||
|
||||
public boolean isAssignableTo(ColumnSpecification receiver)
|
||||
{
|
||||
return receiver.type.equals(type.getType());
|
||||
return receiver.type.asCQL3Type().equals(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ public class FunctionCall extends Term.NonTerminal
|
|||
public boolean isAssignableTo(ColumnSpecification receiver)
|
||||
{
|
||||
AbstractType<?> returnType = Functions.getReturnType(functionName, receiver.ksName, receiver.cfName);
|
||||
return receiver.type.equals(returnType);
|
||||
return receiver.type.asCQL3Type().equals(returnType.asCQL3Type());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ public abstract class Functions
|
|||
|
||||
private static void validateTypes(Function fun, List<? extends AssignementTestable> providedArgs, ColumnSpecification receiver) throws InvalidRequestException
|
||||
{
|
||||
if (!receiver.type.equals(fun.returnType()))
|
||||
if (!receiver.type.asCQL3Type().equals(fun.returnType().asCQL3Type()))
|
||||
throw new InvalidRequestException(String.format("Type error: cannot assign result of function %s (type %s) to %s (type %s)", fun.name(), fun.returnType().asCQL3Type(), receiver, receiver.type.asCQL3Type()));
|
||||
|
||||
if (providedArgs.size() != fun.argsType().size())
|
||||
|
|
@ -135,7 +135,7 @@ public abstract class Functions
|
|||
|
||||
private static boolean isValidType(Function fun, List<? extends AssignementTestable> providedArgs, ColumnSpecification receiver)
|
||||
{
|
||||
if (!receiver.type.equals(fun.returnType()))
|
||||
if (!receiver.type.asCQL3Type().equals(fun.returnType().asCQL3Type()))
|
||||
return false;
|
||||
|
||||
if (providedArgs.size() != fun.argsType().size())
|
||||
|
|
|
|||
|
|
@ -374,7 +374,7 @@ public abstract class Selection
|
|||
|
||||
public boolean isAssignableTo(ColumnSpecification receiver)
|
||||
{
|
||||
return receiver.type.equals(isWritetime ? LongType.instance : Int32Type.instance);
|
||||
return receiver.type.asCQL3Type().equals(isWritetime ? CQL3Type.Native.BIGINT : CQL3Type.Native.INT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cassandra.cql3.CQL3Type;
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
import org.apache.cassandra.exceptions.SyntaxException;
|
||||
|
||||
|
|
@ -96,6 +97,12 @@ public class ReversedType<T> extends AbstractType<T>
|
|||
return baseType.decompose(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CQL3Type asCQL3Type()
|
||||
{
|
||||
return baseType.asCQL3Type();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue