Discussion on Semantics-transact

Documents Home

Semantic-transact Reference

Topic Details
SQL Gramma
Expression String
Read (Query) API
Expression String
Wrie (Update / Insert / Delete) API
Expression String
Generating SQL
How empty values are handled

Note: This is a description of server side handling. If you want to know how to control empty handling from client, see client reference like js client. Do not confused with it.

The client side normally running in different evironment, this leads to different empty value coding conventions.
Semantic.transact tried to take those empty value as consistant as possible to database convensions. It take the empty values following the rules:
Can Find DB Meta Represent String DB Type In gerated SQL
No "" (0 length String) Any (Unknown) " ' ' "
null Any (Unknown) null
Yes "" (0 length String) Text / Varchar " ' ' "
"" (0 length String) Number, ... (other than text) " 0 "
null Text / Varchar or Date / Datetime null
null Number, Date / Datetime, .. (other than text) null

1. If there is no db column type available, then all empty value is taken as a text field.
2. If the field is type of date / dateime or text / varchar, the empty value is treated as an empty string:
2.1 If the string is 0 length of string, the value will bee taken as "''".
2.2 If the string is null, the value will bee taken as null.
3. If the field is not type of date / dateime or text / varchar, the empty value is treated as:
3.1 If the value is repesented by a 0 length of string, the value will bee taken as "0".
3.2 If the value is null, the value will bee taken as null.

For test example, see test of empty values (@Test testEmptyVals()).

Known Issues

  1. Sql#condt(String) parsed predicate missing flowing single quote.

    See test case TestTransc#testExprVals().

    For code line

    .where(Sql.condt("roleName = '%s'", "roleName-old'''")) // roleName = 'roleName-old'''
    We are expecting this:
    roleName = 'roleName-old'''
    // but we want 3 single quotes ("'"), the 2nd from right side should be replaced
    But we got this:
    roleName = 'roleName-old''
    It's because of PredicateVisitor handled the wrong grammar?