Coverage for toardb/contacts/models_person.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-11-03 20:32 +0000

1# SPDX-FileCopyrightText: 2021 Forschungszentrum Jülich GmbH 

2# SPDX-License-Identifier: MIT 

3 

4""" 

5class Person (Base) 

6=================== 

7""" 

8from sqlalchemy import Boolean, Column, Integer, String, Sequence, UniqueConstraint, text 

9from toardb.base import Base 

10 

11PERSONS_ID_SEQ = Sequence('persons_id_seq') # define sequence explicitly 

12class Person(Base): 

13 """ 

14 Table "public.persons" 

15 

16 +-----------+------------------------+-----------+----------+------------------------------------------+ 

17 | Column | Type | Collation | Nullable | Default | 

18 +===========+========================+===========+==========+==========================================+ 

19 | id | integer | | not null | nextval('persons_id_seq'::regclass) | 

20 +-----------+------------------------+-----------+----------+------------------------------------------+ 

21 | name | character varying(64) | | not null | | 

22 +-----------+------------------------+-----------+----------+------------------------------------------+ 

23 | email | character varying(128) | | not null | | 

24 +-----------+------------------------+-----------+----------+------------------------------------------+ 

25 | phone | character varying(32) | | not null | ''::character varying | 

26 +-----------+------------------------+-----------+----------+------------------------------------------+ 

27 | orcid | character varying(19) | | not null | '0000-0002-0309-8010'::character varying | 

28 +-----------+------------------------+-----------+----------+------------------------------------------+ 

29 | isprivate | boolean | | not null | false | 

30 +-----------+------------------------+-----------+----------+------------------------------------------+ 

31 

32 Indexes: 

33 "persons_pkey" PRIMARY KEY, btree (id) 

34 "persons_name_email" UNIQUE CONSTRAINT, btree (name, email) 

35 Referenced by: 

36 TABLE "station_roles" CONSTRAINT "station_roles_person_id_3bd9c160_fk_persons_id" FOREIGN KEY (person_id) REFERENCES persons(id) DEFERRABLE INITIALLY DEFERRED 

37 TABLE "timeseries_roles" CONSTRAINT "timeseries_roles_person_id_3e26200e_fk_persons_id" FOREIGN KEY (person_id) REFERENCES persons(id) DEFERRABLE INITIALLY DEFERRED 

38 """ 

39 __tablename__ = 'persons' 

40 __table_args__ = ( 

41 UniqueConstraint('name', 'email'), 

42 ) 

43 

44 

45 id = Column(Integer, PERSONS_ID_SEQ, primary_key=True, server_default=PERSONS_ID_SEQ.next_value()) 

46 name = Column(String(64), nullable=False) 

47 email = Column(String(128), nullable=False) 

48 phone = Column(String(32), nullable=False, server_default=text("''::character varying")) 

49 orcid = Column(String(19), nullable=False, server_default=text("'0000-0000-0000-0000'::character varying")) 

50 isprivate = Column(Boolean, nullable=False, server_default=text("false")) 

51