All files / blong-int-adapter/mysql/adapter/sql sqlSchemaProcedureSync.ts

46.42% Statements 13/28
100% Branches 1/1
0% Functions 0/1
46.42% Lines 13/28

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 291x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                               1x  
import {handler} from '@feasibleone/blong';
 
/**
 * sqlSchemaProcedureSync — synchronises inline stored-procedure definitions to
 * the database using the knex adapter's built-in `schemaProcedureSync` method.
 *
 * For the integration test we create a trivial `sql_schema_list_active` procedure
 * that returns all rows from `schema_item` where `schema_item_active = 1`.
 */
export default handler(
    () =>
        async function sqlSchemaProcedureSync(
            _params: Record<string, unknown>,
            _$meta: Record<string, unknown>,
        ): Promise<{created: string[]}> {
            return (
                this.schemaProcedureSync as (...args: unknown[]) => Promise<{created: string[]}>
            )([
                {
                    name: 'sql_schema_list_active',
                    sql: `CREATE PROCEDURE \`sql_schema_list_active\`()
BEGIN
    SELECT * FROM \`schema_item\` WHERE \`schemaItemActive\` = 1;
END`,
                },
            ]);
        },
);