Skip to content

Table-Returning Functions #4

@scott-w

Description

@scott-w

It would be nice to be able to treat a function that returns a table as a Model in Django.

I'm thinking something along the lines of what's already in the View class, but a function gets called instead.

The reason for using a function is to create more powerful "views" that can be generated, and queried, at runtime.

It will need extra information so that the sync command can create the function names, arguments etc.

An example:

class MyFunc(TableFunction):

    class Meta:
        arguments = (
           ( 'arg1',  'DATE'),
        )

        sql = 'SELECT my_column FROM my_table WHERE some_date = $1'

    my_column = models.CharField()

The idea is still a little poorly-formed in my mind, so I'll try and put some sample code together and see if I can get the result I want before pushing anything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions