hasura / ndc-jvm-mono

0 stars 2 forks source link

Schema name appended with table name in `tableName` property of configuration.json file #13

Open nihxdr opened 3 days ago

nihxdr commented 3 days ago

Including the schema name in tableName property is restrictive and seems unnecessary, since it won't allow us to use the same metadata files generated for different databases with the same schema.

https://github.com/hasura/ndc-jvm-mono/blob/441f6b027ef83be005d9bab8aa4be124e650a3d3/ndc-cli/src/main/kotlin/io/hasura/cli/MySQLConfigGenerator.kt#L23

nihxdr commented 3 days ago

I was able to run MySQL queries after following these steps:


We would have the metadata file names as such: TableName, instead of SchemaNameTableName

here are the before and after of the SQL queries shown in the logs of the data connector: before:

select json_object('rows', (
  select json_arrayagg(json_object('email', email))
  from (
    select <schema_name>.<table_name>.email as email
    from <schema_name>.<table_name>
    group by <schema_name>.<table_name>.email
  ) as <alias>
))

after:

select json_object('rows', (
  select json_arrayagg(json_object('email', email))
  from (
    select <table_name>.email as email
    from <table_name>
    group by <table_name>.email
  ) as <alias>
))

But we may have to check for and resolve the conflicting metadata files generated from multiple data sources (or instead of removing the schema name it should be taken from env? )

GavinRay97 commented 3 days ago

Hmm, I suppose there's no reason why a flag couldn't exist to omit schema name.

For some historical context, all DB connectors (MySQL/Oracle etc) used to run as one service, and you could add any type of database, or even multiple connections to the same database type.

For example, /api/v1/mysql/query, /api/v1/oracle/query

I'm not 100% sure if we still need the schema name in MySQL connector.

I have not tried using a JDBC URL with MySQL which doesn't specify a database. Since in that case you would need <db/schema_name>.<table_name> to disambiguate.