Git Product home page Git Product logo

atlas-provider-typeorm's People

Contributors

giautm avatar ronenlu avatar rotemtam avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

atlas-provider-typeorm's Issues

"Driver not connected"

The module si not working with postgres dialect, postgres does not have in memory databases.

There are various issues:

  1. The loadEntities method is missing a call to await mockDb.initialize() actually it throws Driver not connected exception
  2. To terminate the process, await mockDB.destroy(); should be added at the end of the method before returning the queries.
  3. Postgres does not offers in-memory databases. You have various approaches, one of them would be to use pg-mem but it is not officially supported by postgres. Or really connect to a non vistrual DB. To to so additional parameters should be added to the script such as the dbname, username and password. Or the function should allow to add environment variables.
  4. The method does not export all objects required for our database. Enums are not exported which make the initial migration to fail.

Please find a modified version here:

export async function loadEntities(
  dialect: Dialect,
  // eslint-disable-next-line @typescript-eslint/ban-types
  entities: (Function | EntitySchema | string)[],
) {
  const mockDB = new DataSource({
    type: dialect,
    host: process.env.TYPEORM_HOST,
    port: Number(process.env.TYPEORM_PORT),
    username: process.env.TYPEORM_USERNAME,
    password: process.env.TYPEORM_PASSWORD,
    database: process.env.TYPEORM_DATABASE,
    schema: process.env.TYPEORM_SCHEMA,
    entities,
    logging: false,
    synchronize: false,
  });

  await mockDB.initialize();

  const driver = mockDB.driver;
  const sqlInMemory = await driver.createSchemaBuilder().log();

  const queries = sqlInMemory.upQueries.map((query) => query.query);

  await mockDB.destroy();
  return queries.join(';\n');
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.