mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-04 07:27:23 +01:00
* Unit test for TIMESTAMP data type in MySQL. * Added support for TIMESTAMP data type. Co-authored-by: Hector Toledo Soto <hsoto@transperfect.com>
This commit is contained in:
parent
1fe93ca26a
commit
0f9a8760a0
@ -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:
|
||||
@ -118,6 +119,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:
|
||||
|
@ -422,6 +422,8 @@ void MySQLTest::testDateTime()
|
||||
_pExecutor->date();
|
||||
recreatePersonTimeTable();
|
||||
_pExecutor->time();
|
||||
recreatePersonTimestampTable();
|
||||
_pExecutor->timestamp();
|
||||
}
|
||||
|
||||
|
||||
@ -769,6 +771,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");
|
||||
|
@ -119,6 +119,7 @@ private:
|
||||
void recreatePersonDateTimeTable();
|
||||
void recreatePersonDateTable();
|
||||
void recreatePersonTimeTable();
|
||||
void recreatePersonTimestampTable();
|
||||
void recreatePersonLongBLOBTable();
|
||||
void recreatePersonJSONTable();
|
||||
void recreateStringsTable();
|
||||
|
@ -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()";
|
||||
|
@ -83,6 +83,7 @@ public:
|
||||
void dateTime();
|
||||
void date();
|
||||
void time();
|
||||
void timestamp();
|
||||
void longBlob();
|
||||
void json();
|
||||
void unsignedInts();
|
||||
|
Loading…
x
Reference in New Issue
Block a user