schemats icon indicating copy to clipboard operation
schemats copied to clipboard

Type [undefined] has been mapped to [any] because no specific type has been found.

Open coderq opened this issue 6 years ago • 6 comments

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

coderq avatar May 02 '18 03:05 coderq

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.

abenhamdine avatar May 02 '18 13:05 abenhamdine

OP could you share the DDL of one of your table (for example test_article)? Also try running without -s mydb

xiamx avatar May 02 '18 13:05 xiamx

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;
}

talzion12 avatar Nov 13 '18 06:11 talzion12

Did anyone find a solution to this?

sunojvijayan avatar Jun 30 '19 03:06 sunojvijayan