db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <fisc...@seitenbau.net>
Subject Re: Postgresql, integer types, and size (Torque 3.2 only)
Date Tue, 28 Mar 2006 13:05:45 GMT
p.ledbrook@gmail.com schrieb am 28.03.2006 14:27:25:

> On 27/03/06, Thomas Fischer <tfischer@apache.org> wrote:
> > I would claim this to be a problem of the schema.sql. If the column
does
> > not support a size, it should not be forces to take one, so the correct
> > schema.xml would look like
> >
> >   <column name="DELETED" required="false" type="BOOLEANINT"
> >   default="0" javaType="primitive"/>
>
> Yes, but whether the column supports a size or not is
> database-dependent, which I would have thought is something a database
> abstraction layer should deal with.

What I meant is that Torque should deal with the sizes in datatypes where a
size makes sense. As always, "makes sense" is open to discussion :-), but
in my opinion it does not make sense to have a size for boolean values.
However, because "makes sense" is a very soft definition, you have
convinced me that Torque should deal with superfluous sizes. In principle,
Torque can do that, but the information for all data types of all databases
has to be collected.

> ...
> As for the other issue, I discovered a workaround, although I'm not
> sure how safe it is. First create a function in the database:
>
>   CREATE FUNCTION bool2smallint(boolean) RETURNS smallint AS $$
>     SELECT CASE WHEN $1 THEN INT2(1) ELSE INT2(0) END;
>   $$ LANGUAGE SQL;
>
> then add an implicit cast for converting booleans to smallints:
>
>   CREATE CAST (boolean AS smallint) WITH FUNCTION bool2smallint AS
IMPLICIT;

I did not yet have time to look into the other issue, but from first
thought, I hope to resolve the problem at a deeper level.

    Thomas


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message