mirror of
https://github.com/correl/mage.git
synced 2024-12-25 19:25:41 +00:00
[CardRepository] Fixed searching for Strings containing apostrophe
This commit is contained in:
parent
021a00400d
commit
86702ec437
2 changed files with 11 additions and 9 deletions
|
@ -28,6 +28,7 @@
|
|||
package mage.cards.repository;
|
||||
|
||||
import com.j256.ormlite.stmt.QueryBuilder;
|
||||
import com.j256.ormlite.stmt.SelectArg;
|
||||
import com.j256.ormlite.stmt.Where;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -158,11 +159,11 @@ public class CardCriteria {
|
|||
Where where = qb.where();
|
||||
int clausesCount = 0;
|
||||
if (name != null) {
|
||||
where.like("name", '%' + name + '%');
|
||||
where.like("name", new SelectArg('%' + name + '%'));
|
||||
clausesCount++;
|
||||
}
|
||||
if (rules != null) {
|
||||
where.like("rules", '%' + rules + '%');
|
||||
where.like("rules", new SelectArg('%' + rules + '%'));
|
||||
clausesCount++;
|
||||
}
|
||||
|
||||
|
@ -175,7 +176,7 @@ public class CardCriteria {
|
|||
}
|
||||
|
||||
for (CardType type : types) {
|
||||
where.like("types", '%' + type.name() + '%');
|
||||
where.like("types", new SelectArg('%' + type.name() + '%'));
|
||||
}
|
||||
if (!types.isEmpty()) {
|
||||
where.or(types.size());
|
||||
|
@ -183,21 +184,21 @@ public class CardCriteria {
|
|||
}
|
||||
|
||||
for (CardType type : notTypes) {
|
||||
where.not().like("types", '%' + type.name() + '%');
|
||||
where.not().like("types", new SelectArg('%' + type.name() + '%'));
|
||||
clausesCount++;
|
||||
}
|
||||
|
||||
for (String superType : supertypes) {
|
||||
where.like("supertypes", '%' + superType + '%');
|
||||
where.like("supertypes", new SelectArg('%' + superType + '%'));
|
||||
clausesCount++;
|
||||
}
|
||||
for (String subType : notSupertypes) {
|
||||
where.not().like("supertypes", '%' + subType + '%');
|
||||
where.not().like("supertypes", new SelectArg('%' + subType + '%'));
|
||||
clausesCount++;
|
||||
}
|
||||
|
||||
for (String subType : subtypes) {
|
||||
where.like("subtypes", '%' + subType + '%');
|
||||
where.like("subtypes", new SelectArg('%' + subType + '%'));
|
||||
clausesCount++;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import com.j256.ormlite.dao.Dao;
|
|||
import com.j256.ormlite.dao.DaoManager;
|
||||
import com.j256.ormlite.jdbc.JdbcConnectionSource;
|
||||
import com.j256.ormlite.stmt.QueryBuilder;
|
||||
import com.j256.ormlite.stmt.SelectArg;
|
||||
import com.j256.ormlite.support.ConnectionSource;
|
||||
import com.j256.ormlite.table.TableUtils;
|
||||
import java.io.File;
|
||||
|
@ -123,7 +124,7 @@ public enum CardRepository {
|
|||
public CardInfo findCard(String setCode, int cardNumber) {
|
||||
try {
|
||||
QueryBuilder<CardInfo, Object> queryBuilder = cardDao.queryBuilder();
|
||||
queryBuilder.where().eq("setCode", setCode).and().eq("cardNumber", cardNumber);
|
||||
queryBuilder.where().eq("setCode", new SelectArg(setCode)).and().eq("cardNumber", cardNumber);
|
||||
List<CardInfo> result = cardDao.query(queryBuilder.prepare());
|
||||
if (!result.isEmpty()) {
|
||||
return result.get(0);
|
||||
|
@ -149,7 +150,7 @@ public enum CardRepository {
|
|||
public List<CardInfo> findCards(String name) {
|
||||
try {
|
||||
QueryBuilder<CardInfo, Object> queryBuilder = cardDao.queryBuilder();
|
||||
queryBuilder.where().eq("name", name);
|
||||
queryBuilder.where().eq("name", new SelectArg(name));
|
||||
|
||||
return cardDao.query(queryBuilder.prepare());
|
||||
} catch (SQLException ex) {
|
||||
|
|
Loading…
Reference in a new issue