Book a Demo

Author Topic: Generating tables from a UML model attribute varchar default length  (Read 9040 times)

UrsulaGreen

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
I am trying to generate a DDL schema from a platform independent model using the transform functionality.  I have a UML based model from which I am generating a database table model an then generating the DDL from the table (fro a MySQL database).

The attributes in the tables are defaulting to varchar (which is ok) but the default length is set to zero.  Ideally I would like this set to 255 but I am not sure how to do this in the transform templates or if it is possible.

I am using sparx EA 15.5

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Generating tables from a UML model attribute varchar default length
« Reply #1 on: August 09, 2018, 01:45:10 pm »
EA 15.5?  Should that be 13.5?
Best Regards, Roy

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Generating tables from a UML model attribute varchar default length
« Reply #2 on: August 10, 2018, 12:00:34 am »
No, he's been teleported here from the future xD

q.

UrsulaGreen

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Generating tables from a UML model attribute varchar default length
« Reply #3 on: August 13, 2018, 08:24:24 pm »
whoops typo; I'm using version 13.5  :)
Time travel is beyond my skillset

SamSepi0l

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: Generating tables from a UML model attribute varchar default length
« Reply #4 on: August 13, 2018, 11:46:45 pm »
Try this:

  • Modify the "DDL" Template (Design -> Tools -> Transform -> Transform Templates)
  • Replace: type=%qt%%CONVERT_DB_TYPE(genOptDefaultDatabase, attType)%%qt%
    with:
        type = %qt%varchar%qt%
        length = %255%qt%

And see if works.

UrsulaGreen

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Generating tables from a UML model attribute varchar default length
« Reply #5 on: August 16, 2018, 12:09:14 am »
thank you I will give it a go

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Generating tables from a UML model attribute varchar default length
« Reply #6 on: August 16, 2018, 04:58:21 pm »
Try this:

  • Modify the "DDL" Template (Design -> Tools -> Transform -> Transform Templates)
  • Replace: type=%qt%%CONVERT_DB_TYPE(genOptDefaultDatabase, attType)%%qt%
    with:
        type = %qt%varchar%qt%
        length = %255%qt%

And see if works.
Wouldn't that make ALL columns of type varchar(255)?

Geert

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1353
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: Generating tables from a UML model attribute varchar default length
« Reply #7 on: August 18, 2018, 08:44:39 am »
Time travel is beyond my skillset

Don't under estimate yourself. You are travelling forward into the future one second at a time.

Try this:

  • Modify the "DDL" Template (Design -> Tools -> Transform -> Transform Templates)
  • Replace: type=%qt%%CONVERT_DB_TYPE(genOptDefaultDatabase, attType)%%qt%
    with:
        type = %qt%varchar%qt%
        length = %255%qt%

And see if works.
Wouldn't that make ALL columns of type varchar(255)?

Geert
Your right Geert. There needs to be some kind of %if ...% statement. However looking at the MySQL DDL transform it looks like
modification of a few lines DDL Data Type (lines 24 to 26) might be the answer as that looks like it sets the length to 0 there.
Code: [Select]
%elseIf $Type=="varchar" or $Type=="nvarchar" or $Type=="varbinary" %
(0)
%endIf%
However isn't the point of varchar is that it has a variable length otherwise just use char and fix the length.
« Last Edit: August 19, 2018, 05:34:11 am by Sunshine »
Happy to help
:)

Glassboy

  • EA Practitioner
  • ***
  • Posts: 1367
  • Karma: +112/-75
    • View Profile
Re: Generating tables from a UML model attribute varchar default length
« Reply #8 on: August 20, 2018, 07:31:02 am »
Don't under estimate yourself. You are travelling forward into the future one second at a time.

In a block universe that is reference frame dependent.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Generating tables from a UML model attribute varchar default length
« Reply #9 on: August 20, 2018, 09:39:05 am »
Don't under estimate yourself. You are travelling forward into the future one second at a time.

In a block universe that is reference frame dependent.
From, at least, the southern hemisphere.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!