telosystools

Open full view…

DSL Model support default values

tranhung
Tue, 24 Dec 2019 09:32:54 GMT

Hi all, I'm generating the Code using DSL Model but can't set default value for fields. Is there a way to do that?

Telosys Team
Tue, 24 Dec 2019 15:36:11 GMT

What kind of language do you generate ? Do you mean initial value for attributes in a domain class ?

tranhung
Wed, 25 Dec 2019 03:19:12 GMT

I'm generating SQLAlchemy ORM code for use with python, This is the kind of result code that I generating: class HSCode(Base): id = Column(Integer, nullable=False, primary_key=True, index=True) national_tariff = Column(String(2), nullable=True, index=True, default="00") picture_id = Column(Integer, ForeignKey("picture.id"), nullable=True) is_activated = Column(Boolean, nullable=False, default=True) picture = relationship("Picture", foreign_keys=[picture_id]) And this is the DSL model for that: HSCode{ id : int { @Id, @AutoIncremented} ; national_tariff : string { @SizeMax(2)}; is_activated : boolean {@NotNull}; display_order : int { @NotNull }; picture : Picture; } In the DSL model, I can't find a way to store and generating these parts: 1. index=True 2. default="00"; default=True

Telosys Team
Tue, 31 Dec 2019 08:49:55 GMT

Yes, you're right the "default value" annotation is not yet implemented in DSL model. It will come soon with others annotations and the new "tag" feature.