-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[#11001] Migrate App Engine Text datastore type #11019
[#11001] Migrate App Engine Text datastore type #11019
Conversation
Hi @jianhandev, these parts of your pull request do not appear to follow our contributing guidelines:
|
} | ||
|
||
public void setInstructorPrivilegeAsText(String instructorPrivilegesAsText) { | ||
this.instructorPrivilegesAsText = new Text(instructorPrivilegesAsText); | ||
this.instructorPrivilegesAsText = new StringValue(instructorPrivilegesAsText); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably you need a null check here?
e.g.
if (instructorPrivilegesAsText == null) {
this.instructorPrivilegesAsText = null;
} else {
this.instructorPrivilegesAsText = new StringValue(instructorPrivilegesAsText);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, StringValue
unlike Text
does not support null value. I was thinking can construct StringValue
using an empty string instead whenever instructorPrivilegesAsText
is null, but this still results in many test failures. Also considering the use of String
type as suggested by @wkurniawan07 without indexing, perhaps that would be a better solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, is it possible to just use String
type?
@@ -52,7 +52,7 @@ | |||
@Unindex | |||
private String displayedName; | |||
|
|||
private Text instructorPrivilegesAsText; | |||
private StringValue instructorPrivilegesAsText; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was implicitly unindexed as the type was Text
, but best to just add @Unindex
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was pondering over this for a while too! I read that for text strings longer than 1500 bytes (which are not indexed), we should use a Text
instance but it is no longer available now. @Unindex
can be added to overcome the 1500 bytes limit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
} | ||
|
||
public void setQuestionText(String questionText) { | ||
this.questionText = questionText == null ? null : new Text(questionText); | ||
this.questionText = questionText == null ? null : questionText; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all these getters and setter you can just return or set as is, because there is no object wrapper anymore
@@ -52,7 +51,8 @@ | |||
@Unindex | |||
private String displayedName; | |||
|
|||
private Text instructorPrivilegesAsText; | |||
@Unindex | |||
private String instructorPrivileges; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is backward-incompatible and will require data migration. Let's not change the field name.
a3e6934
to
7631b94
Compare
…tastore Text type
* Replace usage of Text type from appengine datastore api with StringValue * Use unindexed String as alternative over StringValue previously used to replace Text * Simplify getters and setters * Remove redundant architecture test method after deprecating use of datastore Text type
* Replace usage of Text type from appengine datastore api with StringValue * Use unindexed String as alternative over StringValue previously used to replace Text * Simplify getters and setters * Remove redundant architecture test method after deprecating use of datastore Text type
* Replace usage of Text type from appengine datastore api with StringValue * Use unindexed String as alternative over StringValue previously used to replace Text * Simplify getters and setters * Remove redundant architecture test method after deprecating use of datastore Text type
* Replace usage of Text type from appengine datastore api with StringValue * Use unindexed String as alternative over StringValue previously used to replace Text * Simplify getters and setters * Remove redundant architecture test method after deprecating use of datastore Text type
* Replace usage of Text type from appengine datastore api with StringValue * Use unindexed String as alternative over StringValue previously used to replace Text * Simplify getters and setters * Remove redundant architecture test method after deprecating use of datastore Text type
* Replace usage of Text type from appengine datastore api with StringValue * Use unindexed String as alternative over StringValue previously used to replace Text * Simplify getters and setters * Remove redundant architecture test method after deprecating use of datastore Text type
* Replace usage of Text type from appengine datastore api with StringValue * Use unindexed String as alternative over StringValue previously used to replace Text * Simplify getters and setters * Remove redundant architecture test method after deprecating use of datastore Text type
* Replace usage of Text type from appengine datastore api with StringValue * Use unindexed String as alternative over StringValue previously used to replace Text * Simplify getters and setters * Remove redundant architecture test method after deprecating use of datastore Text type
…1019) * Replace usage of Text type from appengine datastore api with StringValue * Use unindexed String as alternative over StringValue previously used to replace Text * Simplify getters and setters * Remove redundant architecture test method after deprecating use of datastore Text type
Part of #11001
This PR cleans up existing code which still contain traces using the old
com.google.appengine.api
used before the Objectify 6 migration.In Objectify 6, there's no way to explicitly store a
Text
type with the Google-provided SDK. The alternative,StringValue
does not supportnull
.Text
type from thecom.google.appengine.api.datastore
package used in Objectify 5 with unindexedString
.