Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncating and Limiting the Value's class toString() to 36 characters #2654

Open
gauravpurohit06 opened this issue Oct 5, 2023 · 5 comments
Assignees
Labels
api: spanner Issues related to the googleapis/java-spanner API.

Comments

@gauravpurohit06
Copy link
Contributor

In java class Value for 3 data types which includes String, JSON, PGJSONB we are truncating the response of method valueToString to 36 characters. Method valueToString is called internally by toString() method.

The toString() method is designed to return a string representation of an object, and it's expected to provide a complete and meaningful representation of the object's state. Truncating it may lead to loss of information and make debugging and logging more difficult.

@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/java-spanner API. label Oct 5, 2023
@gauravpurohit06
Copy link
Contributor Author

Context
While working on Dataflow Integration Tests, I am converting mutation object to map and then using toString() to get a valid string but the string is truncated as it's internally using the above method.

@olavloite
Copy link
Collaborator

You should call Value#getAsString() for that

@gauravpurohit06
Copy link
Contributor Author

@olavloite, yes we can use it but the thing is we are not calling it directly on any particular Value instance. We are using Mutation.toString() which internally calls toString method for all the Value objects.

@olavloite
Copy link
Collaborator

For that, we should add a method to Mutation (e.g. Mutation#getStringRepresentation()) that calls Value#getAsString(). Changing the toString() implementation of either Value or Mutation could be considered a breaking change, as it could risk that someone who is currently logging the outcome of those methods would all of a sudden see a log size explosion.

@gauravpurohit06
Copy link
Contributor Author

Thanks @olavloite, it makes sense. Client Library owners to take the call, if it's helpful to add.

@arpan14 arpan14 assigned rahul2393 and unassigned arpan14 Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/java-spanner API.
Projects
None yet
Development

No branches or pull requests

4 participants