class GroupUser(orb.Table): id = orb.IdColumn() user = orb.ReferenceColumn(reference='User') group = orb.ReferenceColumn(reference='Group') byUserAndGroup = orb.Index(('user', 'group'), flags={'Unique'}) byUser = orb.Index(('user', ))
class Asset(orb.Table): id = orb.IdColumn() code = orb.StringColumn(flags={'Unique'}) display_name = orb.StringColumn() parent = orb.ReferenceColumn(reference='Asset') project = orb.ReferenceColumn(reference='Project') type = orb.StringColumn(flags={'Polymorphic'}) children = orb.ReverseLookup(from_column='Asset.parent') dependsOn = orb.Pipe(through_path='Dependency.target.source') dependencies = orb.Pipe(through_path='Dependency.source.target')
def test_pg_statement_create_index(orb, GroupUser, pg_sql): index = orb.Index(name='byGroupAndUser', columns=[ orb.ReferenceColumn(name='group'), orb.ReferenceColumn('user') ]) index.setSchema(GroupUser.schema()) st = pg_sql.statement('CREATE INDEX') assert st is not None statement, data = st(index) assert 'CREATE INDEX' in statement statement, data = st(index, checkFirst=True) assert 'DO $$' in statement
class Address(orb.Table): id = orb.IdColumn() user = orb.ReferenceColumn(reference='User') name = orb.StringColumn() street = orb.StringColumn() city = orb.StringColumn() state = orb.StringColumn() zipcode = orb.IntegerColumn()
class Group(orb.Table): __resource__ = True id = orb.IdColumn() name = orb.StringColumn(flags={'Unique'}) owner = orb.ReferenceColumn(reference='User') users = orb.Pipe(through_path='GroupUser.group.user') groupUsers = orb.ReverseLookup(from_column='GroupUser.group') byName = orb.Index(columns=['name'], flags={'Unique'})
class Address(orb.Table): __resource__ = True id = orb.IdColumn() user = orb.ReferenceColumn(reference='User') street = orb.StringColumn(flags={'Required'}) city = orb.StringColumn(flags={'Required'}) state = orb.StringColumn(flags={'Required'}) zipcode = orb.IntegerColumn() def onInit(self, event): context = self.context() self.set('user', context.scope.get('user'))
class TestAllColumns(orb.Table): Test = enum('Ok') # boolean bool = orb.BooleanColumn() # data binary = orb.BinaryColumn() json = orb.JSONColumn() query = orb.QueryColumn() yaml = orb.YAMLColumn() # datetime date = orb.DateColumn() datetime = orb.DatetimeColumn() datetime_tz = orb.DatetimeWithTimezoneColumn() interval = orb.IntervalColumn() time = orb.TimeColumn() timestamp = orb.TimestampColumn() utc_datetime = orb.UTC_DatetimeColumn() utc_timestamp = orb.UTC_TimestampColumn() # numeric id = orb.IdColumn() decimal = orb.DecimalColumn(scale=2) float = orb.FloatColumn() integer = orb.IntegerColumn() long = orb.LongColumn() enum = orb.EnumColumn() # reference reference = orb.ReferenceColumn(reference='TestReference') # string string = orb.StringColumn() text = orb.TextColumn() color = orb.ColorColumn() directory = orb.DirectoryColumn() email = orb.EmailColumn() filepath = orb.FilepathColumn() html = orb.HtmlColumn() password = orb.PasswordColumn(default='T3st1ng!') token = orb.TokenColumn() url = orb.UrlColumn() xml = orb.XmlColumn()
class ProjectSupervisor(orb.Table): id = orb.IdColumn() project = orb.ReferenceColumn(reference='Project') user = orb.ReferenceColumn(reference='User')
class Dependency(orb.Table): id = orb.IdColumn() source = orb.ReferenceColumn(reference='Asset') target = orb.ReferenceColumn(reference='Asset')
class GroupUser(orb.Table): id = orb.IdColumn() user = orb.ReferenceColumn(reference='User') group = orb.ReferenceColumn(reference='Group')
class Preference(orb.Table): id = orb.IdColumn() user = orb.ReferenceColumn(reference='User', flags={'Unique'}) notifications_enabled = orb.BooleanColumn()
class Attachment(orb.Table): id = orb.IdColumn(type='hash') filename = orb.StringColumn() comment = orb.ReferenceColumn(reference='Comment', flags={'Required'})
class Employee(User): role = orb.ReferenceColumn(reference='Role', flags={'AutoExpand'})