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

DateTime issue with MySQL Database #84

Closed
adrianimboden opened this issue Feb 11, 2013 · 3 comments
Closed

DateTime issue with MySQL Database #84

adrianimboden opened this issue Feb 11, 2013 · 3 comments

Comments

@adrianimboden
Copy link
Contributor

I've found an issue when using multiple DateTime columns in a MySQL table.
The following code statement produces table content as stated below:

Poco::Data::Session sess("MySQL", "host=localhost;user=root;password=;db=mydb");
sess << "DROP TABLE IF EXISTS test;", now;
sess << "CREATE TABLE test (field1 DATETIME, field2 DATETIME)", now;
Poco::DateTime date(2013, 01, 02, 01, 02, 03, 4, 5);
sess << "INSERT INTO test (field1) VALUES(?)", use(date), now;
sess << "INSERT INTO test (field2) VALUES(?)", use(date), now;
sess << "INSERT INTO test (field1, field2) VALUES(?, ?)", use(date), use(date), now;

Table content afterwards:
| field1 | field2 |
| 2013-01-02 01:02:03 | NULL |
| NULL | 2013-01-02 01:02:03 |
| 0000-00-02 01:02:03 | 2013-01-02 01:02:03 |

The first two rows are as expected, but the last row is clearly malformed.

I'm using gcc 4.7.2 on Debian Wheezy and the mysqlclient library in version 5.5.28

@adrianimboden
Copy link
Contributor Author

I decided to participate to this project a little bit too.
I found the bug that caused this problem. The bound parameter is being stored in a std::vector and a pointer to the internal structure of the vector is being used in the mysql library call.

I fixed it and a pull request is pending :)

@simfe
Copy link

simfe commented Jul 8, 2013

how to resolve this bug ?
Thanks!

@simfe
Copy link

simfe commented Jul 9, 2013

oh.I found where is the bug,and resolve it. and then,the latest poco develop version resolved it. we are the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants