Skip to content

Commit

Permalink
Fix pg bug (#4807)
Browse files Browse the repository at this point in the history
* fix missing backtick in mysql keywords

* fix pg bug
  • Loading branch information
sjgllgh authored Jul 25, 2023
1 parent a4c4d12 commit 1cbd17f
Show file tree
Hide file tree
Showing 25 changed files with 805 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >

<mapper namespace="org.apache.linkis.engineplugin.server.dao.EngineConnBmlResourceDao">


<sql id="bml_resources">
engine_conn_type,version,file_name,file_size,last_modified,bml_resource_id,bml_resource_version,create_time,last_update_time
</sql>

<select id="getAllEngineConnBmlResource"
resultType="org.apache.linkis.engineplugin.server.entity.EngineConnBmlResource">
SELECT * FROM linkis_cg_engine_conn_plugin_bml_resources
WHERE engine_conn_type=#{engineConnType} and version=#{version}
</select>

<select id="getTypeVersionList" resultType="java.lang.String">
SELECT version FROM linkis_cg_engine_conn_plugin_bml_resources where engine_conn_type = #{type} GROUP BY version
</select>

<select id="getTypeList" resultType="java.lang.String">
SELECT engine_conn_type FROM linkis_cg_engine_conn_plugin_bml_resources GROUP BY engine_conn_type
</select>

<select id="selectByPageVo"
resultType="org.apache.linkis.engineplugin.server.entity.EngineConnBmlResource">
SELECT
*
FROM linkis_cg_engine_conn_plugin_bml_resources
<where>
<if test="engineConnType != null and engineConnType != ''">
AND engine_conn_type like concat('%', #{engineConnType}::text, '%')
</if>
<if test="engineConnVersion != null and engineConnVersion != ''">
AND version like concat('%', #{engineConnVersion}::text, '%')
</if>
</where>
ORDER BY create_time DESC
</select>

<delete id="delete" parameterType="org.apache.linkis.engineplugin.server.entity.EngineConnBmlResource">
DELETE FROM linkis_cg_engine_conn_plugin_bml_resources
WHERE engine_conn_type = #{engineConnBmlResource.engineConnType}
AND version = #{engineConnBmlResource.version}
AND file_name = #{engineConnBmlResource.fileName}
</delete>

<update id="update" parameterType="org.apache.linkis.engineplugin.server.entity.EngineConnBmlResource">
UPDATE linkis_cg_engine_conn_plugin_bml_resources
<set>
<if test="engineConnBmlResource.lastModified != null">last_modified =
#{engineConnBmlResource.lastModified},
</if>
<if test="engineConnBmlResource.fileSize != null">file_size = #{engineConnBmlResource.fileSize},</if>
<if test="engineConnBmlResource.bmlResourceVersion != null">bml_resource_version =
#{engineConnBmlResource.bmlResourceVersion},
</if>
<if test="engineConnBmlResource.lastUpdateTime != null">last_update_time =
#{engineConnBmlResource.lastUpdateTime},
</if>
</set>
WHERE engine_conn_type=#{engineConnBmlResource.engineConnType} and version=#{engineConnBmlResource.version}
AND file_name=#{engineConnBmlResource.fileName}
</update>

<insert id="save" parameterType="org.apache.linkis.engineplugin.server.entity.EngineConnBmlResource">
INSERT INTO linkis_cg_engine_conn_plugin_bml_resources(<include refid="bml_resources"/>)
VALUES (#{engineConnBmlResource.engineConnType}, #{engineConnBmlResource.version},
#{engineConnBmlResource.fileName},#{engineConnBmlResource.fileSize},
#{engineConnBmlResource.lastModified},#{engineConnBmlResource.bmlResourceId},
#{engineConnBmlResource.bmlResourceVersion},
#{engineConnBmlResource.createTime}, #{engineConnBmlResource.lastUpdateTime})
</insert>


</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<if test="instance != null">service_instance = #{instance}</if>
<if test="username != null">and create_user = #{username}</if>
<!-- label_value in db eg:`hadoop-spark,spark-3.2.1`-->
<if test="engineType !=null">and label_value like concat('%,',#{engineType},'%')</if>
<if test="engineType !=null">and label_value like concat('%,',#{engineType}::text,'%')</if>
<if test="startDate != null">and create_time BETWEEN #{startDate} AND #{endDate}</if>
</where>
ORDER BY linkis_cg_ec_resource_info_record.create_time DESC
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->

<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">


<mapper namespace="org.apache.linkis.basedatamanager.server.dao.DatasourceAccessMapper">

<resultMap id="BaseResultMap" type="org.apache.linkis.basedatamanager.server.domain.DatasourceAccessEntity">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="tableId" column="table_id" jdbcType="BIGINT"/>
<result property="visitor" column="visitor" jdbcType="VARCHAR"/>
<result property="fields" column="fields" jdbcType="VARCHAR"/>
<result property="applicationId" column="application_id" jdbcType="INTEGER"/>
<result property="accessTime" column="access_time" jdbcType="TIMESTAMP"/>
</resultMap>

<sql id="Base_Column_List">
id,table_id,visitor,
fields,application_id,access_time
</sql>

<select id="getListByPage" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"></include>
FROM linkis_ps_datasource_access
<if test="searchName != null and searchName!=''">
WHERE visitor LIKE concat('%',#{searchName}::text,'%')
OR fields LIKE concat('%',#{searchName}::text,'%')
</if>
</select>
</mapper>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.apache.linkis.basedatamanager.server.dao.DatasourceEnvMapper">

<resultMap id="BaseResultMap" type="org.apache.linkis.basedatamanager.server.domain.DatasourceEnvEntity">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="envName" column="env_name" jdbcType="VARCHAR"/>
<result property="envDesc" column="env_desc" jdbcType="VARCHAR"/>
<result property="datasourceTypeId" column="datasource_type_id" jdbcType="INTEGER"/>
<result property="parameter" column="parameter" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="createUser" column="create_user" jdbcType="VARCHAR"/>
<result property="modifyTime" column="modify_time" jdbcType="TIMESTAMP"/>
<result property="modifyUser" column="modify_user" jdbcType="VARCHAR"/>
</resultMap>

<sql id="Base_Column_List">
id,env_name,env_desc,
datasource_type_id,parameter,create_time,
create_user,modify_time,modify_user
</sql>

<select id="getListByPage" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"></include>
FROM linkis_ps_dm_datasource_env
<if test="searchName != null and searchName!=''">
WHERE env_name LIKE concat('%',#{searchName}::text,'%')
OR env_desc LIKE concat('%',#{searchName}::text,'%')
OR parameter LIKE concat('%',#{searchName}::text,'%')
</if>
</select>
</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
from linkis_ps_dm_datasource_type_key
where 1 = 1
<if test="searchName != null and searchName!=''">
and "name" like concat('%',#{searchName},'%')
and "name" like concat('%',#{searchName}::text,'%')
</if>
<if test="dataSourceTypeId != null and dataSourceTypeId!=''">
and "data_source_type_id" = #{dataSourceTypeId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
<include refid="Base_Column_List"></include>
from linkis_ps_dm_datasource_type
<if test="searchName != null and searchName!=''">
WHERE "name" LIKE concat('%',#{searchName},'%')
OR "description" LIKE concat('%',#{searchName},'%')
OR "option" LIKE concat('%',#{searchName},'%')
OR "classifier" LIKE concat('%',#{searchName},'%')
WHERE "name" LIKE concat('%',#{searchName}::text,'%')
OR "description" LIKE concat('%',#{searchName}::text,'%')
OR "option" LIKE concat('%',#{searchName}::text,'%')
OR "classifier" LIKE concat('%',#{searchName}::text,'%')
</if>
</select>
</mapper>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.apache.linkis.basedatamanager.server.dao.GatewayAuthTokenMapper">

<resultMap id="BaseResultMap" type="org.apache.linkis.basedatamanager.server.domain.GatewayAuthTokenEntity">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="tokenName" column="token_name" jdbcType="VARCHAR"/>
<result property="legalUsers" column="legal_users" jdbcType="VARCHAR"/>
<result property="legalHosts" column="legal_hosts" jdbcType="VARCHAR"/>
<result property="businessOwner" column="business_owner" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="DATE"/>
<result property="updateTime" column="update_time" jdbcType="DATE"/>
<result property="elapseDay" column="elapse_day" jdbcType="BIGINT"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
</resultMap>

<sql id="Base_Column_List">
id,token_name,legal_users,
legal_hosts,business_owner,create_time,
update_time,elapse_day,update_by
</sql>

<select id="getListByPage" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"></include>
FROM linkis_mg_gateway_auth_token
<if test="searchName != null and searchName!=''">
WHERE token_name LIKE concat('%',#{searchName}::text,'%')
OR legal_users LIKE concat('%',#{searchName}::text,'%')
OR legal_hosts LIKE concat('%',#{searchName}::text,'%')
</if>
</select>
</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
<include refid="Base_Column_List"></include>
from linkis_ps_error_code
<if test="searchName != null and searchName!=''">
where error_code like concat('%',#{searchName},'%')
or error_desc like concat('%',#{searchName},'%')
or error_regex like concat('%',#{searchName},'%')
or error_type::text like concat('%',#{searchName},'%')
where error_code like concat('%',#{searchName}::text,'%')
or error_desc like concat('%',#{searchName}::text,'%')
or error_regex like concat('%',#{searchName}::text,'%')
or error_type::text like concat('%',#{searchName}::text,'%')
</if>
</select>
</mapper>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.apache.linkis.basedatamanager.server.dao.RmExternalResourceProviderMapper">

<resultMap id="BaseResultMap" type="org.apache.linkis.basedatamanager.server.domain.RmExternalResourceProviderEntity">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="resourceType" column="resource_type" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="labels" column="labels" jdbcType="VARCHAR"/>
<result property="config" column="config" jdbcType="VARCHAR"/>
</resultMap>

<sql id="Base_Column_List">
id,resource_type,name,
labels,config
</sql>

<select id="getListByPage" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"></include>
FROM linkis_cg_rm_external_resource_provider
<if test="searchName != null and searchName!=''">
WHERE resource_type LIKE concat('%',#{searchName}::text,'%')
OR name LIKE concat('%',#{searchName}::text,'%')
OR labels LIKE concat('%',#{searchName}::text,'%')
OR config LIKE concat('%',#{searchName}::text,'%')
</if>
</select>
</mapper>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.apache.linkis.basedatamanager.server.dao.UdfManagerMapper">

<resultMap id="BaseResultMap" type="org.apache.linkis.basedatamanager.server.domain.UdfManagerEntity">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="userName" column="user_name" jdbcType="VARCHAR"/>
</resultMap>

<sql id="Base_Column_List">
id,user_name
</sql>

<select id="getListByPage" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"></include>
FROM linkis_ps_udf_manager
<if test="searchName != null and searchName!=''">
WHERE user_name LIKE concat('%',#{searchName}::text,'%')
</if>
</select>
</mapper>
Loading

0 comments on commit 1cbd17f

Please sign in to comment.