Copilot commented on code in PR #2938:
URL:
https://github.com/apache/incubator-hugegraph/pull/2938#discussion_r2690026198
##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/builder/VertexLabelBuilder.java:
##########
@@ -546,7 +533,25 @@ private void checkStableVars() {
}
}
- private void checkTtl() {
+ /**
+ * Update TTL in two cases:
+ * 1) ttl > 0L: set or change a positive TTL
+ * 2) ttl == 0L and existing ttl > 0L: explicitly clear an existing TTL
+ * This allows removing TTL from a label that previously had TTL
configured.
+ */
+ private void updateTTL(VertexLabel vertexLabel) {
+ if (this.ttl > 0L) {
+ vertexLabel.ttl(this.ttl);
+ if (this.ttlStartTime != null) {
+
vertexLabel.ttlStartTime(this.graph().propertyKey(this.ttlStartTime).id());
+ }
+ } else if (this.ttl == 0L && vertexLabel.ttl() > 0L) {
Review Comment:
The condition `this.ttl == 0L` will be true even when `this.ttl` was never
explicitly set by the user (default is 0). This means that appending any schema
change without specifying TTL will inadvertently clear an existing TTL.
Consider tracking whether TTL was explicitly set, or check if this behavior is
intentional.
##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/builder/EdgeLabelBuilder.java:
##########
@@ -670,7 +667,25 @@ private void checkStableVars() {
}
}
- private void checkTtl() {
+ /**
+ * Update TTL in two cases:
+ * 1) ttl > 0L: set or change a positive TTL
+ * 2) ttl == 0L and existing ttl > 0L: explicitly clear an existing TTL
+ * This allows removing TTL from a label that previously had TTL
configured.
+ */
+ private void updateTTL(EdgeLabel edgeLabel) {
+ if (this.ttl > 0L) {
+ edgeLabel.ttl(this.ttl);
+ if (this.ttlStartTime != null) {
+
edgeLabel.ttlStartTime(this.graph().propertyKey(this.ttlStartTime).id());
+ }
+ } else if (this.ttl == 0L && edgeLabel.ttl() > 0L) {
Review Comment:
The condition `this.ttl == 0L` will be true even when `this.ttl` was never
explicitly set by the user (default is 0). This means that appending any schema
change without specifying TTL will inadvertently clear an existing TTL.
Consider tracking whether TTL was explicitly set, or check if this behavior is
intentional.
--
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]