# Path: wh.py
# def xlt(s): # translate
#   return s
#   t=wx.GetTranslation(s)
#   # if dict set and t == s: log untranslated
#   return t
# 
# def YesNo(b):
#   if b:
#     return xlt("Yes")
#   else:
#     return xlt("No")


from _objects import SchemaObject
from _pgsql import pgQuery
from wh import xlt, YesNo
import logger
# The Admin4 Project
# (c) 2013-2014 Andreas Pflug
#
# Licensed under the Apache License, 
# see LICENSE.TXT for conditions of usage




class Function(SchemaObject):
  typename=xlt("Function")
  shortname=xlt("Function")
  refreshOid="pro.oid"
  allGrants='X'
  favtype='f'
  relkind='P'


  
  @staticmethod
  def FindQuery(schemaName, schemaOid, patterns):
    sql=pgQuery("pg_proc p")
    sql.AddCol("'P' as kind")
    sql.AddCol("nspname")
    sql.AddCol("proname as name")
    sql.AddCol("n.oid as nspoid")
    sql.AddCol("p.oid")
    sql.AddJoin("pg_namespace n ON n.oid=pronamespace")

# Path: wh.py
# def xlt(s): # translate
#   return s
#   t=wx.GetTranslation(s)
#   # if dict set and t == s: log untranslated
#   return t
# 
# def YesNo(b):
#   if b:
#     return xlt("Yes")
#   else:
#     return xlt("No")


# Path: modPg/Function.py
from _objects import SchemaObject
from _pgsql import pgQuery
from wh import xlt, YesNo
import logger

# The Admin4 Project
# (c) 2013-2014 Andreas Pflug
#
# Licensed under the Apache License, 
# see LICENSE.TXT for conditions of usage




class Function(SchemaObject):
  typename=xlt("Function")
  shortname=xlt("Function")
  refreshOid="pro.oid"
  allGrants='X'
  favtype='f'
  relkind='P'


  
  @staticmethod
  def FindQuery(schemaName, schemaOid, patterns):
    sql=pgQuery("pg_proc p")
    sql.AddCol("'P' as kind")
    sql.AddCol("nspname")
    sql.AddCol("proname as name")
    sql.AddCol("n.oid as nspoid")
    sql.AddCol("p.oid")
    sql.AddJoin("pg_namespace n ON n.oid=pronamespace")

    SchemaObject.AddFindRestrictions(sql, schemaName, schemaOid, 'proname', patterns)