-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Transformation Model and its routes (#39)
* Added Transformation Model and its routes
- Loading branch information
1 parent
2f1505b
commit 1ad1345
Showing
10 changed files
with
357 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from __future__ import annotations | ||
from typing import Literal, Union, List | ||
from peewee import ( | ||
CharField, | ||
ForeignKeyField, | ||
TextField, | ||
IntegerField, | ||
BooleanField, | ||
) | ||
from playhouse.sqlite_ext import JSONField | ||
|
||
from sand.models.base import BaseModel | ||
from sand.models.table import Table | ||
|
||
|
||
class Transformation(BaseModel): | ||
name = CharField() | ||
table = ForeignKeyField(Table, backref="transformations", on_delete="CASCADE") | ||
mode = CharField() | ||
datapath: Union[List[str], str] = JSONField() # type: ignore | ||
outputpath: List[str] = JSONField() # type: ignore | ||
type = CharField() | ||
code = TextField() | ||
on_error: Literal[ | ||
"set_to_blank", "store_error", "keep_original", "abort" | ||
] = CharField() | ||
is_draft = BooleanField() | ||
order = IntegerField() | ||
insert_after = ForeignKeyField("self", null=True, on_delete="SET NULL") | ||
|
||
def to_dict(self): | ||
return { | ||
"id": self.id, | ||
"name": self.name, | ||
"table": self.table_id, | ||
"type": self.type, | ||
"mode": self.mode, | ||
"datapath": self.datapath, | ||
"outputpath": self.outputpath, | ||
"code": self.on_error, | ||
"on_error": self.on_error, | ||
"is_draft": self.is_draft, | ||
"order": self.order, | ||
"insert_after": self.insert_after, | ||
} |
Oops, something went wrong.