Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting up a model for a table with a dot/period in the name #2430

Open
awo00 opened this issue May 22, 2023 · 0 comments
Open

Setting up a model for a table with a dot/period in the name #2430

awo00 opened this issue May 22, 2023 · 0 comments
Labels

Comments

@awo00
Copy link

awo00 commented May 22, 2023

Hello,

I am working with an old database and trying to use Objection to query it. Unfortunately there are a few tables with a dot/period in their name. I've been able to use raw() to access these tables, but I haven't been able to set up a Model. One of these Models is set up like this:

import { Model } from 'objection';

export class CustomersContacts extends Model {
    CustomerID!: string;
    ContactID!: string;
    Type!: number;

    static get tableName() {
        return 'Customers.Contacts';
    }
}

But this queries the table as [Customers].[Contacts] when I want [Customers.Contacts]. Any addition of square brackets makes no difference to the output, trying double quotes surrounding the name produces ["Customers].[Contacts"], and I am unable to use the raw() function in this method.

Apart from renaming the table, is there any way to get this set up correctly?

Thanks.

@lehni lehni added the bug label Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants