Пример #1
0
    def post(self, column_id):
        # We only allow manual updates of description, as rest is updated from database
        req = request.get_json(True)
        required_fields = ("description",)

        for f in required_fields:
            if f not in req:
                abort(400)

        data_source_column = get_object_or_404(models.DataSourceColumn.get_by_id, column_id)

        data_source_column.description = req["description"]
        data_source_column.save()

        # Refresh cache
        refresh_schema.delay(data_source_column.table.datasource)

        return data_source_column.to_dict()
Пример #2
0
    def post(self):
        req = request.get_json(True)
        required_fields = ("column_id", "related_table_id", "related_column", "cardinality")

        for f in required_fields:
            if f not in req:
                abort(400)

        column = get_object_or_404(models.DataSourceColumn.get_by_id, req["column_id"])
        related_column = get_object_or_404(
            models.DataSourceColumn.get, table=req["related_table_id"], name=req["related_column"]
        )

        join, create = models.DataSourceJoin.get_or_create(
            table=column.table,
            column=column,
            related_table=related_column.table,
            related_column=related_column,
            cardinality=req["cardinality"],
        )

        refresh_schema.delay(column.table.datasource)

        return join.to_dict(all=True)