Development

#2045 (propel-convert-xml-schema generate null text as default values)

You must first sign up to be able to contribute.

Ticket #2045 (closed enhancement: wontfix)

Opened 3 years ago

Last modified 7 months ago

propel-convert-xml-schema generate null text as default values

Reported by: Fernando.Toledo Assigned to: fabien
Priority: minor Milestone:
Component: sfPropelPlugin Version: 1.2.8
Keywords: Cc:
Qualification: Unreviewed

Description

i convert the schema from xml to yml.

my schema.xml have default values as "" in some fields

<column name="nombre" type="VARCHAR" size="128" required="true" default=""/>

in the converted schema.yml the field have an attribute "default:"

    nombre:
      type: VARCHAR
      size: 128
      required: true
      default:

it's behavior make a "null" word as default value in the text input controls like the screenshot attached.

i think that the parser must be ignore it. and no generate the "default:" attribute if the xml has "" (empty string).

Attachments

shot14.png (135.3 kB) - added by Fernando.Toledo on 07/30/07 18:00:45.
Scheenshoot

Change History

07/30/07 18:00:45 changed by Fernando.Toledo

  • attachment shot14.png added.

Scheenshoot

07/30/07 21:08:41 changed by Andrejs.Verza

I also use a kind of reverse engeneering with the database. This approach allows me to create/edit the database with triggers and stored procedures using my favorite visual tools, which is way more convenient for complex database than defining schema.yml by hand.

The best solution I found was a "patch" for the generated schema.xml file. The patch simply removes default="" and <parameter name="Default" value=""/> from the file.

This works well for me. PS: I believe this is Propel's issue.

(in reply to: ↑ description ) 02/21/08 16:41:17 changed by shouze

  • status changed from new to closed.
  • type changed from defect to enhancement.
  • resolution set to fixed.
  • qualification set to Ready for core team.

It's propel's fault indeed. I tried to signal it to propel team (IRC & trac), but :

_ Trac need a valid acount to open a ticket and account creation is restricted _ On #propel irc chan they said me that the next big thing is propel 1.3 and that propel 1.2 has never existed and they'll never apply any patch on it.

So I have a Little patch to fix the problem @ schema generation time, could you apply it into symfony replository please ? :

Index: propel-generator/classes/propel/phing/PropelCreoleTransformTask.php
===================================================================
--- propel-generator/classes/propel/phing/PropelCreoleTransformTask.php (révision 7563)
+++ propel-generator/classes/propel/phing/PropelCreoleTransformTask.php (copie de travail)
@@ -504,7 +504,9 @@
                }
 
                if (($defValue = $column->getDefaultValue()) !== null) {
-                       $node->setAttribute("default", iconv($this->dbEncoding, 'utf-8', $defValue));
+                       if(!empty($defValue)) {
+                               $node->setAttribute("default", iconv($this->dbEncoding, 'utf-8', $defValue));
+                       }
                }
 
                if ($vendorNode = $this->createVendorInfoNode($column->getVendorSpecificInfo())) {

Replying to Fernando.Toledo:

i convert the schema from xml to yml. my schema.xml have default values as "" in some fields {{{ <column name="nombre" type="VARCHAR" size="128" required="true" default=""/> }}} in the converted schema.yml the field have an attribute "default:" {{{ nombre: type: VARCHAR size: 128 required: true default: }}} it's behavior make a "null" word as default value in the text input controls like the screenshot attached. i think that the parser must be ignore it. and no generate the "default:" attribute if the xml has "" (empty string).

02/21/08 17:06:41 changed by fabien

  • status changed from closed to reopened.
  • resolution deleted.

06/23/08 03:44:11 changed by dwhittle

  • milestone set to 1.0.17.

This bug should be filled with the creole trac at creole.phpdb.org.

06/23/08 03:45:18 changed by dwhittle

  • status changed from reopened to closed.
  • resolution set to wontfix.

06/23/08 08:49:40 changed by fabien

  • status changed from closed to reopened.
  • resolution deleted.

06/29/08 16:50:29 changed by gregoire

  • milestone changed from 1.0.17 to 1.0.18.

09/30/08 18:27:28 changed by gregoire

  • milestone changed from 1.0.18 to 1.0.19.

11/25/08 10:32:04 changed by gregoire

  • milestone changed from 1.0.19 to 1.0.20.

03/05/09 00:50:00 changed by Kris.Wallsmith

  • status changed from reopened to closed.
  • resolution set to wontfix.

Please post this issue to Propel again. They're being much more responsive lately.

07/17/09 05:18:04 changed by Jaime Vargas

  • version changed from 1.0.5 to 1.2.8.
  • component changed from tasks to sfPropelPlugin.
  • qualification changed from Ready for core team to Unreviewed.
  • milestone deleted.

in symfony 1.2.8 i solve the issue related to null text modifying the following file:
lib/vendors/symfony/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5ObjectBuilder.php

replacing the line 142:

$defaultValue = var_export($val, true);

with:

$defaultValue = $val === 'null' ? $val : var_export($val, true);

This is a patch but works for me, if your default value is 'null' as string it will be transformed in a PHP null value in your model.

This patch only modify the generated class model, not the generated yml or xml schema file.

Hope this help.

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.