# Path: pyelt/datalayers/database.py
# class DbFunction:
#     def __init__(self, *args):
#         self.name = camelcase_to_underscores(self.__class__.__name__)
#         self.func_params = []
#         for arg in args:
#             self.func_params.append(arg)
#         self.sql_body = ''
#         self.return_type = ''
#         self.schema = None
#         self.lang = 'PLPGSQL'
# 
#     def get_complete_name(self):
#         func_args = ''
#         for func_param in self.func_params:
#             func_args += '{} {}, '.format(func_param.name, func_param.type)
#         func_args = func_args[:-2]
#         params = {'schema': self.schema.name, 'name': self.name, 'args': func_args}
#         return '{schema}.{name}({args})'.format(**params)
# 
#     def to_create_sql(self):
#         func_params = ''
#         for func_param in self.func_params:
#             func_params += '{} {}, '.format(func_param.name, func_param.type)
#         func_params = func_params[:-2]
#         params = {'schema': self.schema.name, 'name': self.name, 'params': func_params, 'return_type': self.return_type, 'sql_body': self.sql_body, 'lang': self.lang}
# 
#         sql = """CREATE OR REPLACE FUNCTION {schema}.{name}({params})
#     RETURNS {return_type}
#       AS
#       $BODY$
#         {sql_body}
#       $BODY$
#     LANGUAGE {lang} VOLATILE;""".format(**params)
#         return sql
# 
#     def get_sql(self, alias=''):
#         params = self.__dict__
#         fields = ''
#         for param in self.func_params:
#             if alias:
#                 fields += '{}.{},'.format(alias, param.calling_field)
#             else:
#                 fields += '{},'.format(param.calling_field)
#         fields = fields[:-1]
#         params['fields'] = fields
#         sql = "{schema}.{name}({fields})".format(**params)
#         return sql
# 
#     def parse_args(self, args_str):
#         args = args_str.split(',')
#         self.func_params = []
#         for arg in args:
#             arg = arg.strip()
#             arg_name = arg.split(' ')[0]
#             arg_type = arg.split(' ')[1]
#             self.func_params.append(DbFunctionParameter(arg_name, arg_type))
# 
#     def parse_sql_body(self, sql_body=''):
#         start = sql_body.find('$function$') + len('$function$')
#         end = sql_body.rfind('$function$')
#         body = sql_body[start:end]
#         self.sql_body = body
# 
#     def get_stripped_body(self):
#         body = self.sql_body
#         body = body.replace('  ', '')
#         body = body.replace('  ', '')
#         body = body.replace('\t', '')
#         body = body.replace('\r\n', '')
#         body = body.replace('\n', '')
#         if not body.startswith('DECLARE'):
#             body = 'DECLARE' + body
#         return body
# 
# class DbFunctionParameter:
#     def __init__(self, name='', type='', calling_field=''):
#         self.name = name
#         self.type = type
#         self.calling_field = calling_field


from pyelt.datalayers.database import DbFunction, DbFunctionParameter


class CreateAgb(DbFunction):
    def __init__(self, zorgtype_calling_field='', agb_calling_field=''):
        super().__init__()

# Path: pyelt/datalayers/database.py
# class DbFunction:
#     def __init__(self, *args):
#         self.name = camelcase_to_underscores(self.__class__.__name__)
#         self.func_params = []
#         for arg in args:
#             self.func_params.append(arg)
#         self.sql_body = ''
#         self.return_type = ''
#         self.schema = None
#         self.lang = 'PLPGSQL'
# 
#     def get_complete_name(self):
#         func_args = ''
#         for func_param in self.func_params:
#             func_args += '{} {}, '.format(func_param.name, func_param.type)
#         func_args = func_args[:-2]
#         params = {'schema': self.schema.name, 'name': self.name, 'args': func_args}
#         return '{schema}.{name}({args})'.format(**params)
# 
#     def to_create_sql(self):
#         func_params = ''
#         for func_param in self.func_params:
#             func_params += '{} {}, '.format(func_param.name, func_param.type)
#         func_params = func_params[:-2]
#         params = {'schema': self.schema.name, 'name': self.name, 'params': func_params, 'return_type': self.return_type, 'sql_body': self.sql_body, 'lang': self.lang}
# 
#         sql = """CREATE OR REPLACE FUNCTION {schema}.{name}({params})
#     RETURNS {return_type}
#       AS
#       $BODY$
#         {sql_body}
#       $BODY$
#     LANGUAGE {lang} VOLATILE;""".format(**params)
#         return sql
# 
#     def get_sql(self, alias=''):
#         params = self.__dict__
#         fields = ''
#         for param in self.func_params:
#             if alias:
#                 fields += '{}.{},'.format(alias, param.calling_field)
#             else:
#                 fields += '{},'.format(param.calling_field)
#         fields = fields[:-1]
#         params['fields'] = fields
#         sql = "{schema}.{name}({fields})".format(**params)
#         return sql
# 
#     def parse_args(self, args_str):
#         args = args_str.split(',')
#         self.func_params = []
#         for arg in args:
#             arg = arg.strip()
#             arg_name = arg.split(' ')[0]
#             arg_type = arg.split(' ')[1]
#             self.func_params.append(DbFunctionParameter(arg_name, arg_type))
# 
#     def parse_sql_body(self, sql_body=''):
#         start = sql_body.find('$function$') + len('$function$')
#         end = sql_body.rfind('$function$')
#         body = sql_body[start:end]
#         self.sql_body = body
# 
#     def get_stripped_body(self):
#         body = self.sql_body
#         body = body.replace('  ', '')
#         body = body.replace('  ', '')
#         body = body.replace('\t', '')
#         body = body.replace('\r\n', '')
#         body = body.replace('\n', '')
#         if not body.startswith('DECLARE'):
#             body = 'DECLARE' + body
#         return body
# 
# class DbFunctionParameter:
#     def __init__(self, name='', type='', calling_field=''):
#         self.name = name
#         self.type = type
#         self.calling_field = calling_field


# Path: tests/unit_tests_basic/_db_functions.py
from pyelt.datalayers.database import DbFunction, DbFunctionParameter



class CreateAgb(DbFunction):
    def __init__(self, zorgtype_calling_field='', agb_calling_field=''):
        super().__init__()

        param1 = DbFunctionParameter('zorgtype', 'text', zorgtype_calling_field)