Note that there are some explanatory texts on larger screens.

plurals
  1. POColdFusion ORM creates wrong data type
    text
    copied!<p>Database: MySql 5.1.47 on OS X</p> <p>ORM Settings in Application.cfc:</p> <p>this.ormEnabled = true; this.ormsettings = { autogenmap = true, dbCreate = application.dbCreate, automanageSession = true, datasource = application.dsn, logSQL = application.logSQL, sqlScript = application.sqlScript };</p> <p>News.cfc</p> <pre><code>/** * These are the news items * @persistent true * @accessors true * @output false * @entityname "News" * @table news */ component { property name="NewsId" type="string" fieldtype="id" ormtype="integer" generator="native" generated="insert"; property name="Teaser" type="string" sqltype="varchar(200)"; property name="Story" type="string" sqltype="varchar(500)"; property name="ProductLineId" type="numeric" sqltype="int" ormtype="int" fieldtype="many-to-one" cfc="ProductLine" fkcolumn="ProductLineId" foreignkeyname="fk_productline_news"; } </code></pre> <p>ProductLine.cfc</p> <pre><code>/** * @persistent true * @accessors true * @output false * @table productline */ component { property name="ProductLineId" sqltype="int" fieldtype="id" ; property name="Label" type="string" sqltype="varchar(50)"; } </code></pre> <p>Debug output from ORMReload()</p> <pre><code>[localhost]:10/05 21:32:00 [jrpp-70] HIBERNATE DEBUG - [localhost]: create table news ( [localhost]: NewsId integer not null auto_increment, [localhost]: Teaser varchar(200), [localhost]: Story varchar(500), [localhost]: **ProductLineId varchar(255)**, [localhost]: primary key (NewsId) [localhost]: ) [localhost]:10/05 21:32:00 [jrpp-70] HIBERNATE DEBUG - [localhost]: create table productline ( [localhost]: ProductLineId int not null, [localhost]: Label varchar(50), [localhost]: primary key (ProductLineId) [localhost]: ) [localhost]:10/05 21:32:01 [jrpp-70] HIBERNATE DEBUG - [localhost]: alter table news [localhost]: add index fk_productline_news (ProductLineId), [localhost]: add constraint fk_productline_news [localhost]: foreign key (ProductLineId) [localhost]: references productline (ProductLineId) </code></pre> <p>The db creation fails when it attempts to create the foreign key relationship. Notice that the field in news is a varchar(255). Where did that come from? I tried to set it up as an integer in every place I could find but it always gets generated as a varchar. I think that is why the relationship fails since the two fields are different data types.</p> <p>What am I doing wrong?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload