dcapwell commented on code in PR #2310:
URL: https://github.com/apache/cassandra/pull/2310#discussion_r1194076407
##########
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:
mostly because it looked like there were more types needing than those that
exclude.
> If it's strings that need quoting then wouldn't it be better to default
to false and override this in AbstractTextSerializer?
Most types looked to be strings, but do not use `AbstractTypeSerializer`...
one negative of this is that collections became strings (which does still work
in CQL), so switching to `false` may help not quote when we don't need to...
ill test out swapping
--
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]