schemats
schemats copied to clipboard
Type [undefined] has been mapped to [any] because no specific type has been found.
when I run this command, it always show the message that you have seen in the title.
schemats generate -c mysql://root:12345678@localhost:3306/mydb -o ./test.ts -t article -t book -t subscription -t test_article -t test_book -t test_toc -t test_version -t toc -t tool -t tool_type -t version -s mydb
And the file which has been generated is like this:
export namespace articleFields {
export type undefined = any;
}
export interface article {
undefined: articleFields.undefined;
}
export namespace bookFields {
export type undefined = any;
}
export interface book {
undefined: bookFields.undefined;
}
export namespace subscriptionFields {
export type undefined = any;
}
export interface subscription {
undefined: subscriptionFields.undefined;
}
export namespace test_articleFields {
export type undefined = any;
}
export interface test_article {
undefined: test_articleFields.undefined;
}
export namespace test_bookFields {
export type undefined = any;
}
export interface test_book {
undefined: test_bookFields.undefined;
}
export namespace test_tocFields {
export type undefined = any;
}
export interface test_toc {
undefined: test_tocFields.undefined;
}
export namespace test_versionFields {
export type undefined = any;
}
export interface test_version {
undefined: test_versionFields.undefined;
}
export namespace tocFields {
export type undefined = any;
}
export interface toc {
undefined: tocFields.undefined;
}
export namespace toolFields {
export type undefined = any;
}
export interface tool {
undefined: toolFields.undefined;
}
export namespace tool_typeFields {
export type undefined = any;
}
export interface tool_type {
undefined: tool_typeFields.undefined;
}
export namespace versionFields {
export type undefined = any;
}
export interface version {
undefined: versionFields.undefined;
}
How can I fix this problem?
node version is 8.9.1 schemats version is 3.0.3
weird IIRC this message is supposed to happen when an unknowned sql type is found in the schema. But the message should display that type.
OP could you share the DDL of one of your table (for example test_article)?
Also try running without -s mydb
I also encountered this error message when I used postgres' composite types.
For example for this SQL definition:
CREATE TYPE TEST_COMPOSITE as (
first_name text,
last_name text
);
CREATE TABLE test (
id UUID PRIMARY KEY,
test_composite TEST_COMPOSITE
);
This typescript is generated:
export namespace testFields {
export type id = string;
export type test_composite = any | null;
}
export interface test {
id: testFields.id;
test_composite: testFields.test_composite;
}
Did anyone find a solution to this?