What is the default nullable constraint setting for a liquibase column? - nullable

I'm creating a new table, like this:
<createTable tableName="myTable">
<column name="key" type="int" autoIncrement="true">
<constraints primaryKey="true" primaryKeyName="PK_myTable" nullable="false"/>
</column>
<column name="name" type="nvarchar(40)">
<constraints nullable="false"/>
</column>
<column name="description" type="nvarchar(100)">
<constraints nullable="true"/>
</column>
</createTable>
As far as the nullable constraint, if I omit that attribute what is the default setting?
E.g.,
If I only did this:
<column name="description" type="nvarchar(100)"/>
...would the column be nullable?
More importantly, where is the documentation that specifies this (as I have other questions like this)?
I looked here: Liquibase Column Tag, but it only says ambiguously:
nullable - Is column nullable?

It isn't documented, but I looked at the source code and it appears that if you do not specify, there is no constraint added to the column. One way you can check this yourself is to use the liquibase updateSql command to look at the SQL generated.

Actually it's documented here.
Defines whether the column is nullable. Default: database-dependent
So the default null constraint is database-dependent.
If you use Postgres, for example, it will be nullable by default.
https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-not-null-constraint/
Use the NOT NULL constraint for a column to enforce a column not accept NULL. By default, a column can hold NULL.

Related

TFS Default Area Path set as blank and mandatory

TFS defaults Area Path for new items to Parent Area, and people forget to populate it properly, with the consequence of having items wrongly assigned to parent area (we have the children areas well specified).
I've tried to set it as blank by default, so it is mandatory to populate the value before saving the item in New state, but TFS does not allow that as AreaPath is kind of "special" field.
How could I workaround this? I'm of course open to any other alternative that can work here.
Like you said, the AreaPath field is kind of "spacial" field, so we can't restrict values on this field. but there is a workaround:
1) Create a new field, for example: AreaPathValidation.
2) Find out the AreaIDs of the restricted area paths.
3) Make a rules to the new field like the following:
<FIELD name="Area Path Validation" refname="Company.AreaPathValidation" type="String">
<PROHIBITEDVALUES>
<LISTITEM value="Root Area Path" />
</PROHIBITEDVALUES>
<COPY from="value" value="No Errors" />
<WHEN field="System.AreaId" value="54">
<COPY from="value" value="Root Area Path" />
</WHEN>
</FIELD>
The 54 it's only an example to Area Path Id, change it to your root Area Path Id.
Now when the user not will change the Area Path he couldn't save the work item :)

How to order rules in work item field

Is there a way to apply rules in a specific order?
I want to offer YesNo ONLY if two specific values are selected from another field... my rules in XML look like this:
<WHEN field="xxx.yyy.FoundInVersion" value="xxx">
<ALLOWEXISTINGVALUE />
<ALLOWEDVALUES not="[project]\xxx" expanditems="true">
<LISTITEM value="No" />
<LISTITEM value="Yes" />
</ALLOWEDVALUES>
</WHEN>
<WHEN field="xxx.yyy.FoundInVersion" value="yyy">
<ALLOWEXISTINGVALUE />
<ALLOWEDVALUES not="[project]\xxx" expanditems="true">
<LISTITEM value="No" />
<LISTITEM value="Yes" />
</ALLOWEDVALUES>
</WHEN>
<ALLOWEDVALUES not="[project]\MigrationAccounts" expanditems="true">
<LISTITEM value="No" />
</ALLOWEDVALUES>
This works. If either of the both WHENs are correct Yes and No are allowed.
But TFS somehow automatically (on the different/target instance) moves the last ALLOWEDVALUES rule to the top, and only No is allowed and selectable, even if I select one of the values "yyy" or "xxx" in the other field.
It seems to cache somewhere, or try to be intelligent or sth.
How can I force/workaround the rules to my own order?
Rules are typically processed in the sequence in which they are listed. However, when you use the WHEN*, DEFAULT, and COPY elements, additional behaviors may apply.
You can gain some idea of how rules are evaluated when you apply multiple rules to a field. How rules are evaluated is not completely deterministic. This section describes the expected behavior and interactions when you are using the WHEN*, DEFAULT, and COPY rules.
The following steps show, in the correct sequence, the interactions that TFS performs and by the user of a work-item form. Only steps 1, 8, and 13 are performed by the user.
1.From a Team Foundation client─such as Visual Studio, Team Explorer, Team Web Access, or Team Explorer Everywhere─, a user creates a new
work item or edits an existing work item.
2.Fill in field defaults. For all fields, use any DEFAULT rules that are outside WHEN* rules.
3.Copy field values. For all fields, use any COPY rules that are outside WHEN* clauses.
4.For all fields with a WHEN rule that matches, first do DEFAULT and then COPY rules inside.
5.For all fields with a WHENNOT rule that matches, first do DEFAULT and then COPY rules inside.
TFS always processes WHEN rules before WHENNOT rules.
6.For all fields that have had their values changed since step 1 and that contain WHENCHANGED rules, first do DEFAULT and then COPY rules
inside.
7.Allow the user to start editing.
8.The user changes a field value and then moves focus from the field.
9.Raise any WHEN rules for that field that match the new value.
10.Raise any WHENNOT rules for that field that match the new value.
11.Raise any WHENCHANGED rules for that field that match the new value.
12.Return editing ability to the user.
13.The user saves the changes to the database.
14.For all fields, perform SERVERDEFAULT operations that are defined for the field either directly or indirectly under a WHEN or a WHENNOT
rule.

How to use Html5 tags e.g email with struts2

I am using struts2 for presentation layer, now there is requirement to use html5 tags e.g. email, tel etc., but it seems that struts2 doesn't support html5 tags.
Is there any way to achieve the above requirement?
You can add custom (HTML5 and others) attributes to Struts2 Tags that have declared they support Dynamic Attributes. Look in the documentation, for each tag you are using, under the Parameters part if you see Dynamic Attributes Allowed: true;
You can still use native HTML elements, along with Struts tags. Then both the following ways are good:
<s:textfield name="foo" value="bar" customAttr />
<input type="text" name="foo" value="<s:property value="bar"/>" customAttr />
If you need to change the type, you can now do it with the Struts <s:textfield /> tag too:
<s:textfield type="email" name="foo" value="bar" customAttr />
<s:textfield type="date" name="foo" value="bar" customAttr />
<s:textfield type="currency" name="foo" value="bar" customAttr />
etc...
Your struts2 tags(<s: >) will finally be converted to basic HTML tags when the page is rendered, which you can check by looking into the generated source. Usually, Struts2 just adds some css(if you are not using theme="simple") to the basic HTML tags. So. it is incorrect to say that
struts2 doesn't support html5 tags
Use the Html5 tags as usual, they will work.
It looks like you are new to the community, so dont get demotivated by the downvotes but in future try to do some homework and ask specific problems, what did you try and what did not work

How to use two WHEN elements to make field required in TFS

In VSTF 2012 I have a custom template. I have a field which uses the WHEN field element to determine if it is required based on the input from a different field - in this example the Ops Approver field is required when the Ops Required field = Operations.
<FieldDefinition name="Operations Approver" refname="Microsoft.VSTS.Common.OperationsApprover" type="String" reportable="dimension">
<VALIDUSER />
<WHEN field="Microsoft.VSTS.Common.OpsRequired" value="Operations">
<REQUIRED />
</WHEN>
</FieldDefinition>
This works perfectly. I now need to make this field required based on the WHEN from 2 different fields e.g. When Ops Required = Operations and Priority = 2
I have tried adding another WHEN element but they act as an OR function rather than an AND function.
I have searched on the web, on this site in MSDN and found nothing. What am I missing? Is this even possible?
Any help greatly appreciated.

Assigning users in TFS if two fields have specific values

Updated question with additional info as solution was not applicable.
Sorry, I will have to ask this question once again. My objective is to implement some TFS automation for the Assigned To field. This field is to be populated certain values in the module and category field are selected.
Is there a way to create an "And" operator within the TFS WI XML that can handle this? I asked this question a couple of months ago and received an answer. Unfortunately, I haven't had time to implement it due to several items that came down the pipe. When I tried implementing the solution and when importing the WIT, TFS would throw a "WHEN" has an invalid child element "WHEN" error.
Example:
If "Module" field = value X and "Platform" field = value Y, then "Assigned to" field is set to specific user
Given solution does not work:
<FIELD name="QA Owner" refname="<QAOwnerFieldReference>" type="String">
<VALIDUSER />
<WHEN field="<ModuleReferenceName>" value="Compliance">
<WHEN field="<AnotherFieldName>" value="SomeValue">
<DEFAULT from="value" value="<QATester>" />
</WHEN>
</WHEN>
</FIELD>
I do have an idea, is it possible to merge the second "WHEN" condition with the first, such that:
<WHEN field="<ModuleReferenceName>" value="Compliance" && WHEN field="<AnotherFieldName>" value="SomeValue">
Link to previous post: Assigning users in TFS if two fields have specific values
What you need to do is to cascade two conditions, to create an and effect. Not ideal, but what'll you do :)
Here's what your WIT field definition could look like:
<FIELD name="QA Owner" refname="<QAOwnerFieldReference>" type="String">
<VALIDUSER />
<WHEN field="<ModuleReferenceName>" value="Compliance">
<WHEN field="<AnotherFieldName>" value="SomeValue">
<DEFAULT from="value" value="<QATester>" />
</WHEN>
</WHEN>
</FIELD>
The only viable solution I could find for this is to create a custom control that will process a set of rules before saving the work item.
Check out Gregg Boer's blog for a short guide to creating WI custom controls. Note that this will need to be installed on each desktop client's machine.
Note that you will want to write a handler for the BeforeUpdateDatasource event.
Also, if you need this to run on the web, you'll need to create a web-access custom control (see Ewald Hoffman's post on WA controls).

Resources