refs #703: fix Smilegate annotation metadata query
This commit is contained in:
@@ -20,10 +20,7 @@ public interface SchemaMetadataMapper {
|
||||
@Param("tableName") String tableName
|
||||
);
|
||||
|
||||
List<SchemaMetadataAnnotationRow> findAnnotations(
|
||||
@Param("owner") String owner,
|
||||
@Param("tableName") String tableName
|
||||
);
|
||||
List<SchemaMetadataAnnotationRow> findAnnotations(@Param("tableName") String tableName);
|
||||
|
||||
int countColumn(
|
||||
@Param("owner") String owner,
|
||||
@@ -32,13 +29,11 @@ public interface SchemaMetadataMapper {
|
||||
);
|
||||
|
||||
int countTableAnnotation(
|
||||
@Param("owner") String owner,
|
||||
@Param("tableName") String tableName,
|
||||
@Param("annotationName") String annotationName
|
||||
);
|
||||
|
||||
int countColumnAnnotation(
|
||||
@Param("owner") String owner,
|
||||
@Param("tableName") String tableName,
|
||||
@Param("columnName") String columnName,
|
||||
@Param("annotationName") String annotationName
|
||||
|
||||
@@ -148,7 +148,7 @@ public class SchemaMetadataService {
|
||||
|
||||
private Map<String, List<SchemaAnnotation>> annotationsByTarget(String tableName) {
|
||||
Map<String, LinkedHashMap<String, List<String>>> grouped = new LinkedHashMap<>();
|
||||
for (SchemaMetadataAnnotationRow row : mapper.findAnnotations(OWNER, tableName)) {
|
||||
for (SchemaMetadataAnnotationRow row : mapper.findAnnotations(tableName)) {
|
||||
String target = row.columnName() == null
|
||||
? tableTargetKey()
|
||||
: columnTargetKey(row.columnName());
|
||||
@@ -172,8 +172,8 @@ public class SchemaMetadataService {
|
||||
|
||||
private boolean annotationExists(String tableName, String columnName, String annotationName) {
|
||||
return columnName == null
|
||||
? mapper.countTableAnnotation(OWNER, tableName, annotationName) > 0
|
||||
: mapper.countColumnAnnotation(OWNER, tableName, columnName, annotationName) > 0;
|
||||
? mapper.countTableAnnotation(tableName, annotationName) > 0
|
||||
: mapper.countColumnAnnotation(tableName, columnName, annotationName) > 0;
|
||||
}
|
||||
|
||||
private String requireColumn(String tableName, String columnName) {
|
||||
|
||||
@@ -39,8 +39,7 @@
|
||||
annotation_name,
|
||||
annotation_value
|
||||
FROM all_annotations_usage
|
||||
WHERE object_owner = #{owner,jdbcType=VARCHAR}
|
||||
AND object_name = #{tableName,jdbcType=VARCHAR}
|
||||
WHERE object_name = #{tableName,jdbcType=VARCHAR}
|
||||
AND object_type = 'TABLE'
|
||||
ORDER BY column_name NULLS FIRST, annotation_name, annotation_value
|
||||
</select>
|
||||
@@ -56,8 +55,7 @@
|
||||
<select id="countTableAnnotation" resultType="int">
|
||||
SELECT COUNT(*)
|
||||
FROM all_annotations_usage
|
||||
WHERE object_owner = #{owner,jdbcType=VARCHAR}
|
||||
AND object_name = #{tableName,jdbcType=VARCHAR}
|
||||
WHERE object_name = #{tableName,jdbcType=VARCHAR}
|
||||
AND object_type = 'TABLE'
|
||||
AND annotation_name = #{annotationName,jdbcType=VARCHAR}
|
||||
AND column_name IS NULL
|
||||
@@ -66,8 +64,7 @@
|
||||
<select id="countColumnAnnotation" resultType="int">
|
||||
SELECT COUNT(*)
|
||||
FROM all_annotations_usage
|
||||
WHERE object_owner = #{owner,jdbcType=VARCHAR}
|
||||
AND object_name = #{tableName,jdbcType=VARCHAR}
|
||||
WHERE object_name = #{tableName,jdbcType=VARCHAR}
|
||||
AND object_type = 'TABLE'
|
||||
AND annotation_name = #{annotationName,jdbcType=VARCHAR}
|
||||
AND column_name = #{columnName,jdbcType=VARCHAR}
|
||||
|
||||
Reference in New Issue
Block a user