def amalgamate_sql(app, model, extra_fields=None, table_name=None,<EOL>view_name=None):
if extra_fields == None:<EOL><INDENT>extra_fields = []<EOL><DEDENT>extra_fields = "<STR_LIT:U+002CU+0020>".join(extra_fields)<EOL>if extra_fields:<EOL><INDENT>extra_fields = "<STR_LIT:U+002CU+0020>" + extra_fields<EOL><DEDENT>if not table_name:<EOL><INDENT>table_name = "<STR_LIT>" % (app, model)<EOL><DEDENT>if not view_name:<EOL><INDENT>view_name = "<STR_LIT>" % table_name<EOL><DEDENT>return """<STR_LIT>""" % dict(view_name=view_name,<EOL>app=app,<EOL>model=model,<EOL>table_name=table_name,<EOL>extra_fields=extra_fields)<EOL>
This function returns a string, containing SQL to create
    a view exposing given model's content_type_id and object_id,
    with some extra_fields optionally.

    This function does *not* escape or quote its arguments.

    >>> print(utils.amalgamate_sql('tests', 'phone', ['foo', 'x as y']))

            CREATE VIEW tests_phone_view AS
            SELECT
                U0.id::text || '_' || test_phone.id::text AS fake_id,
                U0.id AS content_type_id,
                tests_phone.id AS object_id
                , foo, x as y
            FROM
                tests_phone,
                (SELECT
                    id
                 FROM
                    django_content_type
                 WHERE
                    app_label = 'tests' AND
                    model = 'phone'
                ) U0;