Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2569: Added TIMESTAMP data type support on MySQL #3471

Merged
merged 3 commits into from
May 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Data/MySQL/src/ResultMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ namespace
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_TIME:
case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_TIMESTAMP:
return sizeof(MYSQL_TIME);

case MYSQL_TYPE_DECIMAL:
Expand Down Expand Up @@ -117,6 +118,7 @@ namespace
return Poco::Data::MetaColumn::FDT_TIME;

case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_TIMESTAMP:
return Poco::Data::MetaColumn::FDT_TIMESTAMP;

case MYSQL_TYPE_STRING:
Expand Down
11 changes: 11 additions & 0 deletions Data/MySQL/testsuite/src/MySQLTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ void MySQLTest::testDateTime()
_pExecutor->date();
recreatePersonTimeTable();
_pExecutor->time();
recreatePersonTimestampTable();
_pExecutor->timestamp();
}


Expand Down Expand Up @@ -761,6 +763,15 @@ void MySQLTest::recreatePersonTimeTable()
}


void MySQLTest::recreatePersonTimestampTable()
{
dropTable("Person");
try { *_pSession << "CREATE TABLE Person (LastName VARCHAR(30), FirstName VARCHAR(30), Address VARCHAR(30), Birthday TIMESTAMP(6))", now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail ("recreatePersonTimestampTable()"); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail ("recreatePersonTimestampTable()"); }
}


void MySQLTest::recreatePersonLongBLOBTable()
{
dropTable("Person");
Expand Down
1 change: 1 addition & 0 deletions Data/MySQL/testsuite/src/MySQLTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class MySQLTest: public CppUnit::TestCase
void recreatePersonDateTimeTable();
void recreatePersonDateTable();
void recreatePersonTimeTable();
void recreatePersonTimestampTable();
void recreatePersonLongBLOBTable();
void recreateStringsTable();
void recreateIntsTable();
Expand Down
28 changes: 28 additions & 0 deletions Data/MySQL/testsuite/src/SQLExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,34 @@ void SQLExecutor::time()
}


void SQLExecutor::timestamp()
{
std::string funct = "timestamp()";
std::string lastName("Bart");
std::string firstName("Simpson");
std::string address("Springfield");
DateTime birthday(1980, 4, 1, 5, 45, 12, 354, 879);

int count = 0;
try { *_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(birthday), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assertTrue (count == 1);

DateTime bd;
assertTrue (bd != birthday);
try { *_pSession << "SELECT Birthday FROM Person", into(bd), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assertTrue (bd == birthday);

std::cout << std::endl << RecordSet(*_pSession, "SELECT * FROM Person");
}


void SQLExecutor::blob(unsigned int bigSize)
{
std::string funct = "blob()";
Expand Down
1 change: 1 addition & 0 deletions Data/MySQL/testsuite/src/SQLExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class SQLExecutor: public CppUnit::TestCase
void dateTime();
void date();
void time();
void timestamp();
void longBlob();
void unsignedInts();
void floats();
Expand Down