From 86870dcf6acb9d1e23354666893a440bfa1059a8 Mon Sep 17 00:00:00 2001 From: Yingjian Wu Date: Thu, 7 Mar 2024 17:37:15 -0500 Subject: [PATCH] address comments --- .../metadata/mysql/MySqlLookupService.java | 3 +-- .../mysql/MySqlLookupServiceSpec.groovy | 17 +++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlLookupService.java b/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlLookupService.java index 3b0217f7c..0f32974aa 100644 --- a/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlLookupService.java +++ b/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlLookupService.java @@ -50,8 +50,7 @@ public class MySqlLookupService implements LookupService { private static final String SQL_INSERT_LOOKUP_VALUES = "insert into lookup_values( lookup_id, values_string) values (?,?)"; private static final String SQL_INSERT_LOOKUP_VALUE_IF_NOT_EXIST = - "INSERT INTO lookup_values(lookup_id, values_string) VALUES (?,?) " - + "ON DUPLICATE KEY UPDATE lookup_id=lookup_id, values_string=values_string"; + "INSERT IGNORE INTO lookup_values (lookup_id, values_string) VALUES (?, ?)"; private static final String SQL_GET_LOOKUP_VALUES = "select values_string value from lookup_values where lookup_id=?"; diff --git a/metacat-metadata-mysql/src/test/groovy/com/netflix/metacat/metadata/mysql/MySqlLookupServiceSpec.groovy b/metacat-metadata-mysql/src/test/groovy/com/netflix/metacat/metadata/mysql/MySqlLookupServiceSpec.groovy index 644948913..c82f537fb 100644 --- a/metacat-metadata-mysql/src/test/groovy/com/netflix/metacat/metadata/mysql/MySqlLookupServiceSpec.groovy +++ b/metacat-metadata-mysql/src/test/groovy/com/netflix/metacat/metadata/mysql/MySqlLookupServiceSpec.groovy @@ -50,7 +50,7 @@ class MySqlLookupServiceSpec extends Specification { def lookupWithValues = new Lookup( id: 1L, name: 'Test1', - values: new HashSet(['tag1', 'tag2']), + values: new HashSet(['tag1', 'tag1', 'tag2']), dateCreated: new Date(), lastUpdated: new Date() ) @@ -68,12 +68,13 @@ class MySqlLookupServiceSpec extends Specification { then: lookUpResult.values == expectedValues where: - tagsToAdd | includeValues | expectedValues - ['tag1', 'tag2'] as Set |true | ['tag1', 'tag2'] as Set - ['tag1', 'tag2'] as Set |false | [] as Set - ['tag1', 'tag3'] as Set |true | ['tag1', 'tag2', 'tag3'] as Set - ['tag1', 'tag3'] as Set |false | [] as Set - ['tag3', 'tag4'] as Set |true | ['tag1', 'tag2', 'tag3', 'tag4'] as Set - ['tag3', 'tag4'] as Set |false | [] as Set + tagsToAdd | includeValues | expectedValues + ['tag1', 'tag2'] as Set |true | ['tag1', 'tag2'] as Set + ['tag1', 'tag2'] as Set |false | [] as Set + ['tag1', 'tag3'] as Set |true | ['tag1', 'tag2', 'tag3'] as Set + ['tag1', 'tag3'] as Set |false | [] as Set + ['tag3', 'tag4'] as Set |true | ['tag1', 'tag2', 'tag3', 'tag4'] as Set + ['tag3', 'tag4'] as Set |false | [] as Set + ['tag3', 'tag3', 'tag4'] as Set |true | ['tag1', 'tag2', 'tag3', 'tag4'] as Set } }