Coverage for toardb/variables/models.py: 100%

14 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 

4from sqlalchemy import Column, Integer, String, Sequence 

5from sqlalchemy.orm import relationship 

6from toardb.base import Base 

7 

8 

9VARIABLES_ID_SEQ = Sequence("variables_id_seq") # define sequence explicitly 

10 

11 

12class Variable(Base): 

13 """ 

14 Table "public.variables" 

15 

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

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

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

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

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

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

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

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

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

25 | displayname | character varying(128) | | not null | | 

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

27 | cf_standardname | character varying(128) | | not null | | 

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

29 | units | character varying(64) | | not null | | 

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

31 | chemical_formula | character varying(128) | | not null | | 

32 +------------------+------------------------+-----------+----------+---------------------------------------+ 

33 

34 Indexes: 

35 "variables_pkey" PRIMARY KEY, btree (id) 

36 "variables_name_key" UNIQUE CONSTRAINT, btree (name) 

37 "variables_name_9bc98a13_like" btree (name varchar_pattern_ops) 

38 Referenced by: 

39 TABLE "timeseries" CONSTRAINT "timeseries_variable_id_dd9603f5_fk_variables_id" FOREIGN KEY (variable_id) REFERENCES variables(id) DEFERRABLE INITIALLY DEFERRED 

40 """ 

41 

42 __tablename__ = "variables" 

43 

44 id = Column( 

45 Integer, 

46 VARIABLES_ID_SEQ, 

47 primary_key=True, 

48 server_default=VARIABLES_ID_SEQ.next_value(), 

49 ) 

50 name = Column(String(32), nullable=False, unique=True) 

51 longname = Column(String(128), nullable=False) 

52 displayname = Column(String(128), nullable=False) 

53 cf_standardname = Column(String(128), nullable=False) 

54 units = Column(String(64), nullable=False) 

55 chemical_formula = Column(String(128), nullable=False) 

56 

57 timeseries = relationship("Timeseries", back_populates="variable")