Closed tungbhrelipa closed 1 year ago
I fixed this by read the doc and the solution code below:
import { sql } from "@pgtyped/runtime";
import { IFindByTransactionHashListResult } from "./internal_transactions.queries";
interface createSimilarityFunctionQuery {
params: void;
result: void;
}
export const createSimilarityFunction = sql<createSimilarityFunctionQuery>`
CREATE EXTENSION IF NOT EXISTS pg_trgm;
`;
export interface IGetSimilarContractParams {
input_deployed_bytecode: string;
threshold: number;
}
export type IGetSimilarContractResult = IFindByTransactionHashListResult;
export interface IGetSimilarContractQuery {
params: IGetSimilarContractParams;
result: IGetSimilarContractResult;
}
export const findSimilarContract = sql<IGetSimilarContractQuery>`
SELECT *
FROM internal_transactions
WHERE
created_contract_code <> ''
AND created_contract_code IS NOT NULL
AND SIMILARITY(ENCODE(created_contract_code, 'escape')::TEXT , $input_deployed_bytecode) >= $threshold
ORDER BY block_number ASC
LIMIT 1;
`;
Describe the bug I created a simple query code
and it threw an error
I have found the way to use the similar function is that I have to run
CREATE EXTENSION IF NOT EXISTS pg_trgm;
first. Then, I updated my SQL codeAnd again, it threw another error
How can I fix this?