diff --git a/console/src/components/Services/Data/Schema/Schema.js b/console/src/components/Services/Data/Schema/Schema.js
index a36415165fb..8e66b058d10 100644
--- a/console/src/components/Services/Data/Schema/Schema.js
+++ b/console/src/components/Services/Data/Schema/Schema.js
@@ -50,6 +50,7 @@ import {
} from '../../../../metadata/selector';
import { RightContainer } from '../../../Common/Layout/RightContainer';
import { TrackableFunctionsList } from './FunctionsList';
+import { getTrackableFunctions } from './utils';
const DeleteSchemaButton = ({ dispatch, migrationMode, currentDataSource }) => {
const successCb = () => {
@@ -264,18 +265,6 @@ class Schema extends Component {
dispatch(updateCurrentSchema(e.target.value, currentDataSource));
};
- const _getTrackableFunctions = () => {
- const trackedFuncNames = trackedFunctions.map(fn => fn.function_name);
-
- // Assuming schema for both function and tables are same
- // return function which are tracked
- const filterCondition = func => {
- return !trackedFuncNames.includes(func.function_name);
- };
-
- return functionsList.filter(filterCondition);
- };
-
const getSectionHeading = (headingText, tooltip, actionElement = null) => {
return (
@@ -293,8 +282,11 @@ class Schema extends Component {
const allUntrackedTables = getUntrackedTables(
getSchemaTables(schema, currentSchema)
);
- const trackableFuncs = _getTrackableFunctions();
+ const trackableFuncs = getTrackableFunctions(
+ functionsList,
+ trackedFunctions
+ );
const getCreateBtn = () => {
let createBtn = null;
diff --git a/console/src/components/Services/Data/Schema/utils.ts b/console/src/components/Services/Data/Schema/utils.ts
new file mode 100644
index 00000000000..de269e3513e
--- /dev/null
+++ b/console/src/components/Services/Data/Schema/utils.ts
@@ -0,0 +1,23 @@
+import {
+ ArgType,
+ PGFunction,
+ PGInputArgType,
+} from '../../../../dataSources/services/postgresql/types';
+
+export const getTrackableFunctions = (
+ functionsList: PGFunction[],
+ trackedFunctions: PGFunction[]
+): PGFunction[] => {
+ const trackedFuncNames = trackedFunctions.map(fn => fn.function_name);
+ const containsTableArgs = (arg: PGInputArgType): boolean =>
+ arg.type.toLowerCase() === ArgType.CompositeType;
+ // Assuming schema for both function and tables are same
+ // return function which are tracked
+ const filterCondition = (func: PGFunction) => {
+ return (
+ !trackedFuncNames.includes(func.function_name) &&
+ !func.input_arg_types?.some(containsTableArgs)
+ );
+ };
+ return functionsList.filter(filterCondition);
+};
diff --git a/console/src/dataSources/services/postgresql/types.ts b/console/src/dataSources/services/postgresql/types.ts
index 20ff05a94bc..55c93f90b4e 100644
--- a/console/src/dataSources/services/postgresql/types.ts
+++ b/console/src/dataSources/services/postgresql/types.ts
@@ -1,7 +1,7 @@
export type PGInputArgType = {
schema: string;
name: string;
- type: string;
+ type: ArgType;
};
export type PGFunction = {
@@ -57,11 +57,16 @@ export interface PostgresTrigger {
event_manipulation: string;
}
-type InputArgType = {
+export type InputArgType = {
schema: string;
name: string;
};
+export enum ArgType {
+ CompositeType = 'c',
+ BaseType = 'b',
+}
+
export interface FunctionState {
functionName: string;
inputArgTypes: InputArgType[];