talk@lists.collectionspace.org

WE HAVE SUNSET THIS LISTSERV - Join us at collectionspace@lyrasislists.org

View all threads

How to assign a default value to a field in the database?

SB
Sébastien Brossard
Mon, Feb 25, 2013 12:57 PM

Hi all,

The title says almost all.

Declaring a field in the Service layer as follow,
<xs:element name="scalarValuesComputed" type="xs:boolean"/>
… this field will be then turned to a column in the database.

Is it possible to assign a default value for this column through the Service layer declaration?
Something like:
<xs:element name="scalarValuesComputed" type="xs:boolean" default=”true”/>

Thank you by advance for your help and have a nice day.

Best regards,
Sébastien

Hi all, The title says almost all. Declaring a field in the Service layer as follow, <xs:element name="scalarValuesComputed" type="xs:boolean"/> … this field will be then turned to a column in the database. Is it possible to assign a default value for this column through the Service layer declaration? Something like: <xs:element name="scalarValuesComputed" type="xs:boolean" default=”true”/> Thank you by advance for your help and have a nice day. Best regards, Sébastien
JM
Jesse Martinez
Mon, Feb 25, 2013 5:33 PM

Hi Sébastien,

AFAIK, declaring a default value for a field is only done in the
application layer as this is the layer where field types are declared and
term lists are enumerated. It seems plausible that a boolean type field
could be given a default value in the services layer since a
(non-repeating) boolean is guaranteed to have only one of two values,
whereas any other field with attribute type="xs:string" could be a variety
of field types (and values) depending on tenant configuration and scope.
Nonetheless, adding a default value to a field, say boolean, in the
application layer configuration would look like this example Ray Lee shared
a few months back*:

<field id="approvedForWeb" section="pahma" datatype="boolean"> <default>true</default> </field>

Hope this helps,

  • Jesse

On Mon, Feb 25, 2013 at 7:57 AM, Sébastien Brossard <
Sebastien.Brossard@smk.dk> wrote:

Hi all,****


The title says almost all.****


Declaring a field in the Service layer as follow, ****

<xs:element name="scalarValuesComputed" type="xs:boolean"/>

… this field will be then turned to a column in the database.****


Is it possible to assign a default value for this column through the
Service layer declaration? ****

Something like:****

<xs:element name="scalarValuesComputed" type="xs:boolean" default=”true”
/>



Thank you by advance for your help and have a nice day.****


Best regards,****

Sébastien****


Talk mailing list
Talk@lists.collectionspace.org

http://lists.collectionspace.org/mailman/listinfo/talk_lists.collectionspace.org

Hi Sébastien, AFAIK, declaring a default value for a field is only done in the application layer as this is the layer where field types are declared and term lists are enumerated. It seems plausible that a boolean type field could be given a default value in the services layer since a (non-repeating) boolean is guaranteed to have only one of two values, whereas any other field with attribute type="xs:string" could be a variety of field types (and values) depending on tenant configuration and scope. Nonetheless, adding a default value to a field, say boolean, in the application layer configuration would look like this example Ray Lee shared a few months back*: <field id="approvedForWeb" section="pahma" datatype="boolean"> <default>true</default> </field> Hope this helps, - Jesse * http://lists.collectionspace.org/pipermail/talk_lists.collectionspace.org/2012-June/000850.html and also documented on the wiki, http://wiki.collectionspace.org/display/DOC/cspace-config+Fields#cspace-configFields-default%28element%29 On Mon, Feb 25, 2013 at 7:57 AM, Sébastien Brossard < Sebastien.Brossard@smk.dk> wrote: > Hi all,**** > > ** ** > > The title says almost all.**** > > ** ** > > Declaring a field in the Service layer as follow, **** > > *<xs:element name="scalarValuesComputed" type="xs:boolean"/>* > > … this field will be then turned to a column in the database.**** > > ** ** > > Is it possible to assign a default value for this column through the > Service layer declaration? **** > > Something like:**** > > *<xs:element name="scalarValuesComputed" type="xs:boolean" default=”true” > />* > > ** ** > > ** ** > > Thank you by advance for your help and have a nice day.**** > > ** ** > > Best regards,**** > > Sébastien**** > > _______________________________________________ > Talk mailing list > Talk@lists.collectionspace.org > > http://lists.collectionspace.org/mailman/listinfo/talk_lists.collectionspace.org > >