Almost finished implementing Update command fully.

This commit is contained in:
Alexander Huddleston 2015-09-29 23:51:50 -05:00
parent d5c6c52a03
commit 0504ce7fea
5 changed files with 37 additions and 5 deletions

View file

@ -52,6 +52,11 @@ void Attribute::setName(string s){
name = s;
}
void Attribute::setValue(string s, int index)
{
values[index] = s;
}
string Attribute::getType(){
return type;
}

View file

@ -22,6 +22,7 @@ public:
vector<string> getValues();
string getName();
void setName(string s);
void setValue(string s, int index);
string getType();
bool isKey();
int getSize();

View file

@ -2,7 +2,7 @@
using namespace std;
/*
void yourAccount()
{
@ -123,3 +123,4 @@ int main()
else {cout<<"oops";}
}
*/

View file

@ -1019,14 +1019,18 @@ vector<string> insertCMD(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());
if(input[0] == "SET")
{
input.erase(input.begin());
vector <Attribute> a = r.getAttributes();
//parse out ( and send everything until ) into an Expression vector
if(input[0] == "(")
{
@ -1043,8 +1047,6 @@ vector<string> updateCMD(vector<string> input, DBEngine &engine)
while(input[0] != ")")
{
temp.setPAttributeName(input[0]);
a.push_back(temp);
temp.setPAttributeName("~");
input.erase(input.begin());
@ -1053,6 +1055,15 @@ vector<string> updateCMD(vector<string> input, DBEngine &engine)
input.erase(input.begin());
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
@ -1064,15 +1075,20 @@ vector<string> updateCMD(vector<string> input, DBEngine &engine)
{
input.erase(input.begin());
}
a.push_back(temp);
temp.setPAttributeName("~");
}
}
if(input[0] == "WHERE")
{
vector<string> s;
if(input[0] == "(")
{
//PCondition c;
/*
PComparison c;
POperand oops1;
POperand oops2;
@ -1091,7 +1107,16 @@ vector<string> updateCMD(vector<string> input, DBEngine &engine)
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

BIN
test

Binary file not shown.