group BundleSqlDao: EntitySqlDao;

tableFields(prefix) ::= <<
  <prefix>external_key
, <prefix>account_id
, <prefix>last_sys_update_date
>>

tableValues() ::= <<
  :externalKey
, :accountId
, :lastSysUpdateDate
>>

updateBundleLastSysTime()  ::= <<
    update bundles
    set
        last_sys_update_date = :lastSysUpdateDate
    where id = :id
    <AND_CHECK_TENANT()>
    ;
>>

getBundleFromId() ::= <<
    select <fields()>
    from bundles
    where
      id = :id
    <AND_CHECK_TENANT()>
    ;
>>

getBundlesForKey() ::= <<
    select <fields()>
    from bundles
    where
      external_key = :externalKey
    <AND_CHECK_TENANT()>
    ;
>>

getBundleFromAccountAndKey() ::= <<
    select <fields()>
    from bundles
    where
      external_key = :externalKey AND account_id = :accountId
    <AND_CHECK_TENANT()>
    ;
>>

getBundleFromAccount() ::= <<
    select <fields()>
    from bundles
    where
      account_id = :accountId
    <AND_CHECK_TENANT()>
    ;
>>
