model.anubis 982 Bytes
/*
 * Created by PyramIDE.
 * User: フランスのトトロ aka (David RENÉ) 
 * Date: 13/02/2016
 * Time: 11:01
 * © Calexium 
 */

read system/string.anubis

read hayamiki_lib/types/hayamiki.anubis

public define String
  format_attributes
  (
    List(HK_Model_Attr)  attributes
  )=
  join(" ",map((HK_Model_Attr attr) |->
    if attr is
    {
      unique        then "UNIQUE",    
      default(str)  then "DEFAULT "+str,             // default value (used in case of creation of a NON NULL column
                                // in a table which already contains some rows)
      not_null      then "NOT NULL"
    }, attributes)).
  
public define String
  format_fk_clause
  (
    List(HK_Foreign_Key_Clause) fk_clauses
  )=
  join(" ",map((HK_Foreign_Key_Clause fk_clause) |->
    if fk_clause is 
    {
      on_delete(directive)  then "ON DELETE "+to_String(directive),
      on_update(directive)  then "ON UPDATE "+to_String(directive)
    }, fk_clauses
  ))
.