MCPcopy Create free account
hub / github.com/YACReader/yacreader / bindValues

Method bindValues

YACReaderLibrary/db/query_parser.cpp:98–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98int QueryParser::TreeNode::bindValues(QSqlQuery &selectQuery, int bindPosition) const
99{
100 if (t == "expression") {
101 std::string bind_string(":bindPosition" + std::to_string(++bindPosition));
102 if (isIn(fieldType(children[0].t), { FieldType::numeric })) {
103 selectQuery.bindValue(QString::fromStdString(bind_string), std::stoi(children[1].t));
104 } else if (isIn(fieldType(children[0].t), { FieldType::boolean, FieldType::booleanFolder })) {
105 auto value = toLower(children[1].t);
106 if (value == "true") {
107 selectQuery.bindValue(QString::fromStdString(bind_string), 1);
108 } else if (value == "false") {
109 selectQuery.bindValue(QString::fromStdString(bind_string), 0);
110 } else {
111 selectQuery.bindValue(QString::fromStdString(bind_string), std::stoi(value));
112 }
113 } else if ((isIn(fieldType(children[0].t), { FieldType::enumField, FieldType::enumFieldFolder }))) {
114 auto enumType = children[0].t;
115 auto value = toLower(children[1].t);
116 if (enumType == "type" || enumType == "foldertype") {
117 if (value == "comic") {
118 selectQuery.bindValue(QString::fromStdString(bind_string), 0);
119 } else if (value == "manga") {
120 selectQuery.bindValue(QString::fromStdString(bind_string), 1);
121 } else if (value == "westernmanga") {
122 selectQuery.bindValue(QString::fromStdString(bind_string), 2);
123 } else if (value == "webcomic" || value == "web") {
124 selectQuery.bindValue(QString::fromStdString(bind_string), 3);
125 } else if (value == "4koma" || value == "yonkoma") {
126 selectQuery.bindValue(QString::fromStdString(bind_string), 4);
127 }
128 } else {
129 selectQuery.bindValue(QString::fromStdString(bind_string), std::stoi(children[1].t));
130 }
131 } else if ((isIn(fieldType(children[0].t), { FieldType::date, FieldType::dateFolder }))) {
132 selectQuery.bindValue(QString::fromStdString(bind_string), QString::fromStdString(parseDate(children[1].t, expOperator)));
133 } else {
134 if (expOperator == "=" || expOperator == ":" || expOperator == "") {
135 selectQuery.bindValue(QString::fromStdString(bind_string), QString::fromStdString("%%" + children[1].t + "%%"));
136 } else {
137 selectQuery.bindValue(QString::fromStdString(bind_string), QString::fromStdString(children[1].t));
138 }
139 }
140 } else if (t == "not") {
141 bindPosition = children[0].bindValues(selectQuery, bindPosition);
142 } else {
143 bindPosition = children[0].bindValues(selectQuery, bindPosition);
144 bindPosition = children[1].bindValues(selectQuery, bindPosition);
145 }
146
147 return bindPosition;
148}
149
150QueryParser::QueryParser()
151{

Callers 2

foldersSearchQueryFunction · 0.80
comicsSearchQueryFunction · 0.80

Calls 2

parseDateFunction · 0.85
bindValueMethod · 0.80

Tested by

no test coverage detected