Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Yingjian Wu committed Mar 7, 2024
1 parent c2f395d commit 86870dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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=?";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class MySqlLookupServiceSpec extends Specification {
def lookupWithValues = new Lookup(
id: 1L,
name: 'Test1',
values: new HashSet<String>(['tag1', 'tag2']),
values: new HashSet<String>(['tag1', 'tag1', 'tag2']),
dateCreated: new Date(),
lastUpdated: new Date()
)
Expand All @@ -68,12 +68,13 @@ class MySqlLookupServiceSpec extends Specification {
then:
lookUpResult.values == expectedValues
where:
tagsToAdd | includeValues | expectedValues
['tag1', 'tag2'] as Set<String> |true | ['tag1', 'tag2'] as Set<String>
['tag1', 'tag2'] as Set<String> |false | [] as Set<String>
['tag1', 'tag3'] as Set<String> |true | ['tag1', 'tag2', 'tag3'] as Set<String>
['tag1', 'tag3'] as Set<String> |false | [] as Set<String>
['tag3', 'tag4'] as Set<String> |true | ['tag1', 'tag2', 'tag3', 'tag4'] as Set<String>
['tag3', 'tag4'] as Set<String> |false | [] as Set<String>
tagsToAdd | includeValues | expectedValues
['tag1', 'tag2'] as Set<String> |true | ['tag1', 'tag2'] as Set<String>
['tag1', 'tag2'] as Set<String> |false | [] as Set<String>
['tag1', 'tag3'] as Set<String> |true | ['tag1', 'tag2', 'tag3'] as Set<String>
['tag1', 'tag3'] as Set<String> |false | [] as Set<String>
['tag3', 'tag4'] as Set<String> |true | ['tag1', 'tag2', 'tag3', 'tag4'] as Set<String>
['tag3', 'tag4'] as Set<String> |false | [] as Set<String>
['tag3', 'tag3', 'tag4'] as Set<String> |true | ['tag1', 'tag2', 'tag3', 'tag4'] as Set<String>
}
}

0 comments on commit 86870dc

Please sign in to comment.