class Node(Entity, schema="circular_deps", registry=REGISTRY, polymorph="type"): id: Serial type: String = Field(nullable=False) parent_id: Auto = ForeignKey("Node.id") author_id: Auto = ForeignKey("circular_deps.User.id") author: One["circular_deps.User"]
class ArticleA(Entity, registry=reg_ambiguous): id: Serial creator_id: Auto = ForeignKey(UserA.id) creator: One[UserA] = "UserA.id == ArticleA.creator_id" updater_id: Auto = ForeignKey(User.id) updater: One[UserA] = "UserA.id == ArticleA.updater_id"
class __User(Entity, name="User", schema="circular_deps", registry=REGISTRY): id: Serial name: String contract_id: Auto = ForeignKey(Document.id) contract: One[Document] profile_image_id: Auto = ForeignKey("circular_deps.File.id", on_delete="SET NULL") profile_image: One["circular_deps.File"]
class User(Entity): id: Serial name: String email: String created_time: DateTimeTz address_id: Int = ForeignKey(Address.id) address: One[Address] tags: ManyAcross["UserTags", "Tag"] # birth_date: @virtual def name_q(self): return self.name @name_q.compare def name_q_compare(cls, q: Query, op: Any, value: Any): if op is contains: res = [] parts = value.split() for p in parts: res.append(cls.name.contains(p)) return or_(*res) else: return op(cls.name, value)
class User2(Entity, schema="execution_private", name="User", registry=REGISTRY): id: Serial name: String email: String address_id: Auto = ForeignKey(Address.id) address: One[Address]
class User(Entity, schema="execution", registry=REGISTRY): id: Serial uuid: UUID name: String = Field(size=100) bio: String fixed_char: String = Field(size=[5, 5]) secret: Bytes address_id: Auto = ForeignKey(Address.id) address: One[Address] salary: Numeric = Field(size=[15, 2]) distance_mm: Float distance_km: Float = Field(size=8) point: Point is_active: Bool = True birth_date: Date naive_date: DateTime = datetime(2019, 1, 1, 12, 34, 55) created_time: DateTimeTz = func.now() updated_time: DateTimeTz time: Time time_tz: TimeTz @virtual def virtual_prop(self): return f"VIRTUAL:{self.id}"
class User4(Entity): id: Serial name: String password: String = DontSerialize() address_id: Int = ForeignKey(User4Addr.id) address: One[User4Addr] many: Many["User4Many"]
class User(Entity, registry=_registry, schema="ent_load"): id: Serial name: Composite[FullName] address_id: Auto = ForeignKey(Address.id) address: One[Address] children: Many["UserChild"] tags: ManyAcross["UserTags", "Tag"]
class User(BaseEntity, schema="deps"): id: Serial name: String address_id: Auto = ForeignKey(Address.id) address: One[Address] caddress: One[Address] = "Address.id == User.address_id" forward: Many["Forward"] backward: Many[Backward] tags: ManyAcross["UserTags", Tag] ctags: ManyAcross["UserTags", Tag] = { "UserTags": "UserTags.user_id == User.id", Tag: "Tag.id == UserTags.tag_id", }
class User(Entity, schema="execution", registry=new_reg): id: Serial uuid: UUID name_x: String = Field(size=100) bio: String = Field(size=200) fixed_char: Bytes secret: Bytes address_id: Auto = ForeignKey(Address.id) address: One[Address] salary: Numeric = Field(size=[15, 3]) distance_mm: Float distance_km: Float = Field(size=4) point: Point is_active: Bool = True birth_date: String naive_date: DateTimeTz = func.now() created_time: DateTimeTz = func.CURRENT_TIMESTAMP updated_time: DateTimeTz time: Time time_tz: TimeTz
class Something(Entity, registry=_registry, schema="ent_load"): id: Serial article_id: Auto = ForeignKey(Article.id) article: One[Article] = Relation( join="Article.id == Something.article_id") // Loading(always=True)
class UserChild(Entity, registry=_registry, schema="ent_load"): id: Serial parent_id: Auto = ForeignKey(User.id) name: String
class Article(Entity, registry=_registry, schema="ent_load"): id: Serial creator_id: Auto = ForeignKey(User.id) creator: One[User] = "User.id == Article.creator_id" updater_id: Auto = ForeignKey(User.id) updater: One[User] = "User.id == Article.updater_id"
class Tracking: creator_id: Auto = ForeignKey(User.id) creator: One[User] = lambda cls: cls.creator_id == User.id
class UserTags(Entity, registry=_registry, schema="ent_load"): user_id: Auto = ForeignKey(User.id) // PrimaryKey() tag_id: Auto = ForeignKey(Tag.id) // PrimaryKey()
class Node(BaseEntity): id: Serial parent_id: Auto = ForeignKey("Node.id") parent: One["Node"]
class B(Entity): id_a: Int = ForeignKey(GlobalA.id) n_many: Many[GlobalA] fw_many: Many["GlobalA"]
class UserTags(BaseEntity, name="user-tags", schema="deps"): user_id: Auto = ForeignKey(User.id) // PrimaryKey() tag_id: Auto = ForeignKey(Tag.id) // PrimaryKey()
class D(Entity, registry=registry): id: Serial a_id_1: Auto = ForeignKey(A.id) a_id_2: Auto = ForeignKey(A.id)
class AcrossAB(Entity): id_a: Serial = ForeignKey(GlobalA.id) id_b: Serial = ForeignKey(GlobalB.id)
class Forward(BaseEntity, schema="deps"): id: Serial user_id: Auto = ForeignKey(User.id)
class Backward(BaseEntity, schema="deps"): id: Serial user_id: Auto = ForeignKey("User.id")
class Organization(Entity, schema="poly", registry=REGISTRY): id: Serial employee_id: Auto = ForeignKey(Employee.id) employee: One[Employee]
class Something(Entity, schema="poly", registry=registry): id: Serial pid1: Auto = ForeignKey(PolyChild.id) p1: One[PolyChild] = "Something.pid1 == PolyChild.id" pid2: Auto = ForeignKey(PolyChild.id) p2: One[PolyChild] = "Something.pid2 == PolyChild.id"
class Something2(Entity, registry=_registry, schema="ent_load"): id: Serial something_id: Auto = ForeignKey(Something.id) something: One[Something]
class User4Many(Entity): id: Serial many: String parent_id: Int = ForeignKey(User4.id)
class B(BaseEntity): id: Serial = ForeignKey(Z.id1, name="composite_fk") id_a: Int = ForeignKey(A3.id) // ForeignKey(Z.id2, name="composite_fk") id_x: Int = ForeignKey(X.id)
class C(Entity, registry=registry): id: Serial a_id: Auto = ForeignKey(A.id) b_id: Auto = ForeignKey("B.id")
class Mixin: created_time: DateTimeTz = func.now() user_id: Auto = ForeignKey(FKUser.id)
class B(Entity): id_a: Int = ForeignKey(GlobalA.id) n_one: One[GlobalA] fw_one: One["GlobalA"]