Copilot commented on code in PR #8125:
URL: https://github.com/apache/texera/pull/8125#discussion_r3899553160
##########
sql/texera_ddl.sql:
##########
@@ -166,7 +166,10 @@ CREATE TABLE IF NOT EXISTS workflow
content TEXT NOT NULL,
creation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
last_modified_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
- is_public BOOLEAN NOT NULL DEFAULT false
+ is_public BOOLEAN NOT NULL DEFAULT false,
+ -- Which view the workflow opens in by default (CANVAS or FORM); the
form's definition
+ -- lives in workflow.content (`formBinding`).
+ default_view VARCHAR NOT NULL DEFAULT 'CANVAS'
Review Comment:
Fresh databases also need the `CANVAS`/`FORM` constraint; otherwise direct
inserts through the workflow create/persist DTO can store arbitrary strings
despite the setter endpoint's validation. Keep this definition aligned with
`44.sql` by adding the same check.
##########
sql/updates/44.sql:
##########
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+\c texera_db
+
+SET search_path TO texera_db;
+
+BEGIN;
+
+-- Which view a workflow opens in by default (CANVAS or FORM). The form's
definition lives
+-- in workflow.content under `formBinding`; only this preference is
denormalized so listing
+-- endpoints need not parse every row's content. It never gates availability
-- the form is
+-- reachable for every workflow.
+ALTER TABLE workflow
+ ADD COLUMN IF NOT EXISTS default_view VARCHAR NOT NULL DEFAULT 'CANVAS';
Review Comment:
The `CANVAS`/`FORM` invariant is not enforced here. Although
`/set-default-view` validates its body, `/workflow/create` and new-workflow
`/workflow/persist` deserialize the same generated `Workflow` POJO and pass it
directly to `workflowDao.insert`, so a client can persist any non-null
`defaultView` value and bypass that validation. Add a database constraint (and
mirror it in `texera_ddl.sql`) so every write path preserves the enum contract.
--
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]