Skip to content

Instantly share code, notes, and snippets.

@thekingofspain
Last active February 17, 2023 21:17
Show Gist options
  • Save thekingofspain/2295b2665fb84c9644747fa4d30243d3 to your computer and use it in GitHub Desktop.
Save thekingofspain/2295b2665fb84c9644747fa4d30243d3 to your computer and use it in GitHub Desktop.
OutSystems Entity Internals

OutSystems Entity Internals

Module Enitites

Espace join Entity
 on Espace.Id = Entity.Espace_Id
Entity join Etity_Attr
  on Entity.Id = Etity_Attr.Entity_Id
where Espace.Name = @ModuleNameThatContainsTheEnity

Module.Entity Attributes

Espace join Entity
on Espace.Id = Entity.Espace_Id
Entity join Etity_Attr
 on Entity.Id = Etity_Attr.Entity_Id
where 
Espace.Name = @ModuleNameThatContainsTheEnity and
Enity.Name = @Entity_Name

Foreign Keys

with x as (
  select 
	{Espace}.[Name]  EspaceName, 
    {Espace}.[id] EspaceId, 
    {Espace}.[ss_key]  EspaceSsKey,
    {Entity}.[Name]  EntityName, 
    {Entity}.[id]  EntityId, 
    {Entity}.[ss_key]  EntitySsKey, 
    {Entity}.[PrimaryKey_SS_Key]  EntityPrimaryKeySsKey,
    {Entity_Attr}.[Name]   EntityAttrName, 
    {Entity_Attr}.[id] EntityAttrId, 
    {Entity_Attr}.[ss_key]  EntityAttrSsKey, 
    {entity_Attr}.[Type]  EntityAttrType
from {Espace} 
inner join {Entity} 
	on {Entity}.[Espace_Id] = {Espace}.[Id] 
inner join {Entity_Attr} 
	on {Entity_Attr}.[Entity_Id] = {Entity}.[id]
 )
  select 
  p.EspaceName || '.[' || p.EntityName || '].{' || p.EntityAttrName  || '}' ForeignKey,
  f.EspaceName || '.[' || f.EntityName || '].{' || f.EntityAttrName  || '}' PrimaryKey
  from x p, x f
  where p.EntityAttrType = 'bt' || f.EspaceSsKey || '*' || f.EntitySsKey
  and f.EntityAttrSsKey = f.EntityPrimaryKeySsKey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment