group TagDao: EntitySqlDao;

tableName() ::= "tags"

tableFields(prefix) ::= <<
  <prefix>tag_definition_id
, <prefix>object_id
, <prefix>object_type
, <prefix>is_active
, <prefix>created_by
, <prefix>created_date
, <prefix>updated_by
, <prefix>updated_date
>>

tableValues() ::= <<
  :tagDefinitionId
, :objectId
, :objectType
, :isActive
, :createdBy
, :createdDate
, :updatedBy
, :updatedDate
>>

historyTableName() ::= "tag_history"

markTagAsDeleted() ::= <<
update <tableName()> t
set t.is_active = 0
where <idField("t.")> = :id
<AND_CHECK_TENANT("t.")>
;
>>

getTagsForObject() ::= <<
select
  <allTableFields("t.")>
from <tableName()> t
where t.is_active
and t.object_id = :objectId
and t.object_type = :objectType
<AND_CHECK_TENANT("t.")>
;
>>
