0 votes

This may be a bug, but being a new user of Skipper, I'm hoping it's user error, so I am posting this to "How To".

I am using Skipper 3.2.14.1430, Doctrine DBAL v2.8.0, and MySQL v14.14.

Using YML ORM files, I have gotten my database to be completely in sync with Skipper. However, because of the issue with Gedmo Timestampable, I have to manually remove the dashes in order for this to work. After reading this forum, I decided to try XML ORM files as I learned that YML will soon be deprecated in Doctrine.

When I simply changed the Skipper setting to output as XML, Doctrine now reports numerous SQL updates. I found this to be disturbing, but let me continue.

An issue I found is with the default value of a nullable string field. In Skipper, under the General Properties of the field, if "not-null" is set to false (in other words, nullable is true), and default is set to NULL, the resulting XML in the ORM file will be:

<field name="label" type="string" length="50" nullable="true">
  <options>
    <option name="default">NULL</option>
  </options>
</field>

When I run the doctrine command:

bin/console doctrine:schema:update --dump-sql

The resulting SQL will shows:

ALTER TABLE network CHANGE label label VARCHAR(50) DEFAULT 'NULL';

Notice, NULL is wrapped in quotes.

If I try leaving the default option blank in Skipper the resulting XML is:

<field name="label" type="string" length="50" nullable="true">
  <options>
    <option name="default"/>
  </options>
</field>

So now when I run the doctrine command, the resulting SQL is:

ALTER TABLE network CHANGE label label VARCHAR(50) DEFAULT '';

Notice it will not set the field with a default empty string.

The only way I have found to get the result I am wanting, is to manually remove the options block from the ORM file.

<field name="label" type="string" length="50" nullable="true">
</field>

Now the resulting SQL is:

ALTER TABLE network CHANGE label label VARCHAR(50) DEFAULT NULL;

Notice, NULL is no longer wrapped in quotes, but is a literal NULL value. This is what I want.

Is there any way to have Skipper create the correct XML ORM file for me?

in How To & Manuals by (160 points)
edited by

1 Answer

+1 vote
Best answer

Hi Rob,

Is there any reason why you need to enter "NULL" to options? As you mentioned, if you leave "default" without value and do not check NN (not-null), Skipper and Doctrine correctly generates result SQL query.

Option- default serves only for special cases where you need to enter string default value to SQL command.

It's redundant to enter "NULL" to defaults, because NULL is already default value.

by Skipper developer (141k points)
selected by

no problem. we will fix the default: NULL import so this will not occur again.

We can update importer tomorrow so you can import it again.

The other solution is to manually remove (through mass search and replace) all of these strings:

default=""
enum-values=""

This will fix the issue too.

Great! Thanks Ludek

Fix is available in 3.2.15.1464 beta
https://support.skipper18.com/402/downloads-skipper-beta

This fix completely resolved my issue. This is what I did:

  1. I downloaded the 3.2.15.1464 beta
  2. I deleted the Skipper file
  3. I started a new project by importing my YML ORM files
  4. I changed the format from YML to XML
  5. I deleted all of the YML files
  6. I exported the XML ORM files
  7. I ran doctrine:schema:update --dump-sql
  8. I then used the outputted SQL to correct any configuration issues I should have had in my ORM files to begin with.

Thanks for your timely help!

Perfect. I'm glad it's working now.

And thanks for your step-by-step description. It's exactly the correct way.