hasura-camelize icon indicating copy to clipboard operation
hasura-camelize copied to clipboard

Prefix table with source when db is not the default

Open cj opened this issue 3 years ago • 1 comments

Prefixing the table with the source name when the db is not the default avoids naming conflicts. i.e. if both databases have a table named orders

cj avatar Jan 14 '22 00:01 cj

Thanks for contributing!

I'm not sure if this should really be the default behavior though, people may have non-default source without wanting the tables renamed in that way. The same behavior can easily be achieved by:

import convert from 'hasura-camelize';

const source = 'custom';
convert(
  {
    ...,
    source
  },
  {
    transformTableNames(
      name,
      defaultTransformer
    ) {
      return defaultTransformer(`${source}_${name}`);
    };
  }
);

Or maybe I didn't fully understand the intend. In that case, could you elaborate a bit more?

bkniffler avatar Jan 14 '22 06:01 bkniffler