Insert silently fails with missing table name?

Hi everyone!

I've been using Drizzle the past few days and so far it's been a breeze. However, I've ran into an issue today that I cannot seem to figure out.

I have a schema file that contains table definitions, like:

export const clients = pgTable("clients", {
  id: text("id").primaryKey().notNull(),
  createdAt: timestamp("created_at").defaultNow().notNull(),
  company: text("company").notNull().unique(),
  // The rest of the columns
});

export type Client = typeof clients.$inferSelect;
export type NewClient = typeof clients.$inferInsert;

export const accounts = pgTable("accounts", {
  id: text("id").primaryKey().notNull(),
  createdAt: timestamp("created_at").defaultNow().notNull(),
  email: text("email").unique().notNull(),
  // The rest of the columns
});


I am using RDS Data API with Drizzle. Created a repository service class for Clients and Accounts as well. I have the necessary functions such as getters, inserts, etc. For example, this is how a new client is inserted into the database:

public async insertClient(client: NewClient) {
  if (!this.repository) {
    await this.createRepositoryAccess(); // Ensure that drizzle() is called already
  }

  return this.repository
    .insert(clients)
    .values(client)
    .returning({
      id: clients.id,
      createdAt: clients.createdAt,
  });
}


This works perfectly, the client is inserted, all good. When I try to do the exact same thing with the "accounts" table however, the insert fails silently with 0 logs, 0 errors (callers are wrapped with try/catch), and as return value, I just get an empty object.

The "accounts" insert method:

public async createNewAccount(accountData: NewAccount) {
  if (!this.repository) {
    await this.createRepositoryAccess();
  }

  return this.repository
    .insert(accounts)
    .values(accountData)
    .returning({
      id: accounts.id,
      createdAt: accounts.createdAt,
    });
}


Anyone has ever seen something like this?
Was this page helpful?