You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2021/08/02 12:11:26 UTC

[GitHub] [dolphinscheduler] ruanwenjun commented on a change in pull request #5931: [Improvement][Dao] SQL optimization - check exist #5930

ruanwenjun commented on a change in pull request #5931:
URL: https://github.com/apache/dolphinscheduler/pull/5931#discussion_r680909636



##########
File path: dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
##########
@@ -176,8 +177,7 @@
     }
 
     private boolean checkName(String name) {

Review comment:
       It might be better to rename this method to checkDatasourceNameExist, what do you think?

##########
File path: dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.java
##########
@@ -189,4 +189,12 @@ ProcessDefinition queryByDefineName(@Param("projectCode") Long projectCode,
      * @return definition id
      */
     Integer queryHasAssociatedDefinitionByIdAndVersion(@Param("processDefinitionId") int processDefinitionId, @Param("version") long version);
+
+    /**
+     *
+     * @param projectCode projectCode
+     * @param name name
+     * @return if exist return true else return null
+     */
+    Boolean existDefByProjectCodeAndDefineName(@Param("projectCode") Long projectCode, @Param("processDefinitionName") String name);

Review comment:
       This method hasn't been used.

##########
File path: dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.xml
##########
@@ -180,4 +180,16 @@
         where id = #{processDefinitionId}
         and version = #{version} limit 1
     </select>
+
+    <select id="existDefByProjectCodeAndDefineName" resultType="java.lang.Boolean">
+        select 1
+        from t_ds_process_definition pd
+        JOIN t_ds_user u ON pd.user_id = u.id

Review comment:
       It seems that we just need to join the `t_ds_project` table, am I right?
   ```sql
   select 1 from t_ds_process_definition pd
   JOIN t_ds_project p ON pd.project_code = p.code
   WHERE p.code = #{projectCode}
   and pd.name = #{processDefinitionName}
   ```




-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org