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

Can't bind timestamp with timezone as string, time is not set #248

Open
lavoiekeven opened this issue Sep 4, 2020 · 3 comments
Open

Can't bind timestamp with timezone as string, time is not set #248

lavoiekeven opened this issue Sep 4, 2020 · 3 comments
Labels
good-first-issue Opportunity for new contributors to help us version/2.12 Reports to v2.12.x

Comments

@lavoiekeven
Copy link

Environment

  • nanodbc version: 2.12.4
  • DBMS name/version: Postgresql
  • ODBC connection string: Driver={PostgreSQL ANSI};Server=192.168.1.184;Port=5433;Uid=;Pwd=;Database=;
  • OS and Compiler: Windows 10 Visual studio v141 and Ubuntu 18.04 gcc
  • CMake settings:

Actual behavior

When you are binding a timestamps with timezone as a string, the time part is setted to 00:00:00.

For exemple if you are bindind "2020-09-03T15:27:38-02:00"
it will insert 2020-09-03T00:00:00 at the timezone of the database.

Expected behavior

When you are binding a timestamps with timezone as a string, the time should be the written one.

For exemple if you are bindind "2020-09-03T15:27:38-02:00"
it should insert 2020-09-03T15:27:38-02:00.

Minimal Working Example

`
//This is working
try
{

	std::vector<std::string> parameters_;

	nanodbc::statement statement(connection);
	prepare(statement, NANODBC_TEXT("INSERT INTO rp.test(uid, \"date\") VALUES(?, '2020-09-03T15:27:38-02:00');"));

	statement.bind(0, NANODBC_TEXT("test123456"));

	execute(statement);

}
catch (std::exception& e)
{
	int i = 0;
}

//This is not working
try
{

	std::vector<std::string> parameters_;

	nanodbc::statement statement(connection);
	prepare(statement, NANODBC_TEXT("INSERT INTO rp.test(uid, \"date\") VALUES(?, ?);"));

	statement.bind(0, NANODBC_TEXT("test12345"));
	statement.bind(1, NANODBC_TEXT("2020-09-03T15:27:38-02:00"));

	execute(statement);

}
catch (std::exception& e)
{
	int i = 0;
}

`
Results:
image

@mloskot
Copy link
Member

mloskot commented Sep 8, 2020

An obvious request: could you try the latest release 2.13.0?

@mloskot mloskot added the version/2.12 Reports to v2.12.x label Sep 8, 2020
@lavoiekeven
Copy link
Author

I took the lastest "nanodbc.h" and "nanodbc.cpp" from the repository at the master branch. Last modification on august 4 2020.

I'm not sure of the version it is not written in the header file.

@mloskot
Copy link
Member

mloskot commented Sep 9, 2020

I'm not sure of the version it is not written in the header file.

There is no version macro, but there

2.13.0

Looks like the tests do not cover timestamp binding well, if at all, just

execute(
connection,
NANODBC_TEXT("insert into test_timestamp_without_tz(t) values "
"('2006-12-30 13:45:12.345'::timestamp with time zone);"));

I will try to look into that some time soon, but no timeline promises.

@mloskot mloskot changed the title Can't bind timestamp with timezone as string, time is not setted Can't bind timestamp with timezone as string, time is not set Mar 23, 2022
@mloskot mloskot added the good-first-issue Opportunity for new contributors to help us label Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good-first-issue Opportunity for new contributors to help us version/2.12 Reports to v2.12.x
Projects
None yet
Development

No branches or pull requests

2 participants