Introspector does not differentiate between enums of different schemas
See original GitHub issueProblem
If a Postgres column uses the type test.status
, the introspector simply infers it as status
, so enum name collisions are possible.
import { Kysely, sql } from 'kysely';
const up = async (db: Kysely<any>) => {
await db.transaction().execute(async (trx) => {
await trx.schema
.createSchema('test')
.ifNotExists()
.execute();
await trx.schema
.withSchema('test')
.createType('status')
.asEnum(['FOO', 'BAR'])
.execute();
await trx.schema
.createType('status')
.asEnum(['CONFIRMED', 'UNCONFIRMED'])
.execute();
await trx.schema
.createTable('users')
.addColumn('user_status', sql`status`)
.addColumn('user_status_2', sql`test.status`)
.execute();
});
};
// Introspection result:
[{
{
dataType: 'status',
enumValues: null,
hasDefaultValue: false,
isAutoIncrementing: false,
isNullable: true,
name: 'user_status',
},
{
dataType: 'status',
enumValues: null,
hasDefaultValue: false,
isAutoIncrementing: false,
isNullable: true,
name: 'user_status_2',
},
}]
Possible solutions
- Include the schema in the data type (feels like a scary/breaking change):
dataType: 'test.status'
- Add a schema property:
dataTypeSchema: 'public'
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
enums are broken after transformSchema · Issue #1056 - GitHub
This happens for every other enum in my schema. So there's evidently some difference between the original schema and the returned value from ......
Read more >How to Query Enums with GraphQL using Introspection
Introspection allows you to ask a GraphQL schema for information about what queries it supports. In the introspection system, there are 6 ...
Read more >What is the difference between enum and example in ...
The swagger schema validation is not differentiating between enum and example, i.e. if I add a value other than enum values, still the...
Read more >Apollo Federation subgraph specification
The returned schema string includes all uses of federation-specific directives, such as @key . The built-in introspection query's response does not include ...
Read more >Combining Schemas – GraphQL Tools
schema : this is a non-executable schema representing the remote API. The remote schema may be obtained using introspection, or fetched as a ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@RobinBlomberg This will be implemented in the next release. All postgres columns have the new
dataTypeSchema
field set. The default value ispg_catalog
which is the schema of all built-in postgres types.I’d say
dataTypeSchema
is better