sql processor bug with xs:boolean type handling

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

sql processor bug with xs:boolean type handling

James Liang
Hi,

There is an inconsistency in the handling of xs:boolean type between
the <sql:query> and <sql:update> for a bit(1) column type in a mysql
database.

Using the sql processor, when I select a bit(1) column from a mysql
database, I have to use xs:boolean.  The output from the sql processor
is 1 or 0.  e.g.

e.g. here I am selecting the flag column in some table and store the
output in the flag attribute

<result>
<sql:attribute name="flag">
<sql:get-column-value type="xs:boolean" column="flag"/>
</sql:attribute>
</result>


On return, I get
<result flag="1" /> or <result flag="0" />

However, when I use <sql:update> to write the same data back to the
database, the use of xs:boolean will not handle 1 or 0 correctly.
e.g.

<sql:update ...>
insert into some_table
set
flag=<sql:param type=xs:boolean select="@flag" />
<sql:update/>

Will always set the flag column to 0.

In order to set 1 or 0 properly, I had to use xs:int for the type.

In summary, to load the bit(1) column in a select query, I had to use
xs:boolean (otherwise, sql processor complaints). To write the bit(1)
column out to database, I had to use xs:int (otherwise, sqlprocessor
always write 0).


Thanks,
James


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: sql processor bug with xs:boolean type handling

Erik Bruchez
Administrator
James,

If you can find the fix in the code that's even better ;)

https://github.com/orbeon/orbeon-forms/tree/master/src/java/org/orbeon/oxf/processor/sql

This processor hasn't been seriously touched in a looong time.

-Erik

On Sat, Jun 18, 2011 at 2:20 PM, James Liang <[hidden email]> wrote:

> Hi,
>
> There is an inconsistency in the handling of xs:boolean type between
> the <sql:query> and <sql:update> for a bit(1) column type in a mysql
> database.
>
> Using the sql processor, when I select a bit(1) column from a mysql
> database, I have to use xs:boolean.  The output from the sql processor
> is 1 or 0.  e.g.
>
> e.g. here I am selecting the flag column in some table and store the
> output in the flag attribute
>
> <result>
> <sql:attribute name="flag">
> <sql:get-column-value type="xs:boolean" column="flag"/>
> </sql:attribute>
> </result>
>
>
> On return, I get
> <result flag="1" /> or <result flag="0" />
>
> However, when I use <sql:update> to write the same data back to the
> database, the use of xs:boolean will not handle 1 or 0 correctly.
> e.g.
>
> <sql:update ...>
> insert into some_table
> set
> flag=<sql:param type=xs:boolean select="@flag" />
> <sql:update/>
>
> Will always set the flag column to 0.
>
> In order to set 1 or 0 properly, I had to use xs:int for the type.
>
> In summary, to load the bit(1) column in a select query, I had to use
> xs:boolean (otherwise, sql processor complaints). To write the bit(1)
> column out to database, I had to use xs:int (otherwise, sqlprocessor
> always write 0).
>
>
> Thanks,
> James
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws