Skip to content

Result types do not get generated unless table is under database specified under DB_NAME #274

@Nydauron

Description

@Nydauron

This example was produced on commit f6baee4 (latest main at the time of writing).

On MySQL, assuming that database mydb and staff are created, and that given the following table created by:

CREATE TABLE IF NOT EXISTS staff.announcements (
    id INT PRIMARY KEY AUTO_INCREMENT,
    message VARCHAR(1000)
);

with the following config having db_mysql_mydb is defined as:

    "db_mysql_mydb": {
      "DB_TYPE": "mysql",
      "DB_HOST": "127.0.0.1",
      "DB_PORT": 33306,
      "DB_USER": "root",
      "DB_NAME": "anotherdb"
    }

The SQL following produces incorrect types:

const mixedQualifiedNamesMySqlStaff = sql`
-- @name: mixed qualified names mine
-- @db: db_mysql_mydb
SELECT message FROM staff.announcements`;

The type generation:

export type MixedQualifiedNamesMineParams = [];

export interface IMixedQualifiedNamesMineResult {
	
}

export interface IMixedQualifiedNamesMineQuery {
	params: MixedQualifiedNamesMineParams;
	result: IMixedQualifiedNamesMineResult;
}

It is worth nothing that changing db_mysql_mydb to the following config:

     "db_mysql_mydb": {
       "DB_TYPE": "mysql",
       "DB_HOST": "127.0.0.1",
       "DB_PORT": 33306,
       "DB_USER": "root",
-      "DB_NAME": "anotherdb"
+      "DB_NAME": "staff"
     }

results in the correct behavior:

export type MixedQualifiedNamesMineParams = [];

export interface IMixedQualifiedNamesMineResult {
	message: string | null;
}

export interface IMixedQualifiedNamesMineQuery {
	params: MixedQualifiedNamesMineParams;
	result: IMixedQualifiedNamesMineResult;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions