group TagDefinitionDao: EntitySqlDao;

tableName() ::= "tag_definitions"

tableFields(prefix) ::= <<
  <prefix>name
, <prefix>description
, <prefix>created_by
, <prefix>created_date
, <prefix>updated_by
, <prefix>updated_date
>>

tableValues() ::= <<
  :name
, :description
, :createdBy
, :createdDate
, :updatedBy
, :updatedDate
>>

accountRecordIdFieldWithComma() ::= ""

accountRecordIdValueWithComma() ::= ""


historyTableName() ::= "tag_definition_history"

deleteTagDefinition() ::= <<
  DELETE FROM tag_definitions
  WHERE id = :id
  <AND_CHECK_TENANT()>
  ;
>>

tagDefinitionUsageCount() ::= <<
  SELECT COUNT(id)
  FROM tags
  WHERE tag_definition_id = :id
  <AND_CHECK_TENANT()>
>>

getByName() ::= <<
  SELECT <allTableFields()>
   FROM tag_definitions
  WHERE name = :name
  <AND_CHECK_TENANT()>
  ;
>>

getByIds(tag_definition_ids) ::= <<
  SELECT <allTableFields()>
  FROM tag_definitions
  WHERE id IN (<tag_definition_ids: {id | :id_<i0>}; separator="," >)
  <AND_CHECK_TENANT()>
>>
