fix(f5): make catalog SQL text parameter types explicit
This commit is contained in:
+12
-12
@@ -156,17 +156,17 @@ export class F5AuthoritativeInventoryCatalog1790087300000 implements MigrationIn
|
|||||||
|
|
||||||
await queryRunner.query(`
|
await queryRunner.query(`
|
||||||
INSERT INTO finding_categories(code,name,sort_order,is_active)
|
INSERT INTO finding_categories(code,name,sort_order,is_active)
|
||||||
SELECT $1,'DH · Modelo de Inventarios F5',270,true
|
SELECT $1::varchar,'DH · Modelo de Inventarios F5',270,true
|
||||||
WHERE NOT EXISTS (SELECT 1 FROM finding_categories WHERE lower(code)=lower($1))
|
WHERE NOT EXISTS (SELECT 1 FROM finding_categories WHERE lower(code)=lower($1::varchar))
|
||||||
`, [CATALOG_CATEGORY_CODE]);
|
`, [CATALOG_CATEGORY_CODE]);
|
||||||
await queryRunner.query(`
|
await queryRunner.query(`
|
||||||
UPDATE finding_categories
|
UPDATE finding_categories
|
||||||
SET name='DH · Modelo de Inventarios F5',sort_order=270,is_active=true,updated_at=CURRENT_TIMESTAMP
|
SET name='DH · Modelo de Inventarios F5',sort_order=270,is_active=true,updated_at=CURRENT_TIMESTAMP
|
||||||
WHERE lower(code)=lower($1)
|
WHERE lower(code)=lower($1::varchar)
|
||||||
`,[CATALOG_CATEGORY_CODE]);
|
`,[CATALOG_CATEGORY_CODE]);
|
||||||
const categoryId = await this.id(
|
const categoryId = await this.id(
|
||||||
queryRunner,
|
queryRunner,
|
||||||
`SELECT id FROM finding_categories WHERE lower(code)=lower($1) LIMIT 1`,
|
`SELECT id FROM finding_categories WHERE lower(code)=lower($1::varchar) LIMIT 1`,
|
||||||
[CATALOG_CATEGORY_CODE],
|
[CATALOG_CATEGORY_CODE],
|
||||||
'F5 finding category',
|
'F5 finding category',
|
||||||
);
|
);
|
||||||
@@ -192,7 +192,7 @@ export class F5AuthoritativeInventoryCatalog1790087300000 implements MigrationIn
|
|||||||
const itemCode = hashCode('F5-H',itemKey);
|
const itemCode = hashCode('F5-H',itemKey);
|
||||||
let itemId = await this.optionalId(
|
let itemId = await this.optionalId(
|
||||||
queryRunner,
|
queryRunner,
|
||||||
`SELECT id FROM finding_catalog_items WHERE lower(code)=lower($1) LIMIT 1`,
|
`SELECT id FROM finding_catalog_items WHERE lower(code)=lower($1::varchar) LIMIT 1`,
|
||||||
[itemCode],
|
[itemCode],
|
||||||
);
|
);
|
||||||
if (!itemId) {
|
if (!itemId) {
|
||||||
@@ -313,7 +313,7 @@ export class F5AuthoritativeInventoryCatalog1790087300000 implements MigrationIn
|
|||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
const categoryId = await this.optionalId(
|
const categoryId = await this.optionalId(
|
||||||
queryRunner,
|
queryRunner,
|
||||||
`SELECT id FROM finding_categories WHERE lower(code)=lower($1) LIMIT 1`,
|
`SELECT id FROM finding_categories WHERE lower(code)=lower($1::varchar) LIMIT 1`,
|
||||||
[CATALOG_CATEGORY_CODE],
|
[CATALOG_CATEGORY_CODE],
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -341,7 +341,7 @@ export class F5AuthoritativeInventoryCatalog1790087300000 implements MigrationIn
|
|||||||
|
|
||||||
await queryRunner.query(`
|
await queryRunner.query(`
|
||||||
DELETE FROM finding_catalog_asset_overrides
|
DELETE FROM finding_catalog_asset_overrides
|
||||||
WHERE reason=$1
|
WHERE reason=$1::text
|
||||||
`,[F5_AUTO_REASON]);
|
`,[F5_AUTO_REASON]);
|
||||||
|
|
||||||
if (categoryId) {
|
if (categoryId) {
|
||||||
@@ -384,7 +384,7 @@ export class F5AuthoritativeInventoryCatalog1790087300000 implements MigrationIn
|
|||||||
`);
|
`);
|
||||||
await queryRunner.query(`
|
await queryRunner.query(`
|
||||||
DELETE FROM source_documents
|
DELETE FROM source_documents
|
||||||
WHERE document_number=$1 AND issuer='Dirección de Hidrocarburos'
|
WHERE document_number=$1::varchar AND issuer='Dirección de Hidrocarburos'
|
||||||
`,[CATALOG_DOCUMENT_NUMBER]);
|
`,[CATALOG_DOCUMENT_NUMBER]);
|
||||||
await this.restoreF31FamilySyncFunctions(queryRunner);
|
await this.restoreF31FamilySyncFunctions(queryRunner);
|
||||||
|
|
||||||
@@ -430,7 +430,7 @@ export class F5AuthoritativeInventoryCatalog1790087300000 implements MigrationIn
|
|||||||
`,[familyCode,name,level,sourceReference]);
|
`,[familyCode,name,level,sourceReference]);
|
||||||
return this.id(
|
return this.id(
|
||||||
queryRunner,
|
queryRunner,
|
||||||
`SELECT id FROM inventory_families WHERE code=$1 LIMIT 1`,
|
`SELECT id FROM inventory_families WHERE code=$1::varchar LIMIT 1`,
|
||||||
[familyCode],
|
[familyCode],
|
||||||
`inventory family ${familyCode}`,
|
`inventory family ${familyCode}`,
|
||||||
);
|
);
|
||||||
@@ -453,7 +453,7 @@ export class F5AuthoritativeInventoryCatalog1790087300000 implements MigrationIn
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const familyId = await this.id(
|
const familyId = await this.id(
|
||||||
queryRunner,
|
queryRunner,
|
||||||
`SELECT id FROM inventory_families WHERE code=$1 LIMIT 1`,
|
`SELECT id FROM inventory_families WHERE code=$1::varchar LIMIT 1`,
|
||||||
[familyCode],
|
[familyCode],
|
||||||
`family ${familyCode}`,
|
`family ${familyCode}`,
|
||||||
);
|
);
|
||||||
@@ -530,14 +530,14 @@ export class F5AuthoritativeInventoryCatalog1790087300000 implements MigrationIn
|
|||||||
INSERT INTO finding_catalog_asset_overrides(
|
INSERT INTO finding_catalog_asset_overrides(
|
||||||
asset_id,catalog_item_id,is_enabled,reason,created_by,updated_by
|
asset_id,catalog_item_id,is_enabled,reason,created_by,updated_by
|
||||||
)
|
)
|
||||||
SELECT asset.id,mapping.catalog_item_id,true,$1,
|
SELECT asset.id,mapping.catalog_item_id,true,$1::text,
|
||||||
asset.created_by,asset.updated_by
|
asset.created_by,asset.updated_by
|
||||||
FROM assets asset
|
FROM assets asset
|
||||||
JOIN finding_catalog_item_inventory_families mapping
|
JOIN finding_catalog_item_inventory_families mapping
|
||||||
ON mapping.inventory_family_id=asset.inventory_family_id
|
ON mapping.inventory_family_id=asset.inventory_family_id
|
||||||
WHERE asset.inventory_family_id IS NOT NULL
|
WHERE asset.inventory_family_id IS NOT NULL
|
||||||
ON CONFLICT (asset_id,catalog_item_id) DO UPDATE SET
|
ON CONFLICT (asset_id,catalog_item_id) DO UPDATE SET
|
||||||
is_enabled=true,reason=$1,updated_at=CURRENT_TIMESTAMP
|
is_enabled=true,reason=$1::text,updated_at=CURRENT_TIMESTAMP
|
||||||
`,[F5_AUTO_REASON]);
|
`,[F5_AUTO_REASON]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user