The field list contains an unidentified column named 'Test.computerIDComputerID'

I am currently navigating through the syntax of typeORM and have been stuck troubleshooting an issue for quite some time. It appears that whenever I utilize the find() function in typeORM, a query is generated with a duplicated column from a relation. Here is a snippet of the code I've been working on:

if(!typeORM.isInitialized)
    await typeORM.initialize()

const test2 = await typeORM.getRepository(Test)
const result  = await test2.find({where: {testID: 98}, relations: {computerID:true}})
console.log(result)

When running this code, I encounter the following error:

  code: 'ER_BAD_FIELD_ERROR',
  errno: 1054,
  sqlMessage: "Unknown column 'Test.computerIDComputerID' in 'field list'",
  sqlState: '42S22',
  index: 0,
  sql: 'SELECT `Test`.`testID` AS `Test_testID`, `Test`.`name` AS `Test_name`, `Test`.`testParameters` AS `Test_testParameters`, `Test`.`saveOutput` AS `Test_saveOutput`, `Test`.`deploy` AS `Test_deploy`, `Test`.`computerIDComputerID` AS `Test_computerIDComputerID`, `Test`.`suiteIDSuiteID` AS `Test_suiteIDSuiteID`, `Test__Test_computerID`.`computerID` AS `Test__Test_computerID_computerID`, `Test__Test_computerID`.`ip` AS `Test__Test_computerID_ip`, `Test__Test_computerID`.`name` AS `Test__Test_computerID_name`, `Test__Test_computerID`.`deployPath` AS `Test__Test_computerID_deployPath`, `Test__Test_computerID`.`cpu` AS `Test__Test_computerID_cpu`, `Test__Test_computerID`.`cores` AS `Test__Test_computerID_cores`, `Test__Test_computerID`.`architecture` AS `Test__Test_computerID_architecture`, `Test__Test_computerID`.`ram` AS `Test__Test_computerID_ram`, `Test__Test_computerID`.`hdd` AS `Test__Test_computerID_hdd`, `Test__Test_computerID`.`speed` AS `Test__Test_computerID_speed`, `Test__Test_computerID`.`os` AS `Test__Test_computerID_os`, `Test__Test_computerID`.`user` AS `Test__Test_computerID_user`, `Test__Test_computerID`.`password` AS `Test__Test_computerID_password` FROM `Test` `Test` LEFT JOIN `Computer` `Test__Test_computerID` ON `Test__Test_computerID`.`computerID`=`Test`.`computerIDComputerID` WHERE (`Test`.`testID` = 98)'

This leads me to my two table entities:

@Entity({name:"Test",synchronize: false})
export class Test{
    @PrimaryGeneratedColumn({ type: "int" })
    testID!: number;         
    @Column({ type: "varchar", length: 50, unique: true })
    name!: string;    

    @ManyToOne(() => Computer, computer => computer.tests)
    @JoinTable({ name: 'computerID'})
    computerID!: Computer;

    @ManyToOne(() => Suite, suite => suite.Test)
    @JoinTable({name: "suiteID"})
    suiteID!: Suite;

    @Column({ type: "varchar", length: 300 })
    testParameters!: string;
    @Column({ type: "tinyint" })
    saveOutput!: number;        
    @Column({ type: "varchar", length: 45 })
    deploy!: string;

    @OneToMany(() => Execution, execution => execution.testID,{cascade: ['insert','update']})
    Execution!: Execution[]

    @OneToMany(() => Scheduler, scheduler => scheduler.testID,{cascade: ['insert','update']})
    Scheduler!: Scheduler[]

}

@Entity({name:"Computer",synchronize: false})
export class Computer {
    @PrimaryGeneratedColumn({ type: "int" })
    computerID!: number;
    @Column({ type: "varchar" })
    ip!: string;
    @Column({ type: "varchar",unique: true })
    name!: string;     
    @Column({ type: "varchar"})
    deployPath!: string;     
    @Column({ type: "varchar"})
    cpu!: string;
    @Column({ type: "varchar"})
    cores!: string;
    @Column({ type: "varchar"})
    architecture!: string;
    @Column({ type: "varchar",unique: true })
    ram!: string;     
    @Column({ type: "varchar"})
    hdd!: string;
    @Column({ type: "varchar"})
    speed!: string;
    @Column({ type: "varchar"})
    os!: string;
    @Column({ type: "varchar"})
    user!: string;     
    @Column({ type: "varchar"})
    password!: string;

    @OneToMany(() => Execution, execution => execution.computerID)
    Execution!: Execution[]

    @OneToMany(() => Test, test => test.testID,{cascade: ['insert','update']})
    tests!: Test[]

}

My suspicion lies within the relational structure, as I have successfully implemented similar relationships in the past without encountering such errors.

Answer №1

After some careful examination, I uncovered the minor error that was causing my confusion. Rather than utilizing JoinTable for the ManyToOne/OneToMany relationships, the correct approach is to use JoinColumn.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unable to load the node modules

In my development journey, I created an ASP.NET MVC project using Angular 2 in Visual Studio 2017 and set up node for package management. Here is a snippet from the package.json file: { "version": "1.0.0", "name": "asp.net", "private": true, ... ...

Creating a Pivot Table Dynamically in MySql

In my database, I have a table that stores student marks in the following format: | id | criteriaid | mark | studentid | | 1 | 5 | 62 | 5 | | 2 | 6 | 54 | 5 | | 3 | ...

Save JSON information in a MySQL database table

I'm facing an issue with storing JSON data in a MySQL table using NodeJS. The JSON data structure I am dealing with looks like this: { "header": { "file1":0, "file2":1, "subfiles":{ "subfile1":"true", ...

Developing a collection of components with customizable color variations using React

I am interested in creating a React component library where users can specify color variants. For instance, I want to use the following syntax: const customTheme = createCustomTheme({ button: { variants: { primary: 'primary ...

Guide to altering Date Format within mysql Command

Looking to alter the date format within MySQL command line. create table date(date Date); The dates are currently stored as strings in this format: YYYY-MM-DD Desired format: YYYY Seeking guidance on how to achieve this transformation with mysql? ...

After encountering an error, the puppeteer promptly shuts down the page

During my page testing, an error is thrown by a dependency. Although the error is not critical and does not impact my application, when testing with Puppeteer and encountering this error, it abruptly closes the tested page. How can I bypass this error to c ...

What is the process for implementing Sequelize to manage and modify multiple tables simultaneously?

I am currently working on developing the back-end with DB using Sequelize ORM. My main challenge is creating or updating data in multiple tables simultaneously. Below are some examples of what I am trying to achieve: //Tables const main = sequelize.define ...

Fetching chat messages using an AJAX script depending on the timestamp they were sent

I am currently working on developing a real-time chat application with various rooms as part of my project. Progress has been smooth so far, but I am facing an issue with properly fetching the most recent chat messages from the database. The message table ...

Determining where to implement the API display logic - on the server side or

Currently, I am in the process of restructuring an API that deals with user profiles stored in one table and profile images in another. The current setup involves querying the profiles table first and then looping through the images table to gather the ass ...

Issues may arise in TypeScript when you are working with an array of objects along with other properties within a type

I am encountering an issue with an object structure similar to the one below: let Obj = { ['0'] : { mode: 'x' }, getMode: () => 'x' } The problem arises when I attempt to create a type definition as shown here: type Obj = ...

Creating an array of Form Groups involves first initializing an empty array and then

Here is a JSON object that I need to create a reactive form based on. What steps should I take for the array portion specifically? { "examName" : "java", "password" : "1234.com", "examCategory" : { "id" : 78 }, "examDetailSet" ...

What is the best way to move data from one table to another in a Laravel application?

I need to transfer the data from a table called "posts" in one database to a table named "buss_posts" in another database, and I want to achieve this using Laravel framework. Here is my post table structure in the first database: Schema::create(&apos ...

The angular 5 application encountered an issue where it was unable to access the property 'singlePost' due to a null value, resulting

When using the once method to fetch data from the Firebase database, everything works correctly. However, when I try to use the on method, I encounter an error that says: ERROR TypeError: Cannot read property 'singlePost' of null. How can I prope ...

The selected check icon does not appear in the console log

Objective: Display preselected data from selected checkbox in console.log Issue: The preselected data is not appearing in the console log. When manually checked, the data shows up. What am I missing? About Me: I am a beginner in Angular. Thank ...

What is the best method to extract the values of objects in an array that share

var data= [{tharea: "Rare Disease", value: 3405220}, {tharea: "Rare Disease", value: 1108620}, {tharea: "Rare Disease", value: 9964980}, {tharea: "Rare Disease", value: 3881360}, ...

Error: useRef in TypeScript - cannot be assigned to LegacyRef<HTMLDivElement> type

Struggling to implement useRef in TypeScript and facing challenges. When using my RefObject, I need to access its property current like so: node.current. I've experimented with the following approaches: const node: RefObject<HTMLElement> = us ...

Obtain a Spotify Token and showcase information in next.js

This is a Simple Next.js component designed to display the currently playing song on Spotify. Context: Utilizing app Router Due to Spotify's token requirements necessitating a server-side call, the entire request is made to fetch the song from an ...

Utilize a solitary MySQL connection to deliver outcomes to numerous users simultaneously

Utilizing a single MySQL connection object in NodeJS to serve multiple users is an approach I have taken. This means that the MySQL connection is established when the script starts and remains active throughout the life of the node script/server. In pract ...

Utilizing a single code base for both Web development with Angular 4 and Mobile app development with Ionic 3

I'm interested in finding out if I can utilize the same code base for both my Angular 4 web application and an Ionic 3 mobile application that I need to develop. As someone who is new to Ionic 3, I've been exploring the documentation and discove ...

Discover which students have conflicting schedules with themselves

To put it simply, my question involves a table display where student numbers (USN) are concatenated in groups and the entire row is displayed using a foreach loop. Row 1: Subject 1 - 22/07/2015 - 08:00 - 1XX10XX086, 1XX10XX087, 1XX09XX088 Row 2: Subject ...