mike-tr-adamson commented on code in PR #2310:
URL: https://github.com/apache/cassandra/pull/2310#discussion_r1193793719
##########
src/java/org/apache/cassandra/serializers/TypeSerializer.java:
##########
@@ -55,11 +60,45 @@ public final void validate(ByteBuffer bytes) throws
MarshalException
public abstract Class<T> getType();
- public String toCQLLiteral(ByteBuffer buffer)
+ protected String toCQLLiteralNonNull(ByteBuffer buffer)
+ {
+ return toString(deserialize(buffer));
+ }
+
+ public final boolean isNull(ByteBuffer buffer)
+ {
+ return isNull(buffer, ByteBufferAccessor.instance);
+ }
+
+ public <V> boolean isNull(V buffer, ValueAccessor<V> accessor)
+ {
+ return buffer == null || accessor.isEmpty(buffer);
+ }
+
+ public final String toCQLLiteral(ByteBuffer buffer)
{
- return buffer == null || !buffer.hasRemaining()
+ return isNull(buffer)
? "null"
- : toString(deserialize(buffer));
+ : maybeQuote(toCQLLiteralNonNull(buffer));
+ }
+
+ public final String toCQLLiteralNoQuote(ByteBuffer buffer)
+ {
+ return isNull(buffer)
+ ? "null"
+ : toCQLLiteralNonNull(buffer);
+ }
+
+ public boolean shouldQuoteCQL()
+ {
+ return true;
Review Comment:
Why do we default to `true` here? If it's strings that need quoting then
wouldn't it be better to default to `false` and override this in
`AbstractTextSerializer`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]