mirror of
https://github.com/YACReader/yacreader
synced 2025-06-03 17:18:23 -04:00
Add support for boolean folder fields
This commit is contained in:
parent
dde60b78ea
commit
f803b54f2e
@ -7,10 +7,11 @@
|
|||||||
const std::map<QueryParser::FieldType, std::vector<std::string>> QueryParser::fieldNames {
|
const std::map<QueryParser::FieldType, std::vector<std::string>> QueryParser::fieldNames {
|
||||||
{ FieldType::numeric, { "numpages", "number", "count", "arcnumber", "arccount" } },
|
{ FieldType::numeric, { "numpages", "number", "count", "arcnumber", "arccount" } },
|
||||||
{ FieldType::text, { "title", "volume", "storyarc", "genere", "writer", "penciller", "inker", "colorist", "letterer", "coverartist", "publisher", "format", "agerating", "synopsis", "characters", "notes" } },
|
{ FieldType::text, { "title", "volume", "storyarc", "genere", "writer", "penciller", "inker", "colorist", "letterer", "coverartist", "publisher", "format", "agerating", "synopsis", "characters", "notes" } },
|
||||||
{ FieldType::boolean, { "isbis", "color" } },
|
{ FieldType::boolean, { "isbis", "color", "read" } },
|
||||||
{ FieldType::date, { "date" } },
|
{ FieldType::date, { "date" } },
|
||||||
{ FieldType::filename, { "filename" } },
|
{ FieldType::filename, { "filename" } },
|
||||||
{ FieldType::folder, { "folder" } }
|
{ FieldType::folder, { "folder" } },
|
||||||
|
{ FieldType::booleanFolder, { "completed", "finished" } },
|
||||||
};
|
};
|
||||||
|
|
||||||
int QueryParser::TreeNode::buildSqlString(std::string &sqlString, int bindPosition) const
|
int QueryParser::TreeNode::buildSqlString(std::string &sqlString, int bindPosition) const
|
||||||
@ -30,6 +31,8 @@ int QueryParser::TreeNode::buildSqlString(std::string &sqlString, int bindPositi
|
|||||||
sqlString += "(UPPER(c." + children[0].t + ") LIKE UPPER(:bindPosition" + std::to_string(bindPosition) + ")) ";
|
sqlString += "(UPPER(c." + children[0].t + ") LIKE UPPER(:bindPosition" + std::to_string(bindPosition) + ")) ";
|
||||||
} else if (fieldType(children[0].t) == FieldType::folder) {
|
} else if (fieldType(children[0].t) == FieldType::folder) {
|
||||||
sqlString += "(UPPER(f.name) LIKE UPPER(:bindPosition" + std::to_string(bindPosition) + ")) ";
|
sqlString += "(UPPER(f.name) LIKE UPPER(:bindPosition" + std::to_string(bindPosition) + ")) ";
|
||||||
|
} else if (fieldType(children[0].t) == FieldType::booleanFolder) {
|
||||||
|
sqlString += "f." + children[0].t + " = :bindPosition" + std::to_string(bindPosition) + " ";
|
||||||
} else {
|
} else {
|
||||||
sqlString += "(UPPER(ci." + children[0].t + ") LIKE UPPER(:bindPosition" + std::to_string(bindPosition) + ")) ";
|
sqlString += "(UPPER(ci." + children[0].t + ") LIKE UPPER(:bindPosition" + std::to_string(bindPosition) + ")) ";
|
||||||
}
|
}
|
||||||
@ -52,7 +55,7 @@ int QueryParser::TreeNode::bindValues(QSqlQuery &selectQuery, int bindPosition)
|
|||||||
{
|
{
|
||||||
if (t == "token") {
|
if (t == "token") {
|
||||||
std::string bind_string(":bindPosition" + std::to_string(++bindPosition));
|
std::string bind_string(":bindPosition" + std::to_string(++bindPosition));
|
||||||
if (isIn(fieldType(children[0].t), { FieldType::numeric, FieldType::boolean })) {
|
if (isIn(fieldType(children[0].t), { FieldType::numeric, FieldType::boolean, FieldType::booleanFolder })) {
|
||||||
selectQuery.bindValue(QString::fromStdString(bind_string), std::stoi(children[1].t));
|
selectQuery.bindValue(QString::fromStdString(bind_string), std::stoi(children[1].t));
|
||||||
} else {
|
} else {
|
||||||
selectQuery.bindValue(QString::fromStdString(bind_string), QString::fromStdString("%%" + children[1].t + "%%"));
|
selectQuery.bindValue(QString::fromStdString(bind_string), QString::fromStdString("%%" + children[1].t + "%%"));
|
||||||
|
@ -81,6 +81,7 @@ private:
|
|||||||
boolean,
|
boolean,
|
||||||
date,
|
date,
|
||||||
folder,
|
folder,
|
||||||
|
booleanFolder,
|
||||||
filename };
|
filename };
|
||||||
static FieldType fieldType(const std::string &str);
|
static FieldType fieldType(const std::string &str);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user