Almost finished implementing Update command fully.
This commit is contained in:
parent
d5c6c52a03
commit
0504ce7fea
5 changed files with 37 additions and 5 deletions
|
@ -52,6 +52,11 @@ void Attribute::setName(string s){
|
||||||
name = s;
|
name = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Attribute::setValue(string s, int index)
|
||||||
|
{
|
||||||
|
values[index] = s;
|
||||||
|
}
|
||||||
|
|
||||||
string Attribute::getType(){
|
string Attribute::getType(){
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ public:
|
||||||
vector<string> getValues();
|
vector<string> getValues();
|
||||||
string getName();
|
string getName();
|
||||||
void setName(string s);
|
void setName(string s);
|
||||||
|
void setValue(string s, int index);
|
||||||
string getType();
|
string getType();
|
||||||
bool isKey();
|
bool isKey();
|
||||||
int getSize();
|
int getSize();
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
void yourAccount()
|
void yourAccount()
|
||||||
{
|
{
|
||||||
|
@ -123,3 +123,4 @@ int main()
|
||||||
else {cout<<"oops";}
|
else {cout<<"oops";}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
33
Parser.cpp
33
Parser.cpp
|
@ -1019,13 +1019,17 @@ vector<string> insertCMD(vector<string> input, DBEngine &engine)
|
||||||
|
|
||||||
vector<string> updateCMD(vector<string> input, DBEngine &engine)
|
vector<string> updateCMD(vector<string> input, DBEngine &engine)
|
||||||
{
|
{
|
||||||
PRelation r(input[0]);
|
Relation r = engine.getTableFromName(input[0]);
|
||||||
|
Relation rcond("TEMP");
|
||||||
|
Relation rfinal("TEMP");
|
||||||
|
|
||||||
input.erase(input.begin());
|
input.erase(input.begin());
|
||||||
|
|
||||||
if(input[0] == "SET")
|
if(input[0] == "SET")
|
||||||
{
|
{
|
||||||
input.erase(input.begin());
|
input.erase(input.begin());
|
||||||
|
vector <Attribute> a = r.getAttributes();
|
||||||
|
|
||||||
|
|
||||||
//parse out ( and send everything until ) into an Expression vector
|
//parse out ( and send everything until ) into an Expression vector
|
||||||
if(input[0] == "(")
|
if(input[0] == "(")
|
||||||
|
@ -1043,8 +1047,6 @@ vector<string> updateCMD(vector<string> input, DBEngine &engine)
|
||||||
while(input[0] != ")")
|
while(input[0] != ")")
|
||||||
{
|
{
|
||||||
temp.setPAttributeName(input[0]);
|
temp.setPAttributeName(input[0]);
|
||||||
a.push_back(temp);
|
|
||||||
temp.setPAttributeName("~");
|
|
||||||
|
|
||||||
input.erase(input.begin());
|
input.erase(input.begin());
|
||||||
|
|
||||||
|
@ -1053,6 +1055,15 @@ vector<string> updateCMD(vector<string> input, DBEngine &engine)
|
||||||
input.erase(input.begin());
|
input.erase(input.begin());
|
||||||
|
|
||||||
s.push_back(input[0]);
|
s.push_back(input[0]);
|
||||||
|
|
||||||
|
if(input[0].at(0) == '\"')
|
||||||
|
{
|
||||||
|
s.push_back(input[0].substr(1, input[0].find_last_of("\"")));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s.push_back(input[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -1064,15 +1075,20 @@ vector<string> updateCMD(vector<string> input, DBEngine &engine)
|
||||||
{
|
{
|
||||||
input.erase(input.begin());
|
input.erase(input.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a.push_back(temp);
|
||||||
|
temp.setPAttributeName("~");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(input[0] == "WHERE")
|
if(input[0] == "WHERE")
|
||||||
{
|
{
|
||||||
|
vector<string> s;
|
||||||
if(input[0] == "(")
|
if(input[0] == "(")
|
||||||
{
|
{
|
||||||
//PCondition c;
|
//PCondition c;
|
||||||
|
/*
|
||||||
PComparison c;
|
PComparison c;
|
||||||
POperand oops1;
|
POperand oops1;
|
||||||
POperand oops2;
|
POperand oops2;
|
||||||
|
@ -1091,7 +1107,16 @@ vector<string> updateCMD(vector<string> input, DBEngine &engine)
|
||||||
|
|
||||||
c.setPComparison(oops1.getPOperand(), op.getPOp(), oops2.getPOperand());
|
c.setPComparison(oops1.getPOperand(), op.getPOp(), oops2.getPOperand());
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
input.erase(input.begin());
|
||||||
|
while(input[0] != ")")
|
||||||
|
{
|
||||||
|
s.push_back(input[0]);
|
||||||
|
input.erase(input.begin());
|
||||||
}
|
}
|
||||||
|
rcond = condition(s, r, engine);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// send update command to DBEngine
|
// send update command to DBEngine
|
||||||
|
|
BIN
test
BIN
test
Binary file not shown.
Reference in a new issue