spinlud / sequelize-typescript-generator

71 stars 27 forks source link

`metadata.schema` must be set for postgres #23

Closed vjpr closed 2 years ago

vjpr commented 3 years ago

Thanks for making this. Just a small validation issue in programmatic interface.

  1. Update programmatic docs to include schema field
  2. Add default to public for PG
Fetching metadata from source
Executing (default): SELECT 1+1 AS result
Executing (default): SELECT 
                t.table_name                AS table_name,
                obj_description(pc.oid)     AS table_comment
            FROM information_schema.tables t
            JOIN pg_class pc
                ON t.table_name = pc.relname
            WHERE t.table_schema='undefined' AND pc.relkind = 'r';
Couldn't find any table for database chinook and provided filters
t.table_schema='undefined'
spinlud commented 3 years ago

Hi there, thanks for the feedback!

I've updated the builder so it forces public schema on Postgres if not specified:

const config: IConfig = {
    connection: {
        // ...
    },
    metadata: {
        schema: undefined, // will be forced to 'public'
    },
    output: {
        // ...
    },
    strict: true,
};

const dialect = new DialectPostgres();

const builder = new ModelBuilder(config, dialect);

Let me know if it works for you