hdbc-odbc adds a space to the value

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

hdbc-odbc adds a space to the value

Vagif Verdi
I have a weird problem ?
When preparing sql statements with ? placeholders, hdbc-odbc adds a space to a
string value at the end.

run conn "update sometable set somefield = ? where id = ?" [SqlString "bla",
toSql 10]

Database: Ms Sql Server 2005.
Driver: FreeTds on linux

Please help!

Regards,
Vagif Verdi

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: hdbc-odbc adds a space to the value

Gershom Bazerman
On Mar 23, 2011, at 4:01 AM, [hidden email] wrote:

I have a weird problem ?
When preparing sql statements with ? placeholders, hdbc-odbc adds a space to a
string value at the end.

run conn "update sometable set somefield = ? where id = ?" [SqlString "bla",
toSql 10]

Database: Ms Sql Server 2005.
Driver: FreeTds on linux

I've run into that bug too. I'm pretty sure its an issue with hdbc-odbc, but haven't wanted to patch it without testing it across a few other configurations., which I haven't had time/found straightforward to do. John Goerzen sent a message recently explaining that HDBC needs some more eyes/contributors on it, and particularly the ODBC backend [1].

In any case, for the moment, you can always avoid bound parameters with hdbc-odbc. I've found support for them to be partial at best anyway.

Cheers,
Gershom


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: hdbc-odbc adds a space to the value

Gershom Bazerman
I've run into that bug too. I'm pretty sure its an issue with hdbc-odbc, but haven't wanted to patch it without testing it across a few other configurations, which I haven't had time/found straightforward to do.

I should add, for those interested, where I think the bug is. In the bindCol method of Statement.hsc, there's the following:

    rc2 <- sqlBindParameter sthptr (fromIntegral icol)
       #{const SQL_PARAM_INPUT}
       #{const SQL_C_CHAR} coltype
       (if isOK rc1 then colsize else fromIntegral cslen + 1) decdigits
       csptr (fromIntegral cslen + 1) pcslen

Either one or both of the "fromIntegral csLen + 1" expressions shouldn't have the "+ 1". 

Cheers,
Gershom

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: hdbc-odbc adds a space to the value

John Goerzen-3
On 03/23/2011 06:43 AM, Gershom Bazerman wrote:

>> I've run into that bug too. I'm pretty sure its an issue with
>> hdbc-odbc, but haven't wanted to patch it without testing it across a
>> few other configurations, which I haven't had time/found
>> straightforward to do.
>
> I should add, for those interested, where I think the bug is. In the
> bindCol method of Statement.hsc, there's the following:
>
> rc2 <- sqlBindParameter sthptr (fromIntegral icol)
> #{const SQL_PARAM_INPUT}
> #{const SQL_C_CHAR} coltype
> (if isOK rc1 then colsize else fromIntegral cslen + 1) decdigits
> csptr (fromIntegral cslen + 1) pcslen
>
> Either one or both of the "fromIntegral csLen + 1" expressions shouldn't
> have the "+ 1".

What version of HDBC-ODBC are those of you with the problem running?  I
believe a fix for this was recently checked into my git tree.

-- John

>
> Cheers,
> Gershom
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: hdbc-odbc adds a space to the value

Vagif Verdi

Latest from hackage: 2.2.3.2

On Wednesday, March 23, 2011 01:58:52 PM you wrote:

> On 03/23/2011 06:43 AM, Gershom Bazerman wrote:

> >> I've run into that bug too. I'm pretty sure its an issue with

> >> hdbc-odbc, but haven't wanted to patch it without testing it across a

> >> few other configurations, which I haven't had time/found

> >> straightforward to do.

> >

> > I should add, for those interested, where I think the bug is. In the

> > bindCol method of Statement.hsc, there's the following:

> >

> > rc2 <- sqlBindParameter sthptr (fromIntegral icol)

> > #{const SQL_PARAM_INPUT}

> > #{const SQL_C_CHAR} coltype

> > (if isOK rc1 then colsize else fromIntegral cslen + 1) decdigits

> > csptr (fromIntegral cslen + 1) pcslen

> >

> > Either one or both of the "fromIntegral csLen + 1" expressions shouldn't

> > have the "+ 1".

>

> What version of HDBC-ODBC are those of you with the problem running? I

> believe a fix for this was recently checked into my git tree.

>

> -- John

>

> > Cheers,

> > Gershom

> >

> >

> >

> > _______________________________________________

> > Haskell-Cafe mailing list

> > [hidden email]

> > http://www.haskell.org/mailman/listinfo/haskell-cafe



_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: hdbc-odbc adds a space to the value

John Goerzen-3
OK, if you send me a tested patch I will be happy to apply it.

-- John

On 03/23/2011 04:09 PM, [hidden email] wrote:

> Latest from hackage: 2.2.3.2
>
> On Wednesday, March 23, 2011 01:58:52 PM you wrote:
>
>  > On 03/23/2011 06:43 AM, Gershom Bazerman wrote:
>
>  > >> I've run into that bug too. I'm pretty sure its an issue with
>
>  > >> hdbc-odbc, but haven't wanted to patch it without testing it across a
>
>  > >> few other configurations, which I haven't had time/found
>
>  > >> straightforward to do.
>
>  > >
>
>  > > I should add, for those interested, where I think the bug is. In the
>
>  > > bindCol method of Statement.hsc, there's the following:
>
>  > >
>
>  > > rc2 <- sqlBindParameter sthptr (fromIntegral icol)
>
>  > > #{const SQL_PARAM_INPUT}
>
>  > > #{const SQL_C_CHAR} coltype
>
>  > > (if isOK rc1 then colsize else fromIntegral cslen + 1) decdigits
>
>  > > csptr (fromIntegral cslen + 1) pcslen
>
>  > >
>
>  > > Either one or both of the "fromIntegral csLen + 1" expressions
> shouldn't
>
>  > > have the "+ 1".
>
>  >
>
>  > What version of HDBC-ODBC are those of you with the problem running? I
>
>  > believe a fix for this was recently checked into my git tree.
>
>  >
>
>  > -- John
>
>  >
>
>  > > Cheers,
>
>  > > Gershom
>
>  > >
>
>  > >
>
>  > >
>
>  > > _______________________________________________
>
>  > > Haskell-Cafe mailing list
>
>  > > [hidden email]
>
>  > > http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe