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

[#11001] Migrate App Engine Text datastore type #11019

Conversation

jianhandev
Copy link
Contributor

@jianhandev jianhandev commented Mar 7, 2021

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 support null.

  • Replace Text type from the com.google.appengine.api.datastore package used in Objectify 5 with unindexed String.

@teammates-bot
Copy link

Hi @jianhandev, these parts of your pull request do not appear to follow our contributing guidelines:

  1. PR Title
    • Issue Reference (#<issue-number>) missing.

@jianhandev jianhandev changed the title Migrate appengine datastore API usage [#11001] Migrate appengine datastore API usage Mar 7, 2021
@jianhandev jianhandev added the s.Ongoing The PR is being worked on by the author(s) label Mar 7, 2021
@Derek-Hardy Derek-Hardy self-assigned this Mar 8, 2021
}

public void setInstructorPrivilegeAsText(String instructorPrivilegesAsText) {
this.instructorPrivilegesAsText = new Text(instructorPrivilegesAsText);
this.instructorPrivilegesAsText = new StringValue(instructorPrivilegesAsText);
Copy link
Contributor

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);
}

Copy link
Contributor Author

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.

Copy link
Member

@wkurniawan07 wkurniawan07 left a 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;
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@Derek-Hardy Derek-Hardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Derek-Hardy Derek-Hardy added s.FinalReview The PR is ready for final review and removed s.Ongoing The PR is being worked on by the author(s) labels Mar 9, 2021
}

public void setQuestionText(String questionText) {
this.questionText = questionText == null ? null : new Text(questionText);
this.questionText = questionText == null ? null : questionText;
Copy link
Member

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;
Copy link
Member

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.

@jianhandev jianhandev force-pushed the 11001-remove-appengine-api-datastore-usage branch from a3e6934 to 7631b94 Compare March 9, 2021 11:16
@jianhandev jianhandev changed the title [#11001] Migrate appengine datastore API usage [#11001] Migrate App Engine Text datastore type Mar 10, 2021
@Derek-Hardy Derek-Hardy added s.ToMerge The PR is approved by all reviewers including final reviewer; ready for merging and removed s.FinalReview The PR is ready for final review labels Mar 11, 2021
@Derek-Hardy Derek-Hardy merged commit b0fcb4e into TEAMMATES:objectify-v6-migration Mar 12, 2021
wkurniawan07 pushed a commit that referenced this pull request Mar 22, 2021
* 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
wkurniawan07 pushed a commit that referenced this pull request Mar 22, 2021
* 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
wkurniawan07 pushed a commit that referenced this pull request Mar 23, 2021
* 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
@wkurniawan07 wkurniawan07 added this to the V8.0.0 milestone Apr 25, 2021
wkurniawan07 pushed a commit that referenced this pull request Apr 28, 2021
* 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
wkurniawan07 pushed a commit that referenced this pull request May 3, 2021
* 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
wkurniawan07 pushed a commit that referenced this pull request Jun 2, 2021
* 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
wkurniawan07 pushed a commit that referenced this pull request Jun 6, 2021
* 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
@wkurniawan07 wkurniawan07 added the c.Task Other non-user-facing works, e.g. refactoring, adding tests label Jun 6, 2021
wkurniawan07 pushed a commit that referenced this pull request Jun 6, 2021
* 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
daongochieu2810 pushed a commit to daongochieu2810/teammates that referenced this pull request Jul 5, 2021
…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
@jianhandev jianhandev deleted the 11001-remove-appengine-api-datastore-usage branch August 4, 2023 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c.Task Other non-user-facing works, e.g. refactoring, adding tests s.ToMerge The PR is approved by all reviewers including final reviewer; ready for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants