cs-models 0.0.806__py3-none-any.whl → 0.0.807__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cs-models might be problematic. Click here for more details.

@@ -11,7 +11,7 @@ class SmartDefGridModel(Base):
11
11
  """
12
12
  __tablename__ = "smart_def_grids"
13
13
 
14
- id = Column(String(36), primary_key=True) # table_id (uuid string)
14
+ id = Column(Integer, primary_key=True, autoincrement=True) # table_id (uuid string)
15
15
  workbook_id = Column(
16
16
  Integer,
17
17
  ForeignKey('workbooks.id'),
@@ -21,7 +21,7 @@ class SmartDefGridResourceSchema(Schema):
21
21
 
22
22
  # read-only expansion of cells
23
23
  cells = fields.Nested(
24
- SmartDefGridCellResourceSchema(exclude="smart_def_grid_id"),
24
+ SmartDefGridCellResourceSchema(exclude=["smart_def_grid_id"]),
25
25
  many=True,
26
26
  dump_only=True,
27
27
  # if you strictly want to hide 'table_id' inside each cell in this view:
@@ -1,5 +1,5 @@
1
1
  from datetime import datetime
2
- from sqlalchemy import Column, DateTime, ForeignKey, Integer, String, JSON, Boolean, Index
2
+ from sqlalchemy import Column, DateTime, ForeignKey, Integer, String, JSON, Boolean, Index, UniqueConstraint
3
3
  from sqlalchemy.orm import relationship
4
4
  from ...database import Base
5
5
 
@@ -29,7 +29,7 @@ class SmartDefGridCellModel(Base):
29
29
  formatting_spec = Column(JSON, nullable=True)
30
30
 
31
31
  # Optional: cache of the latest generated question id
32
- latest_question_id = Column(String(36), ForeignKey("cell_questions.id"), nullable=True)
32
+ latest_question_id = Column(Integer, ForeignKey("smart_def_grid_cell_questions.id"), nullable=True)
33
33
 
34
34
  created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
35
35
  updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
@@ -38,8 +38,14 @@ class SmartDefGridCellModel(Base):
38
38
  latest_question = relationship("SmartDefGridCellQuestionModel", foreign_keys=[latest_question_id], uselist=False)
39
39
 
40
40
  # Canonical applied cell value (write-back)
41
- applied_value = relationship("SmartDefGridCellValueModel", back_populates="cell", uselist=False, cascade="all, delete-orphan")
41
+ applied_value = relationship(
42
+ "SmartDefGridCellValueModel",
43
+ back_populates="cell",
44
+ uselist=False,
45
+ cascade="all, delete-orphan",
46
+ )
42
47
 
43
48
  __table_args__ = (
49
+ UniqueConstraint("smart_def_grid_id", "row", "col", name="uq_sdg_cell_pos"),
44
50
  Index("ix_smart_def_grid_cells_header", "smart_def_grid_id", "is_header"),
45
51
  )
@@ -1,6 +1,5 @@
1
- import enum
2
1
  from datetime import datetime
3
- from sqlalchemy import Column, DateTime, ForeignKey, Float, String, JSON, Integer, Index, Text
2
+ from sqlalchemy import Column, DateTime, ForeignKey, Float, String, JSON, Integer, Index, Text, BigInteger, ForeignKeyConstraint
4
3
  from sqlalchemy.orm import relationship
5
4
  from ...database import Base
6
5
 
@@ -11,7 +10,7 @@ class SmartDefGridCellAnswerModel(Base):
11
10
  """
12
11
  __tablename__ = "smart_def_grid_cell_answers"
13
12
 
14
- id = Column(String(36), primary_key=True) # answer_id (uuid)
13
+ id = Column(BigInteger, primary_key=True, autoincrement=True)
15
14
  question_id = Column(Integer, ForeignKey("smart_def_grid_cell_questions.id", ondelete="CASCADE"), nullable=False)
16
15
 
17
16
  smart_def_grid_id = Column(Integer, ForeignKey("smart_def_grids.id", ondelete="CASCADE"), nullable=False)
@@ -32,6 +31,11 @@ class SmartDefGridCellAnswerModel(Base):
32
31
 
33
32
  # convenience index to quickly get latest by created_at
34
33
  __table_args__ = (
34
+ ForeignKeyConstraint(
35
+ ["smart_def_grid_id", "cell_id"],
36
+ ["smart_def_grid_cells.smart_def_grid_id", "smart_def_grid_cells.cell_id"],
37
+ ondelete="CASCADE",
38
+ ),
35
39
  Index("ix_smart_def_grid_cell_answers_cell", "smart_def_grid_id", "cell_id", "created_at"),
36
40
  )
37
41
 
@@ -1,6 +1,6 @@
1
1
  import enum
2
2
  from datetime import datetime
3
- from sqlalchemy import Column, DateTime, ForeignKey, Integer, String, JSON, Boolean, Index, Text, Enum
3
+ from sqlalchemy import Column, DateTime, ForeignKey, Integer, String, JSON, Boolean, Index, Text, Enum, ForeignKeyConstraint
4
4
  from sqlalchemy.orm import relationship
5
5
  from ...database import Base
6
6
 
@@ -24,7 +24,7 @@ class SmartDefGridCellQuestionModel(Base):
24
24
  """
25
25
  __tablename__ = "smart_def_grid_cell_questions"
26
26
 
27
- id = Column(Integer, primary_key=True) # question_id (uuid)
27
+ id = Column(Integer, primary_key=True, autoincrement=True) # question_id (uuid)
28
28
  smart_def_grid_id = Column(Integer, ForeignKey("smart_def_grids.id", ondelete="CASCADE"), nullable=False)
29
29
  cell_id = Column(String(36), nullable=False)
30
30
 
@@ -57,6 +57,11 @@ class SmartDefGridCellQuestionModel(Base):
57
57
  Index("ix_smart_def_grid_cell_questions_queue", "status", "priority", "created_at"),
58
58
  # Quick lookup for this cell's active question(s)
59
59
  Index("ix_smart_def_grid_cell_questions_cell", "smart_def_grid_id", "cell_id"),
60
+ ForeignKeyConstraint(
61
+ ["smart_def_grid_id", "cell_id"],
62
+ ["smart_def_grid_cells.smart_def_grid_id", "smart_def_grid_cells.cell_id"],
63
+ ondelete="CASCADE",
64
+ ),
60
65
  # strong uniqueness if you want only one ACTIVE per cell; or enforce app-side
61
66
  # UniqueConstraint("table_id", "cell_id", "status", name="uq_cell_question_cell_status"),
62
67
  )
@@ -1,7 +1,8 @@
1
1
  from datetime import datetime
2
- from sqlalchemy import Column, DateTime, ForeignKey, Float, String, JSON, Boolean, Integer, Text
2
+ from sqlalchemy import Column, DateTime, ForeignKey, Float, String, JSON, Boolean, Integer, Text, ForeignKeyConstraint, and_
3
3
  from sqlalchemy.orm import relationship
4
4
  from ...database import Base
5
+ from ..SmartDefGridCell.models import SmartDefGridCellModel
5
6
 
6
7
 
7
8
  class SmartDefGridCellValueModel(Base):
@@ -15,7 +16,7 @@ class SmartDefGridCellValueModel(Base):
15
16
  cell_id = Column(String(36), primary_key=True)
16
17
 
17
18
  # applied value derived from a specific answer_id (or manual override)
18
- answer_id = Column(Integer, ForeignKey("smart_def_grid_cell_answers.id"), nullable=True)
19
+ answer_id = Column(Integer, ForeignKey("smart_def_grid_cell_answers.id", ondelete="SET NULL"), nullable=True)
19
20
  raw_value = Column(Float, nullable=True)
20
21
  display_text = Column(Text, nullable=True)
21
22
  citations = Column(JSON, nullable=True)
@@ -28,6 +29,24 @@ class SmartDefGridCellValueModel(Base):
28
29
  applied_at = Column(DateTime, default=datetime.utcnow, nullable=False)
29
30
  updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
30
31
 
32
+ __table_args__ = (
33
+ ForeignKeyConstraint(
34
+ ["smart_def_grid_id", "cell_id"],
35
+ ["smart_def_grid_cells.smart_def_grid_id", "smart_def_grid_cells.cell_id"],
36
+ ondelete="CASCADE",
37
+ ),
38
+ )
39
+
31
40
  # relationships
32
- cell = relationship("SmartDefGridCellModel", back_populates="applied_value")
41
+ cell = relationship(
42
+ "SmartDefGridCellModel",
43
+ back_populates="applied_value",
44
+ uselist=False,
45
+ primaryjoin=lambda: and_(
46
+ SmartDefGridCellValueModel.smart_def_grid_id == SmartDefGridCellModel.smart_def_grid_id,
47
+ SmartDefGridCellValueModel.cell_id == SmartDefGridCellModel.cell_id,
48
+ ),
49
+ foreign_keys=lambda: [SmartDefGridCellValueModel.smart_def_grid_id, SmartDefGridCellValueModel.cell_id],
50
+ )
51
+
33
52
  answer = relationship("SmartDefGridCellAnswerModel", foreign_keys=[answer_id])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cs-models
3
- Version: 0.0.806
3
+ Version: 0.0.807
4
4
  Summary: MySQL db models
5
5
  Home-page: https://github.com/mindgram/cs-models
6
6
  Author: Shrey Verma
@@ -954,22 +954,22 @@ cs_models/resources/Signature13F/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRk
954
954
  cs_models/resources/Signature13F/models.py,sha256=E-n7Fz1Lz7XOeD6H6Ca0TIe6ixxRXao0hWGGZJkr4m8,538
955
955
  cs_models/resources/Signature13F/schemas.py,sha256=5I0yQ5amGPQg2yoklmtJJ4HiQe14kNpw7OCUXFmrm1o,457
956
956
  cs_models/resources/SmartDefGrid/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
957
- cs_models/resources/SmartDefGrid/models.py,sha256=D2esCzBhZJI4Zo0nRvn-qAmxwa4JdIemAlapa0lGMt8,1243
958
- cs_models/resources/SmartDefGrid/schemas.py,sha256=ju7pZH4a-A9nbqya0yUGjMaN4lYqJ6IkOmtgHwhhM4U,2083
957
+ cs_models/resources/SmartDefGrid/models.py,sha256=DuukDDYw-6U9KYfcciksTeC30uLlCZSWW8T-oKneGR8,1260
958
+ cs_models/resources/SmartDefGrid/schemas.py,sha256=xmzr2f8sYVx5l9KU1SezytyRZUwmVAzm2Iwq1CqdHNs,2085
959
959
  cs_models/resources/SmartDefGridCell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
960
- cs_models/resources/SmartDefGridCell/models.py,sha256=n9VLx_2fuymJCwQqkS-prfXV9FhNTRQ6ZJcVUfRix-s,2161
960
+ cs_models/resources/SmartDefGridCell/models.py,sha256=rbvJPsKQLhWZjUMza1--kS5oQC_D7Ylde8jAzjRoG_8,2315
961
961
  cs_models/resources/SmartDefGridCell/schemas.py,sha256=opd_dD3dj-U618RABBAo8UFAKwt9wPev1WVnPQca26c,1479
962
962
  cs_models/resources/SmartDefGridCellAnswer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
963
- cs_models/resources/SmartDefGridCellAnswer/models.py,sha256=S0JoLWAV_hf9KAyStwztoI5zt3HQjuXFpKhOIHdrtLU,1706
963
+ cs_models/resources/SmartDefGridCellAnswer/models.py,sha256=sQgZDzZUIw7WRUtjrVwk9BZANCnxcuxFaQ-9x4WCDto,1935
964
964
  cs_models/resources/SmartDefGridCellAnswer/schemas.py,sha256=Nvt2pRq7SbbFmnp6EWrvao0A9BmmXqHOsTqf3qTo22Y,915
965
965
  cs_models/resources/SmartDefGridCellAnswerCitation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
966
966
  cs_models/resources/SmartDefGridCellAnswerCitation/models.py,sha256=pCNakAl08pSFTbuhJypF43zDfoapZDsvFPH2PP7QQqo,916
967
967
  cs_models/resources/SmartDefGridCellAnswerCitation/schemas.py,sha256=1dYybWcoSuhP0OLqwQ3igNeexMcV-Nj0IqtBaPVap-Q,568
968
968
  cs_models/resources/SmartDefGridCellQuestion/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
969
- cs_models/resources/SmartDefGridCellQuestion/models.py,sha256=69DbO4LvJXyyMIgWlukSX7CGPm3fof3hH-LsBTaYK_s,2724
969
+ cs_models/resources/SmartDefGridCellQuestion/models.py,sha256=cn2k5mBB-YPcAECLdO2y-3QB1_Db9MtKkLXIsWp0kWg,2973
970
970
  cs_models/resources/SmartDefGridCellQuestion/schemas.py,sha256=L6WKwJA5h-s46SlpdJAdC2B4kj0yfNwhPQw5EAU1pm8,1536
971
971
  cs_models/resources/SmartDefGridCellValue/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
972
- cs_models/resources/SmartDefGridCellValue/models.py,sha256=TJiiqYkwVfqEsVF2VxrDFzvIAheL5r4UvH5Qx0lAAco,1526
972
+ cs_models/resources/SmartDefGridCellValue/models.py,sha256=s5Tnj7s633qbAM14Eh4OU1QHN-CeSUe7GZSGrzywOGA,2259
973
973
  cs_models/resources/SmartDefGridCellValue/schemas.py,sha256=fqp1odR0nPheKjGeLScs9lPR6bDZzWVm2x78NNLuIRc,637
974
974
  cs_models/resources/SmartGrid/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
975
975
  cs_models/resources/SmartGrid/models.py,sha256=9weIkYbh-Y-My5vjjUP-N-ziSNV-AWww1UUltK8EIy0,1011
@@ -1318,7 +1318,7 @@ cs_models/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1318
1318
  cs_models/utils/alchemy.py,sha256=fhINGFn41owJ2DLXQKXAAtLqeZ1BRzD_qU0wPK_bsGQ,1598
1319
1319
  cs_models/utils/utils.py,sha256=BzCDk3u1np7DoJQqCZIJN4f80JNHvJoWO4qEFgolN-8,4474
1320
1320
  cs_models/utils/profiling/__init__.py,sha256=N-73vb0M92C975fxgXyBCBjCPELl8Oh21ZY_-tzDnns,569
1321
- cs_models-0.0.806.dist-info/METADATA,sha256=JeYpP8IGiDomdCYnBn4P7mEgZtPdFnnJkkmBvfz4Mxc,751
1322
- cs_models-0.0.806.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
1323
- cs_models-0.0.806.dist-info/top_level.txt,sha256=M7CA8Nh5t0vRManQ9gHfphhO16uhMqIbfaxr1jPDg18,10
1324
- cs_models-0.0.806.dist-info/RECORD,,
1321
+ cs_models-0.0.807.dist-info/METADATA,sha256=mAyTc6ckLHPStWK7qq_5p47Gji1jWfcSCznqpK52fAE,751
1322
+ cs_models-0.0.807.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
1323
+ cs_models-0.0.807.dist-info/top_level.txt,sha256=M7CA8Nh5t0vRManQ9gHfphhO16uhMqIbfaxr1jPDg18,10
1324
+ cs_models-0.0.807.dist-info/RECORD,,