db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Ledbrook" <pe...@cacoethes.co.uk>
Subject Re: Postgresql, integer types, and size (Torque 3.2 only)
Date Tue, 28 Mar 2006 12:27:25 GMT
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.

>
> However, as we want to keep our users happy, I have just checked in a
> PlatformPosrgresqlImpl class for the generator which tells the generator
> not to give sizes to postgresql int2 columns. If you do not want to
> correct the schema, you may want to get the class (or the whole generator)
> from SVN.

Thanks. I have updated our schema so that integer fields no longer
have a size; we should be ok with that.

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;

Cheers,

Peter

---------------------------------------------------------------------
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