コード例 #1
0
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"]
コード例 #2
0
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"
コード例 #3
0
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"]
コード例 #4
0
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)
コード例 #5
0
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]
コード例 #6
0
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}"
コード例 #7
0
class User4(Entity):
    id: Serial
    name: String
    password: String = DontSerialize()

    address_id: Int = ForeignKey(User4Addr.id)
    address: One[User4Addr]

    many: Many["User4Many"]
コード例 #8
0
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"]
コード例 #9
0
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",
    }
コード例 #10
0
    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
コード例 #11
0
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)
コード例 #12
0
class UserChild(Entity, registry=_registry, schema="ent_load"):
    id: Serial
    parent_id: Auto = ForeignKey(User.id)
    name: String
コード例 #13
0
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"
コード例 #14
0
 class Tracking:
     creator_id: Auto = ForeignKey(User.id)
     creator: One[User] = lambda cls: cls.creator_id == User.id
コード例 #15
0
class UserTags(Entity, registry=_registry, schema="ent_load"):
    user_id: Auto = ForeignKey(User.id) // PrimaryKey()
    tag_id: Auto = ForeignKey(Tag.id) // PrimaryKey()
コード例 #16
0
 class Node(BaseEntity):
     id: Serial
     parent_id: Auto = ForeignKey("Node.id")
     parent: One["Node"]
コード例 #17
0
 class B(Entity):
     id_a: Int = ForeignKey(GlobalA.id)
     n_many: Many[GlobalA]
     fw_many: Many["GlobalA"]
コード例 #18
0
class UserTags(BaseEntity, name="user-tags", schema="deps"):
    user_id: Auto = ForeignKey(User.id) // PrimaryKey()
    tag_id: Auto = ForeignKey(Tag.id) // PrimaryKey()
コード例 #19
0
 class D(Entity, registry=registry):
     id: Serial
     a_id_1: Auto = ForeignKey(A.id)
     a_id_2: Auto = ForeignKey(A.id)
コード例 #20
0
class AcrossAB(Entity):
    id_a: Serial = ForeignKey(GlobalA.id)
    id_b: Serial = ForeignKey(GlobalB.id)
コード例 #21
0
class Forward(BaseEntity, schema="deps"):
    id: Serial
    user_id: Auto = ForeignKey(User.id)
コード例 #22
0
class Backward(BaseEntity, schema="deps"):
    id: Serial
    user_id: Auto = ForeignKey("User.id")
コード例 #23
0
ファイル: test_polymorph.py プロジェクト: zozzz/yapic.entity
class Organization(Entity, schema="poly", registry=REGISTRY):
    id: Serial
    employee_id: Auto = ForeignKey(Employee.id)
    employee: One[Employee]
コード例 #24
0
ファイル: test_polymorph.py プロジェクト: zozzz/yapic.entity
 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"
コード例 #25
0
class Something2(Entity, registry=_registry, schema="ent_load"):
    id: Serial
    something_id: Auto = ForeignKey(Something.id)
    something: One[Something]
コード例 #26
0
class User4Many(Entity):
    id: Serial
    many: String
    parent_id: Int = ForeignKey(User4.id)
コード例 #27
0
 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)
コード例 #28
0
 class C(Entity, registry=registry):
     id: Serial
     a_id: Auto = ForeignKey(A.id)
     b_id: Auto = ForeignKey("B.id")
コード例 #29
0
 class Mixin:
     created_time: DateTimeTz = func.now()
     user_id: Auto = ForeignKey(FKUser.id)
コード例 #30
0
 class B(Entity):
     id_a: Int = ForeignKey(GlobalA.id)
     n_one: One[GlobalA]
     fw_one: One["GlobalA"]