Describe the bug
When passing an object as the indexMethod argument to addToOperatorFamily, the resulting SQL statement contains USING [object Object] if the object is not properly stringified. This is due to direct string interpolation for indexMethod.
|
export type Name = string | { schema?: string; name: string }; |
|
return `ALTER OPERATOR FAMILY ${operatorFamilyNameStr} USING ${indexMethod} ADD |
|
${operatorListStr};`; |
Example:
const statement = addToOperatorFamily(options1)(
'integer_ops',
{ schema: 'myschema', name: 'btree' },
[
{
type: 'operator',
number: 1,
name: '<',
params: [{ type: 'int4' }, { type: 'int2' }],
},
]
);
// statement contains: 'USING [object Object]'
Test Case:
it('should coerce object indexMethod to [object Object] if not handled', () => {
const addToOperatorFamilyFn = addToOperatorFamily(options1);
const statement = addToOperatorFamilyFn(
'integer_ops',
{ schema: 'myschema', name: 'btree' },
[
{
type: 'operator',
number: 1,
name: '<',
params: [{ type: 'int4' }, { type: 'int2' }],
},
]
);
expect(statement).toContain('USING [object Object]');
});
we need to handle it when it contains schema.
Steps to reproduce
- Call
addToOperatorFamily with an object for indexMethod, e.g. { schema: 'myschema', name: 'btree' }.
- Observe the generated SQL statement.
Logs
No response
System Info
Describe the bug
When passing an object as the
indexMethodargument toaddToOperatorFamily, the resulting SQL statement containsUSING [object Object]if the object is not properly stringified. This is due to direct string interpolation forindexMethod.node-pg-migrate/src/operations/generalTypes.ts
Line 27 in f4b4ab4
node-pg-migrate/src/operations/operators/addToOperatorFamily.ts
Lines 28 to 29 in f4b4ab4
Example:
Test Case:
we need to handle it when it contains schema.
Steps to reproduce
addToOperatorFamilywith an object forindexMethod, e.g.{ schema: 'myschema', name: 'btree' }.Logs
No response
System Info