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

Improve auto_bind_columns to recognise fine-grained types #369

Open
mloskot opened this issue Jan 23, 2023 · 0 comments · May be fixed by #370
Open

Improve auto_bind_columns to recognise fine-grained types #369

mloskot opened this issue Jan 23, 2023 · 0 comments · May be fixed by #370
Assignees

Comments

@mloskot
Copy link
Member

mloskot commented Jan 23, 2023

Currently, auto_bind_columns collapses numeric types into SQL_C_SBIGINT as a common type:

nanodbc/nanodbc/nanodbc.cpp

Lines 3804 to 3813 in 2dc94b9

switch (col.sqltype_)
{
case SQL_BIT:
case SQL_TINYINT:
case SQL_SMALLINT:
case SQL_INTEGER:
case SQL_BIGINT:
col.ctype_ = SQL_C_SBIGINT;
col.clen_ = sizeof(int64_t);
break;

This should be fine grained to something like

            switch (col.sqltype_)
            {
            case SQL_BIT:
                col.ctype_ = SQL_C_BIT;
                col.clen_ = sizeof(uint8_t);
                break;
            case SQL_TINYINT:
                col.ctype_ = SQL_C_STINYINT;
                col.clen_ = sizeof(int8_t);
                break;
            case SQL_SMALLINT:
                col.ctype_ = SQL_C_SSHORT;
                col.clen_ = sizeof(int16_t);
                break;
            case SQL_INTEGER:
                col.ctype_ = SQL_C_SLONG;
                col.clen_ = sizeof(int32_t);
                break;
            case SQL_BIGINT:
                col.ctype_ = SQL_C_SBIGINT;
                col.clen_ = sizeof(int64_t);
                break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant