Skip to content

Commit

Permalink
Insert fields into the function class zacharyvoase#4
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Walton committed May 10, 2013
1 parent cec5a25 commit 5a7458c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions django_postgres/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def create_function(connection, function_name, function_fields,
function_sql = _generate_function(
name, args, function_fields, function_definition)

print function_sql
cursor.execute(function_sql)
ret = 'UPDATED' if function_exists else 'CREATED'
else:
Expand Down Expand Up @@ -168,7 +167,8 @@ class Meta:
if fields:
attrs.update(fields)

return type(name, (models.Model,), attrs)
name_to_use = '{0}Function'.format(name)
return type(name_to_use, (models.Model,), attrs)


class FunctionManager(models.Manager):
Expand Down Expand Up @@ -196,8 +196,9 @@ def call(self, args=None):
name=function_name,
args=execute_arguments)

fields = get_fields_by_name(self.model, '*')
model = _create_model(
model_name, execute_function, None, app_label, module)
model_name, execute_function, fields, app_label, module)
return models.query.QuerySet(model, query.NonQuotingQuery(model))

def get_queryset(self):
Expand Down

0 comments on commit 5a7458c

Please sign in to comment.