fix(data-consult): corrige uso de bind variables incompatíveis com Oracle
- Substitui REGEXP_REPLACE com bind variables por pré-processamento do filtro no backend - Evita erro ORA-01036 ao utilizar parâmetros posicionais (?) em conjunto com funções Oracle - Garante segurança e compatibilidade com TypeORM e driver Oracle
This commit is contained in:
@@ -110,6 +110,10 @@ export class DataConsultRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async findProducts(filter: string): Promise<ProductDto[]> {
|
async findProducts(filter: string): Promise<ProductDto[]> {
|
||||||
|
const cleanFilter = filter.replace(/[^\d]/g, '');
|
||||||
|
const likeFilter = filter + '%';
|
||||||
|
const codAux = filter.replace(/[^\d]/g, '');
|
||||||
|
|
||||||
const queries = [
|
const queries = [
|
||||||
{
|
{
|
||||||
sql: `
|
sql: `
|
||||||
@@ -117,10 +121,10 @@ export class DataConsultRepository {
|
|||||||
PCPRODUT.CODPROD || ' - ' || PCPRODUT.DESCRICAO ||
|
PCPRODUT.CODPROD || ' - ' || PCPRODUT.DESCRICAO ||
|
||||||
' ( ' || REGEXP_REPLACE(PCPRODUT.CODAUXILIAR, '[^0-9]', '') || ' )' as "description"
|
' ( ' || REGEXP_REPLACE(PCPRODUT.CODAUXILIAR, '[^0-9]', '') || ' )' as "description"
|
||||||
FROM PCPRODUT
|
FROM PCPRODUT
|
||||||
WHERE PCPRODUT.CODPROD = REGEXP_REPLACE(?, '[^0-9]', '')
|
WHERE PCPRODUT.CODPROD = ?
|
||||||
ORDER BY PCPRODUT.DESCRICAO
|
ORDER BY PCPRODUT.DESCRICAO
|
||||||
`,
|
`,
|
||||||
params: [filter],
|
params: [cleanFilter],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sql: `
|
sql: `
|
||||||
@@ -128,10 +132,10 @@ export class DataConsultRepository {
|
|||||||
PCPRODUT.CODPROD || ' - ' || PCPRODUT.DESCRICAO ||
|
PCPRODUT.CODPROD || ' - ' || PCPRODUT.DESCRICAO ||
|
||||||
' ( ' || REGEXP_REPLACE(PCPRODUT.CODAUXILIAR, '[^0-9]', '') || ' )' as "description"
|
' ( ' || REGEXP_REPLACE(PCPRODUT.CODAUXILIAR, '[^0-9]', '') || ' )' as "description"
|
||||||
FROM PCPRODUT
|
FROM PCPRODUT
|
||||||
WHERE PCPRODUT.CODAUXILIAR = REGEXP_REPLACE(?, '[^0-9]', '')
|
WHERE PCPRODUT.CODAUXILIAR = ?
|
||||||
ORDER BY PCPRODUT.DESCRICAO
|
ORDER BY PCPRODUT.DESCRICAO
|
||||||
`,
|
`,
|
||||||
params: [filter],
|
params: [codAux],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sql: `
|
sql: `
|
||||||
@@ -142,7 +146,7 @@ export class DataConsultRepository {
|
|||||||
WHERE PCPRODUT.DESCRICAO LIKE ?
|
WHERE PCPRODUT.DESCRICAO LIKE ?
|
||||||
ORDER BY PCPRODUT.DESCRICAO
|
ORDER BY PCPRODUT.DESCRICAO
|
||||||
`,
|
`,
|
||||||
params: [filter + '%'],
|
params: [likeFilter],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user