You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by Hilco Wijbenga <hi...@elasticpath.com> on 2005/11/09 22:09:47 UTC

Postgresql - Text Data Type

PostgreSQL's 'text' data type does not support a size modifier. Torque,
however, generates 'text(65535)' or something to that effect.

At first I thought this was something recent, a change between
PostgreSQL 7 and 8, but as far as I can tell this has never been
allowed. So I made some changes in the templates project (it's very nice
that this is a separate project!).

My solution was to copy src/templates/sql/base/mssql/columns.vm into
src/templates/sql/base/postgresql. The diff is attached (I was bold
enough to also change some white space so the resulting schema is a bit
nicer).

Bye,
Hilco

Re: Postgresql - Text Data Type

Posted by Hilco Wijbenga <hi...@elasticpath.com>.
On Thu, 2005-11-10 at 23:14 -0800, Thomas Fischer wrote:
> For the following entry in the schema.xml
>    <table name="clob_test">
>      <column name="id" required="true" primaryKey="true" type="SMALLINT" />
>      <column name="clob_value" type="CLOB" required="false"/>
>      <column name="LONGVARCHAR_value" type="LONGVARCHAR" required="false"/>
>    </table>
> 
> I get the following sql in torque:insert-sql
> 
> DROP TABLE clob_test CASCADE;
> 
> CREATE TABLE clob_test
> (
>      id INT2 NOT NULL,
>      clob_value TEXT,
>      LONGVARCHAR_value TEXT,
>      PRIMARY KEY (id)
> );

I found the reason. If you explicitely add a size

<column
  name="LONGVARCHAR_value"
  type="LONGVARCHAR"
  size="65535"/>

then Torque generates 'text(65535)'. At least for PostgreSQL, this
should be 'text' regardless of the size attribute.

I'm not sure if this is something that should be fixed higher up or in
the Velocity template like I did originally.


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


Re: Postgresql - Text Data Type

Posted by Thomas Fischer <tf...@apache.org>.
Hi,

Sorry, I cannot reproduce this.
For the following entry in the schema.xml
   <table name="clob_test">
     <column name="id" required="true" primaryKey="true" type="SMALLINT" />
     <column name="clob_value" type="CLOB" required="false"/>
     <column name="LONGVARCHAR_value" type="LONGVARCHAR" required="false"/>
   </table>

I get the following sql in torque:insert-sql

DROP TABLE clob_test CASCADE;

CREATE TABLE clob_test
(
     id INT2 NOT NULL,
     clob_value TEXT,
     LONGVARCHAR_value TEXT,
     PRIMARY KEY (id)
);

which has no size modifiers and executes fine.

The test was done using the current svn state, but I do not believe 
something was changed with regard to sql generation since 3.2-rc2

Can you provide a simple test case for this ?

     Thomas


On Wed, 9 Nov 2005, Hilco Wijbenga wrote:

> PostgreSQL's 'text' data type does not support a size modifier. Torque,
> however, generates 'text(65535)' or something to that effect.
>
> At first I thought this was something recent, a change between
> PostgreSQL 7 and 8, but as far as I can tell this has never been
> allowed. So I made some changes in the templates project (it's very nice
> that this is a separate project!).
>
> My solution was to copy src/templates/sql/base/mssql/columns.vm into
> src/templates/sql/base/postgresql. The diff is attached (I was bold
> enough to also change some white space so the resulting schema is a bit
> nicer).
>
> Bye,
> Hilco
>

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