-
Notifications
You must be signed in to change notification settings - Fork 189
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
Unexpected behavior when bult-in sql functioned invoked #317
Comments
Indeed! It seems other functions work. I wonder why this one does not. v = @client.execute("SELECT LOGINPROPERTY('sa', 'IsLocked') as v").first['v']
=> "\u0000\u0000\u0000\u0000" If I add a debug statement to the result file: --- a/ext/tiny_tds/result.c
+++ b/ext/tiny_tds/result.c
@@ -205,6 +205,7 @@ static VALUE rb_tinytds_result_fetch_row(VALUE self, ID timezone, int symbolize_
DBINT data_len = dbdatlen(rwrap->client, col);
int null_val = ((data == NULL) && (data_len == 0));
if (!null_val) {
+ rb_warn("coltype %i", coltype);
switch(coltype) {
case SYBINT1:
val = INT2FIX(*(DBTINYINT *)data); I get the following information:
And I do not see that in the https://github.com/FreeTDS/freetds/blob/master/include/sybdb.h#L153 file |
I filed this issue with FreeTDS FreeTDS/freetds#86 |
Made this PR for us: #321 |
Odd that Ubuntu fails this new test but not locally on OS X or Appveyor.
|
Ah! I think it is a 4-byte integer. Testing that now... |
The data returned by dbdata is dependent on the type of SYBVARIANT (98). Basically every cell of the table can have a different type. I think currently there's no way to get the type of the SYBVARIANT cells in our dblib. |
Thanks @freddy77 for dropping in. Have you seen other places where I am going to move our |
This is now in master and will be upcoming v1.0.6 release. |
…ixed rails-sqlserver#321. Since we can not rely on determining the type from SYBVARIANT we rely on checking for a simple 4-byte (assumed integer) since this is the first time we have encountered it. Else, return binary/string representation.
Output from LOGINPROPERTY builtin function is not correctly encoded
returns:
It looks that something wrong with output encoding.
I found temporary solution but the reason of this behavior will be useful.
I have converted value to int internally on sql server:
SELECT CONVERT(int,(SELECT LOGINPROPERTY('sa', 'IsLocked') as param))
in this case returned value from tiny_tds is correctly displayed
The text was updated successfully, but these errors were encountered: