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

get_sql() returns empty string #91

Closed
mtissington opened this issue Feb 17, 2017 · 10 comments
Closed

get_sql() returns empty string #91

mtissington opened this issue Feb 17, 2017 · 10 comments
Assignees

Comments

@mtissington
Copy link

I'm creating and using a prepared statement auto ps = db << 'select field from mytable'; etc,
For testing I changed the field name to an incorrect value. An exception was correctly thrown. However get_sql() returned an empty string.

Am I missing something?

@zauguin zauguin self-assigned this Feb 17, 2017
@zauguin
Copy link
Collaborator

zauguin commented Feb 17, 2017

Is the exception thrown when you create or when you use the statement? Is the statement UTF-16 encoded?

@zauguin
Copy link
Collaborator

zauguin commented Feb 17, 2017

Maybe you can create a gist which shows the failing code?

@mtissington
Copy link
Author

It occurs when I use the statement and it's utf-16

@mtissington
Copy link
Author

mtissington commented Feb 17, 2017

does this help
code

zauguin added a commit to zauguin/sqlite_modern_cpp that referenced this issue Feb 17, 2017
SQLite converts UTF-16 statements anyway, so this should lead to less
code duplication and access to the converted string in case an exception
is thrown.

Fixes SqliteModernCpp#91
@zauguin
Copy link
Collaborator

zauguin commented Feb 17, 2017

Tip: Please share the "Share" URL and not the embed script of your gists in the future. This makes it easier to open it. Additionally you got the syntax for links backwards.

@aminroosta
Copy link
Collaborator

aminroosta commented Feb 17, 2017

@mtissington I updated your comment, but the link still doesn't work :-(

@aminroosta
Copy link
Collaborator

@zauguin are you sure #92 fixes this?!

@zauguin
Copy link
Collaborator

zauguin commented Feb 17, 2017

@aminroosta Yes, the problem is, that when prepare fails (this happens in this case, because a query plan can't be produced for an invalid column) the query is only appended in the UTF-8 case(the source)
In the UTF-16 case we would have to convert the statement to UTF-8, which I tried to avoid.
#92 does this conversion always, because this shouldn't change anything in the regular case but avoids a double conversion in the exceptional case.

@zauguin
Copy link
Collaborator

zauguin commented Feb 17, 2017

@mtissington I updated your comment too, now your link works.

@mtissington
Copy link
Author

Thanks - A little new to posting gists.

zauguin added a commit that referenced this issue Feb 18, 2017
SQLite converts UTF-16 statements anyway, so this should lead to less
code duplication and access to the converted string in case an exception
is thrown.

Fixes #91
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

3 participants